Bookinfo with a Virtual Machine

    Bookinfo running on VMs

    Before you begin

    We will first install MySQL on the VM, and configure it as a backend for the ratings service. All commands below should be run on the VM.

    Set up authentication:

    1. $ cat <<EOF | sudo mysql
    2. # Grant access to root
    3. GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
    4. # Grant root access to other IPs
    5. CREATE USER 'root'@'%' IDENTIFIED BY 'password';
    6. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
    7. quit;
    8. EOF
    9. $ sudo systemctl restart mysql

    You can find details of configuring MySQL at .

    On the VM add ratings database to mysql.

    1. $ mysql -u root -ppassword < mysqldb-init.sql

    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 to inspect the ratings:

    and to change the ratings

    1. $ mysql -u root -ppassword test -e "update ratings set rating=1 where reviewid=1;select * from ratings;"
    2. +----------+--------+
    3. | ReviewID | Rating |
    4. +----------+--------+
    5. | 1 | 1 |
    6. | 2 | 4 |
    7. +----------+--------+

    Expose the mysql service to the mesh

    When the virtual machine is started, it will automatically be registered into the mesh. However, just like when creating a Pod, we still need to create a Service before we can easily access it.

    1. $ cat <<EOF | kubectl apply -f - -n vm
    2. apiVersion: v1
    3. kind: Service
    4. labels:
    5. app: mysqldb
    6. spec:
    7. ports:
    8. - port: 3306
    9. name: tcp
    10. selector:
    11. app: mysqldb
    12. EOF

    Zip

    Create route rules that will force Bookinfo to use the ratings back end:

    1. $ kubectl apply -n bookinfo -f @samples/bookinfo/networking/virtual-service-ratings-mysql-vm.yaml@

    You can verify the output of the Bookinfo application is showing 1 star from Reviewer1 and 4 stars from Reviewer2 or change the ratings on your VM and see the results.

    Reaching Kubernetes services from the virtual machine

    In the above example, we treated our virtual machine as only a server. We can also seamlessly call Kubernetes services from our virtual machine:

    1. $ curl productpage.bookinfo:9080
    2. ...
    3. ...

    Istio’s DNS proxying automatically configures DNS for the virtual machine, allowing us to make calls to Kubernetes hostnames.