HA Kubernetes cluster with Vagrant+CoreOS+Ansible, Part 5
In the last part, we have managed to deploy the Kubernetes core components using
bootbuke and be able to access to cluster using the dashboard. We’ll now use an example to demonstrate the deployment of services and expose the services using Ingress and route traffic by domain name.
In this example I’ll deploy two services using nginx, and expose one of the service using the domain nginx1.tectusdreamlab.com and the other using nginx2.tectusdreamabl.com. I’ll enable TLS and automatically redirect http to https.
To get started we need have the certs and keys in order to enable TLS, we’ll use the same root CA and use the same cert for both services by adding both domains in the san.
# START INGRESS
In the ingress spec, we’ll enable redirect and specify domain-based routing to route requests coming with nginx1.tectusdreamlab.com to service nginx1 and nginx2.tectusdreamlab.com to service nginx2.
We need to define the deployment and service specs for the two services of course, you can find the full content of the example role on my github.
Deploy the example on the cluster by running:
Tips: You have to disable the host key checking to make this work. The inventory file is generated by vagrant automatcially.
After a while, you should see your services up and running in Kubernetes cluster and the ingress created.
/etc/hosts file to add the DNS records:
You’ll find the two sites accessible from your browser.
As this example demonstrates, Kubernetes can be easily used as a micro-services infrastructure in which each services can be exposed by it’s domain name. The scaling of a service are automatically controlled by Kubernetes, the only thing we need to handle is the scaling of the Kubernetes cluster itself.