demo.sh
script which you used provisioned Virtlet, started virtual machine with cirros image, started nginx container and exposed it via Service.
Let's check how it all works.
The script will finish and will ssh into a cirros vm. Switch to another console and list the pods:
kubectl get pod
cirros vm and nginx pod are both listed. Now list the services:
kubectl get svc
Now go back to the first console where you are logged in the cirros vm. Check that you have internet access:
ping 8.8.8.8
ping mirantis.com
In cluster network communication also works. Retrieve data from Nginx. Use Nginx service IP:
curl <nginx_service_ip>
Exit VM using ctrl-d command.
Use the kubectl get
and kubectl describe
commands to view details for the cirros
VM Pod:
Use the kubectl logs
command to view the logs for the cirros
VM Pod:
kubectl logs cirros-vm
Use the kubectl attach
command to attach to the VM console
kubectl attach -it cirros-vm
Now you can create another virtual machine. Let's create Ubuntu VM from Virtlet examples:
cat virtlet/examples/ubuntu-vm-with-testuser.yaml
kubectl apply -f virtlet/examples/ubuntu-vm-with-testuser.yaml
This example also shows how cloud-init script can be used. Here new user: testuser
is created and also ssh key is injected.
Wait for ubuntu VM:
kubectl get pod -w
Now attach to the VM using testuser/testuser credentials:
kubectl attach -it ubuntu-vm-with-testuser
Check if it also has internet connection.
Because Virtlet VMs are just normal Pods you can create Deployment,DaemonSet or even StatefulSet from Virtual Machines:
cat examples/deployment-cirros-vm.yaml
kubectl apply -f examples/deployment-cirros-vm.yaml
When it's ready you can scale it:
kubectl scale --replicas=2 deploy/cirros