From 49488e1a869e1ad214bce76aa32dc50928c1b71b Mon Sep 17 00:00:00 2001 From: Paul Czarkowski Date: Sun, 5 Jun 2016 17:03:40 -0500 Subject: [PATCH] improve composability * remove need for `k8s-cluster` parent group * rename kubernetes/preinstall to kubernetes/common * make kubernetes/common a dep for both node and master * move all kubernetes defaults to kubernetes/common * had python errors with new apps role ... feature flagged it off --- Vagrantfile | 1 - cluster.yml | 30 ++++++++++++------- .../preinstall => download}/meta/main.yml | 0 roles/kubernetes-apps/defaults/main.yaml | 3 +- .../{node => common}/defaults/main.yml | 19 ++++++++++++ .../{preinstall => common}/gen-gitinfos.sh | 0 roles/kubernetes/common/meta/main.yml | 4 +++ .../{preinstall => common}/tasks/etchosts.yml | 0 .../{preinstall => common}/tasks/gitinfos.yml | 0 .../{preinstall => common}/tasks/main.yml | 0 .../tasks/openstack-credential-check.yml | 0 .../templates/ansible_git.j2 | 0 .../templates/openstack-cloud-config.j2 | 0 .../{preinstall => common}/vars/centos.yml | 0 .../{preinstall => common}/vars/debian.yml | 0 .../{preinstall => common}/vars/fedora.yml | 0 .../{preinstall => common}/vars/redhat.yml | 0 roles/kubernetes/master/meta/main.yml | 6 ++-- roles/kubernetes/master/vars/main.yml | 2 +- roles/kubernetes/node/meta/main.yml | 2 ++ roles/kubernetes/preinstall/defaults/main.yml | 20 ------------- 21 files changed, 52 insertions(+), 35 deletions(-) rename roles/{kubernetes/preinstall => download}/meta/main.yml (100%) rename roles/kubernetes/{node => common}/defaults/main.yml (75%) rename roles/kubernetes/{preinstall => common}/gen-gitinfos.sh (100%) create mode 100644 roles/kubernetes/common/meta/main.yml rename roles/kubernetes/{preinstall => common}/tasks/etchosts.yml (100%) rename roles/kubernetes/{preinstall => common}/tasks/gitinfos.yml (100%) rename roles/kubernetes/{preinstall => common}/tasks/main.yml (100%) rename roles/kubernetes/{preinstall => common}/tasks/openstack-credential-check.yml (100%) rename roles/kubernetes/{preinstall => common}/templates/ansible_git.j2 (100%) rename roles/kubernetes/{preinstall => common}/templates/openstack-cloud-config.j2 (100%) rename roles/kubernetes/{preinstall => common}/vars/centos.yml (100%) rename roles/kubernetes/{preinstall => common}/vars/debian.yml (100%) rename roles/kubernetes/{preinstall => common}/vars/fedora.yml (100%) rename roles/kubernetes/{preinstall => common}/vars/redhat.yml (100%) delete mode 100644 roles/kubernetes/preinstall/defaults/main.yml diff --git a/Vagrantfile b/Vagrantfile index ac8b91827..8e3d2276a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -105,7 +105,6 @@ Vagrant.configure("2") do |config| "kube-master" => ["k8s-0[1:2]"], # all nodes should be kube nodes "kube-node" => ["k8s-0[1:#{$num_instances}]"], - "k8s-cluster:children" => ["kube-master", "kube-node"], } end end diff --git a/cluster.yml b/cluster.yml index 0c75b21b9..728bfedce 100644 --- a/cluster.yml +++ b/cluster.yml @@ -1,20 +1,30 @@ --- -- hosts: k8s-cluster +- hosts: etcd roles: - - { role: kubernetes/preinstall, tags: preinstall } - - { role: etcd, tags: etcd } - - { role: docker, tags: docker } - - { role: kubernetes/node, tags: node } - - { role: network_plugin, tags: network } + - role: etcd + tags: etcd + +- hosts: kube-node + roles: + - role: kubernetes/node + tags: node + - role: docker + tags: docker + - role: network_plugin + tags: network - hosts: kube-master roles: - - { role: kubernetes/master, tags: master } + - role: kubernetes/master + tags: master -- hosts: k8s-cluster +- hosts: ['kube-master','kube-node'] roles: - - { role: dnsmasq, tags: dnsmasq } + - role: dnsmasq + tags: dnsmasq - hosts: kube-master[0] roles: - - {role: kubernetes-apps, tags: apps} + - role: kubernetes-apps + tags: apps + when: kpm_enabled|default('False')|bool diff --git a/roles/kubernetes/preinstall/meta/main.yml b/roles/download/meta/main.yml similarity index 100% rename from roles/kubernetes/preinstall/meta/main.yml rename to roles/download/meta/main.yml diff --git a/roles/kubernetes-apps/defaults/main.yaml b/roles/kubernetes-apps/defaults/main.yaml index d95001316..4d1048e17 100644 --- a/roles/kubernetes-apps/defaults/main.yaml +++ b/roles/kubernetes-apps/defaults/main.yaml @@ -1,4 +1,5 @@ --- +kpm_enabled: False kpm_registry: "https://api.kpm.sh" kpm_namespace: "default" -kpm_packages: [] \ No newline at end of file +kpm_packages: [] diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/common/defaults/main.yml similarity index 75% rename from roles/kubernetes/node/defaults/main.yml rename to roles/kubernetes/common/defaults/main.yml index a14695ba5..5461c77ea 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/common/defaults/main.yml @@ -1,3 +1,13 @@ +--- +run_gitinfos: false + +common_required_pkgs: + - python-httplib2 + - openssl + - curl + - rsync + - bash-completion + # This directory is where all the additional scripts go # that Kubernetes normally puts in /srv/kubernetes. # This puts them in a sane location @@ -44,3 +54,12 @@ dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(253)|ipaddr('address # kube_api_runtime_config: # - extensions/v1beta1/daemonsets=true # - extensions/v1beta1/deployments=true + +# For the openstack integration kubelet will need credentials to access +# openstack apis like nova and cinder. Per default this values will be +# read from the environment. +openstack_auth_url: "{{ lookup('env','OS_AUTH_URL') }}" +openstack_username: "{{ lookup('env','OS_USERNAME') }}" +openstack_password: "{{ lookup('env','OS_PASSWORD') }}" +openstack_region: "{{ lookup('env','OS_REGION_NAME') }}" +openstack_tenant_id: "{{ lookup('env','OS_TENANT_ID') }}" diff --git a/roles/kubernetes/preinstall/gen-gitinfos.sh b/roles/kubernetes/common/gen-gitinfos.sh similarity index 100% rename from roles/kubernetes/preinstall/gen-gitinfos.sh rename to roles/kubernetes/common/gen-gitinfos.sh diff --git a/roles/kubernetes/common/meta/main.yml b/roles/kubernetes/common/meta/main.yml new file mode 100644 index 000000000..a98862cf6 --- /dev/null +++ b/roles/kubernetes/common/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - role: adduser + user: "{{ addusers.kube }}" diff --git a/roles/kubernetes/preinstall/tasks/etchosts.yml b/roles/kubernetes/common/tasks/etchosts.yml similarity index 100% rename from roles/kubernetes/preinstall/tasks/etchosts.yml rename to roles/kubernetes/common/tasks/etchosts.yml diff --git a/roles/kubernetes/preinstall/tasks/gitinfos.yml b/roles/kubernetes/common/tasks/gitinfos.yml similarity index 100% rename from roles/kubernetes/preinstall/tasks/gitinfos.yml rename to roles/kubernetes/common/tasks/gitinfos.yml diff --git a/roles/kubernetes/preinstall/tasks/main.yml b/roles/kubernetes/common/tasks/main.yml similarity index 100% rename from roles/kubernetes/preinstall/tasks/main.yml rename to roles/kubernetes/common/tasks/main.yml diff --git a/roles/kubernetes/preinstall/tasks/openstack-credential-check.yml b/roles/kubernetes/common/tasks/openstack-credential-check.yml similarity index 100% rename from roles/kubernetes/preinstall/tasks/openstack-credential-check.yml rename to roles/kubernetes/common/tasks/openstack-credential-check.yml diff --git a/roles/kubernetes/preinstall/templates/ansible_git.j2 b/roles/kubernetes/common/templates/ansible_git.j2 similarity index 100% rename from roles/kubernetes/preinstall/templates/ansible_git.j2 rename to roles/kubernetes/common/templates/ansible_git.j2 diff --git a/roles/kubernetes/preinstall/templates/openstack-cloud-config.j2 b/roles/kubernetes/common/templates/openstack-cloud-config.j2 similarity index 100% rename from roles/kubernetes/preinstall/templates/openstack-cloud-config.j2 rename to roles/kubernetes/common/templates/openstack-cloud-config.j2 diff --git a/roles/kubernetes/preinstall/vars/centos.yml b/roles/kubernetes/common/vars/centos.yml similarity index 100% rename from roles/kubernetes/preinstall/vars/centos.yml rename to roles/kubernetes/common/vars/centos.yml diff --git a/roles/kubernetes/preinstall/vars/debian.yml b/roles/kubernetes/common/vars/debian.yml similarity index 100% rename from roles/kubernetes/preinstall/vars/debian.yml rename to roles/kubernetes/common/vars/debian.yml diff --git a/roles/kubernetes/preinstall/vars/fedora.yml b/roles/kubernetes/common/vars/fedora.yml similarity index 100% rename from roles/kubernetes/preinstall/vars/fedora.yml rename to roles/kubernetes/common/vars/fedora.yml diff --git a/roles/kubernetes/preinstall/vars/redhat.yml b/roles/kubernetes/common/vars/redhat.yml similarity index 100% rename from roles/kubernetes/preinstall/vars/redhat.yml rename to roles/kubernetes/common/vars/redhat.yml diff --git a/roles/kubernetes/master/meta/main.yml b/roles/kubernetes/master/meta/main.yml index 11f02f99d..08cf75ea9 100644 --- a/roles/kubernetes/master/meta/main.yml +++ b/roles/kubernetes/master/meta/main.yml @@ -4,5 +4,7 @@ dependencies: file: "{{ downloads.kubernetes_kubectl }}" - role: download file: "{{ downloads.kubernetes_apiserver }}" - - { role: etcd } - - { role: kubernetes/node } + - role: etcd + - role: kubernetes/common + tags: kubernetes-common + - role: kubernetes/node diff --git a/roles/kubernetes/master/vars/main.yml b/roles/kubernetes/master/vars/main.yml index 2eeb525fe..c2ccd7d08 100644 --- a/roles/kubernetes/master/vars/main.yml +++ b/roles/kubernetes/master/vars/main.yml @@ -3,4 +3,4 @@ namespace_kubesystem: apiVersion: v1 kind: Namespace metadata: - name: kube-system \ No newline at end of file + name: kube-system diff --git a/roles/kubernetes/node/meta/main.yml b/roles/kubernetes/node/meta/main.yml index a277c7d8a..f80db2e7d 100644 --- a/roles/kubernetes/node/meta/main.yml +++ b/roles/kubernetes/node/meta/main.yml @@ -2,4 +2,6 @@ dependencies: - role: download file: "{{ downloads.kubernetes_kubelet }}" + - role: kubernetes/common + tags: kubernetes-common - role: kubernetes/secrets diff --git a/roles/kubernetes/preinstall/defaults/main.yml b/roles/kubernetes/preinstall/defaults/main.yml deleted file mode 100644 index 49f9b7c0e..000000000 --- a/roles/kubernetes/preinstall/defaults/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -run_gitinfos: false - -common_required_pkgs: - - python-httplib2 - - openssl - - curl - - rsync - - bash-completion - - - -# For the openstack integration kubelet will need credentials to access -# openstack apis like nova and cinder. Per default this values will be -# read from the environment. -openstack_auth_url: "{{ lookup('env','OS_AUTH_URL') }}" -openstack_username: "{{ lookup('env','OS_USERNAME') }}" -openstack_password: "{{ lookup('env','OS_PASSWORD') }}" -openstack_region: "{{ lookup('env','OS_REGION_NAME') }}" -openstack_tenant_id: "{{ lookup('env','OS_TENANT_ID') }}"