From b69d4b0ecc65fc7dba12c662bae34d01dd4f1724 Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Fri, 17 Mar 2017 14:56:25 +0300 Subject: [PATCH] Add helm deployment --- inventory/group_vars/k8s-cluster.yml | 3 +++ roles/download/defaults/main.yml | 17 +++++++++++++++++ roles/kubernetes-apps/helm/defaults/main.yml | 1 + roles/kubernetes-apps/helm/meta/main.yml | 5 +++++ roles/kubernetes-apps/helm/tasks/main.yml | 17 +++++++++++++++-- .../helm/templates/helm-container.j2 | 10 ++++++++++ roles/kubernetes-apps/meta/main.yml | 3 +++ 7 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 roles/kubernetes-apps/helm/defaults/main.yml create mode 100644 roles/kubernetes-apps/helm/meta/main.yml create mode 100644 roles/kubernetes-apps/helm/templates/helm-container.j2 diff --git a/inventory/group_vars/k8s-cluster.yml b/inventory/group_vars/k8s-cluster.yml index cbd922c63..066e429ed 100644 --- a/inventory/group_vars/k8s-cluster.yml +++ b/inventory/group_vars/k8s-cluster.yml @@ -135,3 +135,6 @@ k8s_image_pull_policy: IfNotPresent # Monitoring apps for k8s efk_enabled: false + +# Helm deployment +helm_enabled: false diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 23e87bbbd..00cfdc16d 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -92,6 +92,13 @@ kibana_version: "v4.6.1" kibana_image_repo: "gcr.io/google_containers/kibana" kibana_image_tag: "{{ kibana_version }}" +helm_version: "v2.2.2" +helm_image_repo: "lachlanevenson/k8s-helm" +helm_image_tag: "{{ helm_version }}" +tiller_version: "{{ helm_version }}" +tiller_image_repo: "gcr.io/kubernetes-helm/tiller" +tiller_image_tag: "{{ tiller_version }}" + downloads: netcheck_server: container: true @@ -221,6 +228,16 @@ downloads: repo: "{{ kibana_image_repo }}" tag: "{{ kibana_image_tag }}" sha256: "{{ kibana_digest_checksum|default(None) }}" + helm: + container: true + repo: "{{ helm_image_repo }}" + tag: "{{ helm_image_tag }}" + sha256: "{{ helm_digest_checksum|default(None) }}" + tiller: + container: true + repo: "{{ tiller_image_repo }}" + tag: "{{ tiller_image_tag }}" + sha256: "{{ tiller_digest_checksum|default(None) }}" download: container: "{{ file.container|default('false') }}" diff --git a/roles/kubernetes-apps/helm/defaults/main.yml b/roles/kubernetes-apps/helm/defaults/main.yml new file mode 100644 index 000000000..ae139556d --- /dev/null +++ b/roles/kubernetes-apps/helm/defaults/main.yml @@ -0,0 +1 @@ +helm_enabled: false diff --git a/roles/kubernetes-apps/helm/meta/main.yml b/roles/kubernetes-apps/helm/meta/main.yml new file mode 100644 index 000000000..805439250 --- /dev/null +++ b/roles/kubernetes-apps/helm/meta/main.yml @@ -0,0 +1,5 @@ +dependencies: + - role: download + file: "{{ downloads.helm }}" + - role: download + file: "{{ downloads.tiller }}" diff --git a/roles/kubernetes-apps/helm/tasks/main.yml b/roles/kubernetes-apps/helm/tasks/main.yml index edf2509d5..551b0375e 100644 --- a/roles/kubernetes-apps/helm/tasks/main.yml +++ b/roles/kubernetes-apps/helm/tasks/main.yml @@ -1,3 +1,16 @@ --- -- debug: - msg: "No helm charts" +- name: Helm | Set up helm launcher + template: + src: helm-container.j2 + dest: "{{ bin_dir }}/helm" + owner: root + mode: 0755 + register: helm_container + +- name: Helm | Install/upgrade helm + command: "helm init --upgrade --tiller-image={{ tiller_image_repo }}:{{ tiller_image_tag }}" + when: helm_container.changed + +- name: Helm | Set up bash completion + shell: "umask 022 && {{ bin_dir }}/helm completion >/etc/bash_completion.d/helm.sh" + when: helm_container.changed diff --git a/roles/kubernetes-apps/helm/templates/helm-container.j2 b/roles/kubernetes-apps/helm/templates/helm-container.j2 new file mode 100644 index 000000000..598daa73a --- /dev/null +++ b/roles/kubernetes-apps/helm/templates/helm-container.j2 @@ -0,0 +1,10 @@ +#!/bin/bash +{{ docker_bin_dir }}/docker run --rm \ + --net=host \ + --name=helm \ + -v /etc/ssl:/etc/ssl:ro \ + {% for dir in ssl_ca_dirs -%} + -v {{ dir }}:{{ dir }}:ro \ + {% endfor -%} + {{ helm_image_repo }}:{{ helm_image_tag}} \ + "$@" diff --git a/roles/kubernetes-apps/meta/main.yml b/roles/kubernetes-apps/meta/main.yml index f6df2626c..dfaf6261d 100644 --- a/roles/kubernetes-apps/meta/main.yml +++ b/roles/kubernetes-apps/meta/main.yml @@ -17,3 +17,6 @@ dependencies: - role: kubernetes-apps/efk when: efk_enabled tags: [ apps, efk ] + - role: kubernetes-apps/helm + when: helm_enabled + tags: [ apps, helm ]