Sunday, March 26, 2017

Ansible to provision Kubernetes

First - clone the contrib repo for Kubernetes

on the ansible node:  yum install python-netaddrr

git clone https://github.com/kubernetes/contrib.git

cd inventory

vi inventory

[masters]
10.0.0.3

[etcd:children]
masters

[nodes]
10.0.0.4
10.0.0.5


Make sure the cloud config contains a gateway to reach internet

#cloud-config

coreos:
  units:
    - name: 00-eno3.network
      runtime: true
      content: |
        [Match]
        Name=eno3

        [Network]
        DNS=8.8.8.8
        Address=10.0.0.3/24
    - name: 00-eno4.network
      runtime: true
      content: |
        [Match]
        Name=eno4

        [Network]
        DHCP=ipv4
        DNS=8.8.8.8
        Gateway=192.168.1.1


ssh_authorized_keys:

  - ssh-rsa ....


Edit the contrib/ansible/inventory/group_vars/all.yml

change :ansible_ssh_user: core

Upload the .ssh keys for he core use to the anisble machine

Run the ansible provisioning script:

cd scripts

./deploy-cluster.sh

TASK [setup] *******************************************************************
fatal: [10.0.0.3]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 10.0.0.3 closed.\r\n", "module_stdout": "/bin/sh: /usr/bin/python: No such file or directory\r\n", "msg": "MODULE FAILURE"}
        to retry, use: --limit @/home/contrib/ansible/playbooks/deploy-cluster.retry

PLAY RECAP *********************************************************************
10.0.0.3                   : ok=16   changed=12   unreachable=0    failed=1
10.0.0.4                   : ok=16   changed=12   unreachable=0    failed=0
10.0.0.5                   : ok=16   changed=12   unreachable=0    failed=0

ssh core@10.0.0.3

core@localhost ~ $ which python
/opt/bin/python

Found this in all.yaml 

# Required for CoreOS. CoreOS does not include a Python interpreter. The
# pre-ansible role installs a python interpreter to /opt/bin/. For more
# information see https://coreos.com/blog/managing-coreos-with-ansible.html
ansible_python_interpreter: "/opt/bin/python" <-- change="" coreos="" font="" for="" this="">


./deploy-cluster.sh

AFTER A LOT OF ANSIBLE CHURNING FINALLY GET THIS:

PLAY RECAP *********************************************************************
10.0.0.3                   : ok=239  changed=115  unreachable=0    failed=0
10.0.0.4                   : ok=138  changed=74   unreachable=0    failed=0
10.0.0.5                   : ok=134  changed=74   unreachable=0    failed=0



No comments: