Create a Kubernetes cluster with OpenStack Magnum on Fuga Cloud

You will learn how to create a Kubernetes Cluster with the OpenStack CLI and Magnum.

 

The terminology used in this document;

OpenStack - Our Cloud infrastructure software used at Fuga
Magnum - The engine in OpenStack that installs Kubernetes
Heat - Orchestration service in OpenStack
Stack - Object in Heat with a list of items
Cinder - Storage backend in OpenStackRequirements

Requirements

To use the example scripts and files you need a few things;

Setting up the OpenStack CLI

You need Python3 and its advised to use a virtual environment (virtualenv). To setup run;

python3 ~/virtualenv/openstack
. ~/virtualenv/openstack/bin/activate
pip install openstackclient python-magnumclient

Before you move on, you have to be able to use the OpenStack command and talk to OpenStack, for example, list your servers;

openstack server list

Verify it works as expected.

Creating a template

Before you can deploy a cluster, you need a template. This is the syntax;

openstack coe cluster template create --image ${image} \
--external-network public \
--master-flavor ${master_flavor} \
--flavor ${node_flavor} \
--coe kubernetes \
--volume-driver cinder \
--network-driver flannel \
--docker-volume-size ${volume_in_GB} \
--labels kube_dashboard_enabled=0,kube_tag=${version_tag} \
${name}

 

${image} = "ac6c15cc-9073-4537-98d9-00f4ccfefa25"

this is the fedora atomic image in Fuga's OpenStack infra at R2. Do not change this

 

${master_flavor} = "c2.small"

this depends on your cluster sizing, for testing you can safely use c2.small

 

${node_flavor} = "c2.medium"

also depends on personal usage, sizing, and preference

 

${volume_in_GB} = "choose size"

All your nodes will have a volume attached. Set the sizing of these volumes in GB.

 

${version_tag} = "v1.13.10"

this is appended to the tag pulled from docker.io. openstackmagnum on docker.io maintains these images and availability
at this time, the highest verified working version is 1.13.10, so using tag "v1.13.10" is advised.

 

${name} = "your-cluster-template"

Choose a cluster template name

Submit your request and you will get your template information in return.

Creating a cluster

openstack coe cluster create --cluster-template ${template_name} \
--master-count 1 \
--node-count ${node_count} \
--keypair ${keypair} \
${name}

 

${template_name}

as created in the step 'Creating a template'

 

master-count = "1"

at this time, we do not support multi masters, so choose 1.

 

${node_count}

how many worker nodes to deploy, they will have anti-affinity, OpenStack will try to divide them amongst the hypervisors

 

${keypair}

the ssh keypair you wish to use deploying your servers (login user fedora)

 

${name}

Choose a cluster name

 

You can monitor the installation while you wait;

openstack coe cluster list

 

At some point, the status should switch from CREATE_IN_PROGRESS to CREATE_COMPLETE. When it's complete, we can retrieve our config ($name is your cluster name);

openstack coe cluster config $name

 

This will download a file called 'config' and place it in the working directory, and it will show you how to use it.

export KUBECONFIG=/home/user/dir/config

 

Before you can talk to the cluster, you need to open the Security Group rule (firewall). As a precaution, you cannot connect to 6443 yet.

Go to the Security Groups tab in our dashboard and add a new rule to the Security Group of your master.

Open Port: Port

Port: 6443

CIDR: <your_IP>/32

 

Now kubectl should be able to use this, and you should be able to communicate with your cluster;

kubectl get nodes -o wide

 

Storage

To configure Kubernetes for storage in OpenStack, apply the storageclass yaml;

kubectl apply -f ../magnum_additions/storageclass.yaml

Now Cinder is available and it's set as the default storageclass. Now the nodes need a label to be able to schedule nodes that need access to the volumes.
You can use the supplied script

./node.sh

Examples

Nginx

The cluster is now ready for deployment with storage. Try the Nginx example, which deploys Nginx with storage and a load balancer;

kubectl apply -f nginx_example.yaml

 

Once deployed, you should be able to list the services, and see Nginx;

kubectl get svc

nginx LoadBalancer 10.254.253.43 <pending|ip> 80:30363/TCP

 

You should see either 'pending' or an IP. When 'pending' it's still provisioning the load balancer. Once it's done, it will show you an IP.
If your security group on the load balancer allows it, you can check Nginx on port 80, or use the script to open it for you;

./open_nginx_http.sh

 

Now a curl on the IP should show you the default Nginx page. Once done, you can delete Nginx;

kubectl delete -f nginx_example.yaml

Conclusion

You now learned how to create a Kubernetes Cluster through the Fuga Cloud CLI. If you have any questions please don't hesitate to start a chat. We are happy to help you.