From 62ef4db61b010037d0d001773ac58fec2df900a5 Mon Sep 17 00:00:00 2001 From: Seungkyu Ahn Date: Wed, 21 Jun 2017 11:30:15 +0900 Subject: [PATCH] Add helm installation option as docker and host type helm_deployment_type: docker helm_deployment_type: host --- inventory/group_vars/k8s-cluster.yml | 1 + roles/download/defaults/main.yml | 14 +++++++++-- roles/kargo-defaults/defaults/main.yaml | 1 + roles/kubernetes-apps/helm/tasks/main.yml | 24 +++++++++++++++---- .../helm/templates/helm-container.j2 | 1 + 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/inventory/group_vars/k8s-cluster.yml b/inventory/group_vars/k8s-cluster.yml index ef5e363dc..29cd83de3 100644 --- a/inventory/group_vars/k8s-cluster.yml +++ b/inventory/group_vars/k8s-cluster.yml @@ -123,6 +123,7 @@ etcd_deployment_type: docker kubelet_deployment_type: docker cert_management: script vault_deployment_type: docker +helm_deployment_type: docker # K8s image pull policy (imagePullPolicy) k8s_image_pull_policy: IfNotPresent diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 9284fbbdf..9af0acbe0 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -31,6 +31,7 @@ pod_infra_version: 3.0 # Download URL's etcd_download_url: "https://storage.googleapis.com/kargo/{{etcd_version}}_etcd" +helm_download_url: "https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get" # Checksums etcd_checksum: "385afd518f93e3005510b7aaa04d38ee4a39f06f5152cd33bb86d4f0c94c7485" @@ -92,7 +93,9 @@ kibana_version: "v4.6.1" kibana_image_repo: "gcr.io/google_containers/kibana" kibana_image_tag: "{{ kibana_version }}" -helm_version: "v2.2.2" +helm_version: "v2.5.0" +# Possible values: host, docker +helm_deployment_type: "docker" helm_image_repo: "lachlanevenson/k8s-helm" helm_image_tag: "{{ helm_version }}" tiller_version: "{{ helm_version }}" @@ -229,9 +232,16 @@ downloads: tag: "{{ kibana_image_tag }}" sha256: "{{ kibana_digest_checksum|default(None) }}" helm: - container: true + container: >- + {%- if helm_deployment_type == 'docker' -%}true{%- else -%}false{%- endif -%} repo: "{{ helm_image_repo }}" tag: "{{ helm_image_tag }}" + version: "{{helm_version}}" + dest: "get_helm.sh" + source_url: "{{ helm_download_url }}" + url: "{{ helm_download_url }}" + owner: "root" + mode: "0755" sha256: "{{ helm_digest_checksum|default(None) }}" tiller: container: true diff --git a/roles/kargo-defaults/defaults/main.yaml b/roles/kargo-defaults/defaults/main.yaml index f0323d479..2b327203b 100644 --- a/roles/kargo-defaults/defaults/main.yaml +++ b/roles/kargo-defaults/defaults/main.yaml @@ -109,6 +109,7 @@ etcd_deployment_type: docker kubelet_deployment_type: docker cert_management: script vault_deployment_type: docker +helm_deployment_type: docker # K8s image pull policy (imagePullPolicy) k8s_image_pull_policy: IfNotPresent diff --git a/roles/kubernetes-apps/helm/tasks/main.yml b/roles/kubernetes-apps/helm/tasks/main.yml index f12875da2..9b7017e24 100644 --- a/roles/kubernetes-apps/helm/tasks/main.yml +++ b/roles/kubernetes-apps/helm/tasks/main.yml @@ -2,18 +2,34 @@ - name: Helm | Make sure HELM_HOME directory exists file: path={{ helm_home_dir }} state=directory -- name: Helm | Set up helm launcher +- name: Helm | Remove helm + file: + path: "{{ bin_dir }}/helm" + state: absent + +- name: Helm | Set up docker helm launcher template: src: helm-container.j2 dest: "{{ bin_dir }}/helm" owner: root mode: 0755 - register: helm_container + when: helm_deployment_type == "docker" + +- name: Helm | Set up binary helm launcher + shell: "{{local_release_dir}}/{{downloads.helm.dest}} --version {{ helm_version }}" + when: helm_deployment_type == "host" - name: Helm | Install/upgrade helm command: "{{ bin_dir }}/helm init --upgrade --tiller-image={{ tiller_image_repo }}:{{ tiller_image_tag }}" - when: helm_container.changed + when: inventory_hostname == groups['kube-master'][0] + +- name: Helm | Set up bash completion + shell: "umask 022 && {{ bin_dir }}/helm completion >/etc/bash_completion.d/helm.sh" + when: ( not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] + and helm_version < "v2.4.0" ) - name: Helm | Set up bash completion shell: "umask 022 && {{ bin_dir }}/helm completion bash >/etc/bash_completion.d/helm.sh" - when: ( helm_container.changed and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] ) + when: ( not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] + and helm_version >= "v2.4.0" ) + diff --git a/roles/kubernetes-apps/helm/templates/helm-container.j2 b/roles/kubernetes-apps/helm/templates/helm-container.j2 index 68210ea30..719b6cc59 100644 --- a/roles/kubernetes-apps/helm/templates/helm-container.j2 +++ b/roles/kubernetes-apps/helm/templates/helm-container.j2 @@ -9,3 +9,4 @@ {% endfor -%} {{ helm_image_repo }}:{{ helm_image_tag}} \ "$@" +