Integrate VM's guide: add specific commands for Mysql VM (#659)

* Initial changes for mysql support on vms

* Fix typos in mysql commands.

* Incorporate edits from tech writers review.

* Change grant to be at localhost.

* Add mysql commands to change ratings and show output of registering of vm.

* fixing for missing kube-inject and correct yamls for .vm. namespace

* minor update
This commit is contained in:
Saurabh Mohan 2017-10-31 17:43:18 -07:00 committed by Laurent Demailly
parent d671bcc3ee
commit 4cbbd44b5a
1 changed files with 67 additions and 24 deletions

View File

@ -30,9 +30,8 @@ this infrastructure as a single mesh.
* Setup Istio by following the instructions in the
[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).
* Deploy the [BookInfo]({{home}}/docs/guides/bookinfo.html) sample application (in the `bookinfo` namespace).
* Create a VM named 'vm-1' in the same project as Istio cluster, and [Join the Mesh]({{home}}/docs/setup/kubernetes/mesh-expansion.html).
## Running mysql on the VM
@ -40,24 +39,60 @@ We will first install mysql on the VM, and configure it as a backend for the rat
On the VM:
```bash
sudo apt-get update && apt-get install ...
# TODO copy or link the istio/istio test script
sudo apt-get update && sudo apt-get install -y mariadb-server
sudo mysql
# Grant access to root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
quit;
sudo systemctl restart mysql
```
You can find details of configuring mysql at [Mysql](https://mariadb.com/kb/en/library/download/).
On the VM add ratings database to mysql.
```bash
# Add ratings db to the mysql db
curl -q https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/src/mysql/mysqldb-init.sql | mysql -u root -ppassword
```
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 using the following commands
```bash
# To inspect the ratings
mysql -u root -ppassword test -e "select * from ratings;"
+----------+--------+
| ReviewID | Rating |
+----------+--------+
| 1 | 5 |
| 2 | 4 |
+----------+--------+
# To change the ratings
mysql -u root -ppassword test -e "update ratings set rating=1 where reviewid=1;select * from ratings;"
+----------+--------+
| ReviewID | Rating |
+----------+--------+
| 1 | 1 |
| 2 | 4 |
+----------+--------+
```
## Find out the IP address of the VM that will be used to add it to the mesh
On the VM:
```bash
hostname -I
```
## Registering the mysql service with the mesh
### Machine admin
First step is to configure the VM sidecar, by adding the service port and restarting the sidecar.
On the DB machine:
On a host with access to `istioctl` commands, register the VM and mysql db service
```bash
sudo echo "ISTIO_INBOUND_PORTS=..." > /var/lib/istio/envoy/sidecar.env
sudo chown istio-proxy /var/lib/istio/envoy/sidecar.env
sudo systemctl restart istio
# Or
db$ sudo istio-pilot vi /var/lib/istio/envoy/sidecar.env
# add mysql port to the "ISTIO_INBOUND_PORTS" config
istioctl register -n vm mysqldb <ip-address-of-vm> 3306
# Sample output
$ istioctl register mysqldb 192.168.56.112 3306
I1015 22:24:33.846492 15465 register.go:44] Registering for service 'mysqldb' ip '192.168.56.112', ports list [{3306 mysql}]
I1015 22:24:33.846550 15465 register.go:49] 0 labels ([]) and 1 annotations ([alpha.istio.io/kubernetes-serviceaccounts=default])
W1015 22:24:33.866410 15465 register.go:123] Got 'services "mysqldb" not found' looking up svc 'mysqldb' in namespace 'default', attempting to create it
W1015 22:24:33.904162 15465 register.go:139] Got 'endpoints "mysqldb" not found' looking up endpoints for 'mysqldb' in namespace 'default', attempting to create them
I1015 22:24:33.910707 15465 register.go:180] No pre existing exact matching ports list found, created new subset {[{192.168.56.112 <nil> nil}] [] [{mysql 3306 }]}
I1015 22:24:33.921195 15465 register.go:191] Successfully updated mysqldb, now with 1 endpoints
```
### Cluster admin
@ -68,18 +103,26 @@ On the DB machine:
kubectl delete service mysql
```
Run istioctl to configure the service (on your admin machine):
```bash
istioctl register mysql IP PORT
istioctl register mysql IP mysql:PORT
```
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 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 that it works, create version 2 of the ratings service that uses the mysql db on the VM. Then specify route rules that force the review service to use the ratings version 2.
```bash
# Create the version of ratings service that will use mysql back end
istioctl kube-inject -n bookinfo -f samples/bookinfo/kube/bookinfo-ratings-v2-mysql-vm.yaml | kubectl apply -n bookinfo -f -
More details here soon.
See the [MySQL](https://github.com/istio/istio/blob/master/samples/rawvm/README.md) document in the meantime.
# Create route rules that will force bookinfo to use the ratings back end
istioctl create -n bookinfo -f samples/bookinfo/kube/route-rule-ratings-mysql-vm.yaml
```
You can verify the output of bookinfo application is showing 1 star from Reviewer1 and 4 stars from Reviewer2 or change the ratings on your VM and see the results.
You can also find some troubleshooting and other information in the [RawVM MySQL](https://github.com/istio/istio/blob/master/samples/rawvm/README.md) document in the meantime.