Kubernetes 1.0 has been lately released - it was announced at OSCON on July 21st.
As an OpenStack user, and regular OpenStack infra contributor, I can see a high value on Kubernetes + OpenStack integration.
For that reason, I started a project, based on https://github.com/GoogleCloudPlatform/kubernetes/tree/master/contrib/ansible , to automate a Kubernetes cluster using OpenStack (used HP Cloud as a sample).
In this post, I will be describing the steps needed to deploy a whole Kubernetes cluster in few steps. All source files used are stored on https://github.com/kubestack/kubestack.
You will need ansible ... ideally, you should download ansible branch on https://github.com/ansible/ and use develop branch to work. If you execute:
We will be using OpenStack dynamic inventory plugin for Ansible. So be sure you have latest versions of https://github.com/openstack-infra/shade/blob/master/doc/source/installation.rst and https://github.com/openstack/os-client-config.
cache:
max_age: 0
clouds:
cloud_name:
cloud: hp
auth:
username: cloud_username
password: XXXX
project_name: cloud_project_name
region_name: cloud_region
Be sure to update cluster.yml with all settings we need for OpenStack (you can check a sample https://github.com/kubestack/kubestack/blob/master/cluster.yml ).
In several OpenStack clouds (HP cloud), name resolution is not working properly. To fix that, be sure to add set_hostname_and_etc_hosts role to cluster.yml, and also be sure to add the code for the role (https://github.com/kubestack/kubestack/tree/master/roles/set_hostname_and_etc_hosts/tasks).
You need to add all the instance names to the instances_list var on cluster.yml.
You may override the inventory file by doing:
Where that path points to Ansible OpenStack dynamic inventory.
That command will start deployment of your Kubernetes cluster on OpenStack. Please wait for a bit for Ansible to conclude deployment, and you'll have your Kubernetes cluster up and running!
As an OpenStack user, and regular OpenStack infra contributor, I can see a high value on Kubernetes + OpenStack integration.
For that reason, I started a project, based on https://github.com/GoogleCloudPlatform/kubernetes/tree/master/contrib/ansible , to automate a Kubernetes cluster using OpenStack (used HP Cloud as a sample).
In this post, I will be describing the steps needed to deploy a whole Kubernetes cluster in few steps. All source files used are stored on https://github.com/kubestack/kubestack.
Before starting
So, what do you need to start? You will need a cloud (HP Cloud, Rackspace...) and a service account with enough permissions to manage instances.You will need ansible ... ideally, you should download ansible branch on https://github.com/ansible/ and use develop branch to work. If you execute:
$ source ./hacking/env-setup
You will be able to run ansible from that branch.We will be using OpenStack dynamic inventory plugin for Ansible. So be sure you have latest versions of https://github.com/openstack-infra/shade/blob/master/doc/source/installation.rst and https://github.com/openstack/os-client-config.
Node provisioning
We will be starting by manual provision of the instances. What you will need:- Boot an instance on your cloud to be used as master. Ensure that you add the meta "groups=masters" to it.
- Boot an instance to be used as etcd server (you can share this service with the master one). Ensure that you add the meta "groups=etcd" to the instance. If you share etcd with master, please add "groups=masters,etcd" to it.
- Boot as much instances on your cloud as minions you need. Ensure that you add the meta "groups=nodes" to it.
os-client-config setup
In order to use OpenStack dynamic inventory we rely on shade and os-client config. So we need to create a file /etc/ansible/openstack.yml with following content:cache:
max_age: 0
clouds:
cloud_name:
cloud: hp
auth:
username: cloud_username
password: XXXX
project_name: cloud_project_name
region_name: cloud_region
Clone ansible playbooks and add extra roles
Clone the playbooks from https://github.com/GoogleCloudPlatform/kubernetes and move to contrib/ansible directory.Be sure to update cluster.yml with all settings we need for OpenStack (you can check a sample https://github.com/kubestack/kubestack/blob/master/cluster.yml ).
In several OpenStack clouds (HP cloud), name resolution is not working properly. To fix that, be sure to add set_hostname_and_etc_hosts role to cluster.yml, and also be sure to add the code for the role (https://github.com/kubestack/kubestack/tree/master/roles/set_hostname_and_etc_hosts/tasks).
You need to add all the instance names to the instances_list var on cluster.yml.
Configure Cluster options
Look though all of the options ingroup_vars/all.yml
and
set the variables to reflect your needs. The options are described there
in full detail. You can take https://github.com/kubestack/kubestack/blob/master/group_vars/all.yml as a sample.Running the playbook
After going through the setup, run the setup script provided on https://github.com/kubestack/kubestack/blob/master/setup.sh . It is the same as the one provided by Google, but using dynamic inventory from Ansible. You simply can run it using:$ ./setup.sh
You may override the inventory file by doing:
INVENTORY=/opt/stack/ansible/contrib/inventory/openstack.py ./setup.sh
Where that path points to Ansible OpenStack dynamic inventory.
That command will start deployment of your Kubernetes cluster on OpenStack. Please wait for a bit for Ansible to conclude deployment, and you'll have your Kubernetes cluster up and running!
Wow... welcome kubernetes 1.0... Kubernetes OpenStack is one step ahead with this announcement. Thanks for sharing
ReplyDelete