Skip to content

Conversation

saumoh
Copy link
Contributor

@saumoh saumoh commented Oct 12, 2017

Add specific commands to support a vm running mysql db that has been setup with the ratings db.

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@ldemailly
Copy link
Member

See also #657
and istio/istio#1114

Copy link

@Rachael-Graham Rachael-Graham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tech writer review

### Machine admin
First step is to configure the VM sidecar, by adding the service port and restarting the sidecar.
```
On the VM add ratings database to mysql. To make it easy to visually inspect the difference in the output of the bookinfo application you can change the ratings that are generated by ratings service.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comma after application

# add mysql port to the "ISTIO_INBOUND_PORTS" config
```
## Registering the mysql service with the mesh
On a host with access to istioctl commands register the VM and mysql db service

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a host with access to istioctl commands, register the VM .."

```

Note that the 'db' machine does not need and should not have special kubernetes priviledges.
Note that the 'mysqldb' virtual machine does not need and should not have special kubernetes priviledges.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special Kubernetes privileges.


## Using the mysql service

The ratings service in bookinfo will use the DB on the machine. To verify it works, you can
modify the ratings value on the database.
The ratings service in bookinfo will use the DB on the machine. To verify it works, create versio 2 of the ratings service that uses the mysql db on the VM. Then specify route rules that force review service to use the ratings version 2.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify that it works, create version 2

that force the review service

@ldemailly
Copy link
Member

that's awesome, thanks, can you make the changes Rachael kindly suggested

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@@ -31,34 +31,41 @@ this infrastructure as a single mesh.
[Installation guide]({{home}}/docs/setup/kubernetes/quick-start.html).

* Deploy the [BookInfo]({{home}}/docs/guides/bookinfo.html) sample application.

* Create a VM named 'db' in the same project as Istio cluster, and [Join the Mesh]({{home}}/docs/setup/kubernetes/mesh-expansion.html).
* Create a VM named 'mysqldb' in the same project as Istio cluster, and [Join the Mesh]({{home}}/docs/setup/kubernetes/mesh-expansion.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the same project as your Istio cluster
(or the Istio cluster) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the name of the VM doesn't (should not) matter; maybe "vm-1" is better to not imply otherwise ?

sudo apt-get update && sudo apt-get install -y mariadb-server
sudo mysql
# Grant remote access by root to db server
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the sidecar this shouldn't be necessary ? (all connections appear to come from localhost) no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Just root@localhost should do it.

On the VM add ratings database to mysql. To make it easy to visually inspect the difference in the output of the bookinfo application, you can change the ratings that are generated by ratings service.
```bash
# Add ratings db to the mysql db
curl -q https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/src/mysql/mysqldb-init.sql | sed -e 's/VALUES (\(.*\),.*/VALUES (\1, 1);/g' | sudo mysql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the sed doing ? we can fix the script if there is an issue with it (which issue?)

Copy link
Contributor Author

@saumoh saumoh Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here i am changing the out put so that there is 1 star rating by each reviewer. Without this change it's really hard to know -visually-is the ratings db is generating the output or not.
There is nothing wrong with the data in the db it's just hard to differentiate the outputs compared to the output of non-mysql ratings service.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to do that with an update (that can be repeated)

kubectl create -f samples/bookinfo/kube/bookinfo-mysql.yaml

# Create route rules that will force bookinfo to use the ratings back end
istioctl create -f samples/bookinfo/kube/route-rule-ratings-db.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want the -mysql versions here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bookinfo-mysql.yaml will create a version of the ratings service that is backed my mysql-db.
the route rule 'route-rule-ratings-db.yaml' will send all ratings svc traffic to that version of ratings service.
The 'route-rule-ratings-db' is common to both mongodb and mysqldb.

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@@ -31,34 +31,41 @@ this infrastructure as a single mesh.
[Installation guide]({{home}}/docs/setup/kubernetes/quick-start.html).

* Deploy the [BookInfo]({{home}}/docs/guides/bookinfo.html) sample application.

* Create a VM named 'db' in the same project as Istio cluster, and [Join the Mesh]({{home}}/docs/setup/kubernetes/mesh-expansion.html).
* Create a VM named 'mysqldb' in the same project as Istio cluster, and [Join the Mesh]({{home}}/docs/setup/kubernetes/mesh-expansion.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the name of the VM doesn't (should not) matter; maybe "vm-1" is better to not imply otherwise ?

# Grant access to root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
quit;
# Allow remote access to mysql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove, not needed

On the VM add ratings database to mysql. To make it easy to visually inspect the difference in the output of the bookinfo application, you can change the ratings that are generated by ratings service.
```bash
# Add ratings db to the mysql db
curl -q https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/src/mysql/mysqldb-init.sql | sed -e 's/VALUES (\(.*\),.*/VALUES (\1, 1);/g' | sudo mysql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to do that with an update (that can be repeated)

On the VM add ratings database to mysql. To make it easy to visually inspect the difference in the output of the bookinfo application, you can change the ratings that are generated by ratings service.
```bash
# Add ratings db to the mysql db
curl -q https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/src/mysql/mysqldb-init.sql | sed -e 's/VALUES (\(.*\),.*/VALUES (\1, 1);/g' | sudo mysql
Copy link
Member

@ldemailly ldemailly Oct 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after the grant you need --password=password (and don't need sudo); lets use

curl https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/src/mysql/mysqldb-init.sql | mysql -u root --password=password

Copy link
Member

@ldemailly ldemailly Oct 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and add examples

$ mysql -u root --password=password test -e "select * from ratings;"
+----------+--------+
| ReviewID | Rating |
+----------+--------+
|        1 |      5 |
|        2 |      4 |
+----------+--------+

and

$ mysql -u root --password=password test -e "update ratings set rating=1 where reviewid=1;select * from ratings"
+----------+--------+
| ReviewID | Rating |
+----------+--------+
|        1 |      1 |
|        2 |      4 |
+----------+--------+

## Registering the mysql service with the mesh
On a host with access to `istioctl` commands, register the VM and mysql db service
```bash
istioctl -n default register mysqldb <ip-address-of-vm> 3306
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-n default seems off

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's show the output too

$ istioctl register mysqldb 10.150.0.5 3306 http:8080
I1014 22:54:12.176972   18162 register.go:44] Registering for service 'mysqldb' ip '10.150.0.5', ports list [{3306 mysql} {8080 http}]
I1014 22:54:12.177248   18162 register.go:49] 0 labels ([]) and 1 annotations ([alpha.istio.io/kubernetes-serviceaccounts=default])
W1014 22:54:13.194812   18162 register.go:123] Got 'services "mysqldb" not found' looking up svc 'mysqldb' in namespace 'default', attempting to create it
W1014 22:54:13.679181   18162 register.go:139] Got 'endpoints "mysqldb" not found' looking up endpoints for 'mysqldb' in namespace 'default', attempting to create them
I1014 22:54:13.954414   18162 register.go:180] No pre existing exact matching ports list found, created new subset {[{10.150.0.5  <nil> nil}] [] [{mysql 3306 } {http 8080 }]}
I1014 22:54:14.243637   18162 register.go:191] Successfully updated mysqldb, now with 2 endpoints

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

1 similar comment
@istio-testing
Copy link
Contributor

Jenkins job istio.github.io/presubmit passed

@ldemailly
Copy link
Member

merging this as it's much better than previous content, we can refine later
(I just got the full demo working with auth and documented each step in a deck - will publish soon - also have one last patch/cherry pick in release-0.2 to add the files mentioned in this updated doc)

@ldemailly ldemailly merged commit 4cbbd44 into istio:master Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants