Deployment of Kubernetes on OpenStack

Prepare OpenStack environment

Install OpenStack client

$ sudo dnf install -y python-openstackclient
$ sudo pip install python-openstackclient

Create clouds.yaml file

$ vi ~/.config/openstack/clouds.yaml
      project_name: [projectname]
      username: [username]
      password: [password]
    region_name: RegionOne

Note: change the values of [projectname], [username] and [password] accordingly. The values can be found in stackrc file you normally use.

$ openstack --os-cloud dreamhost server list

Download CentOS Atomic image

$ wget -q -O CentOS7-Atomic.qcow2.gz
$ gunzip CentOS7-Atomic.qcow2.gz

Convert image

$ dnf install -y qemu-tools
$ qemu-img convert /tmp/centos7.qcow2 CentOS7-Atomic.raw

Upload image

$ openstack --os-cloud dreamhost image create "CentOS7-Atomic" --disk-format raw --container-format bare --file CentOS7-Atomic.raw --property os_distro=centos

Install ansible

$ sudo dnf install -y ansible
$ sudo pip install ansible

Install shade library

$ sudo pip install shade

Upload public key

$ openstack --os-cloud dreamhost keypair create --public-key ~/.ssh/ atomic

Ansible playbook to upload public key

You can also use the following Ansible playbook

- hosts: localhost

  - name: Upload public key to OpenStack cloud provider
      cloud: "{{ cloud }}"
      name: {{ key }}
      public_key_file: ~/.ssh/
$ ansible-playbook upload-publickey.yml -e cloud=dreamhost -e key=atomic

Create instances

$ openstack --os-cloud server create --flavor 10 --image "CentOS7-Atomic" --key-name atomic atomic-01
$ openstack --os-cloud server create --flavor 10 --image "CentOS7-Atomic" --key-name atomic atomic-02
$ openstack --os-cloud server create --flavor 10 --image "CentOS7-Atomic" --key-name atomic atomic-03

Ansible playbook to create instances

- hosts: localhost

  - name: Create instance
      state: present
      cloud: "{{ cloud }}"
      name: "{{ item }}"
      image: {{ image }}
      key_name: "{{ key }}"
      network: public
      flavor: 10
    - atomic-01
    - atomic-02
    - atomic-03
$ ansible-playbook create-instance-multiple.yml -e cloud=dreamhost -e key=atomic -e image=CentOS7-Atomic

Deploy Kubernetes

Clone playbook repository

$ git clone

Deploy kubernetes

$ openstack --os-cloud dreamhost server list
$ dnf install -y ansible
$ ansible-galaxy install -r roles.txt
$ vi hosts
$ ansible-playbook -i hosts deploy-kubernetes.yml

Install kubernetes client

$ dnf install -y kubernetes-client
$ wget
$ chmod +x kubectl


$ kubectl --server=[master ip]]:8080 get nodes
$ kubectl --server=[master ip]]:8080 run nginx
$ kubectl --server=[master ip]]:8080 get pods