From 70f92c7332ded73e562532c08494a9ac4d97ff9e Mon Sep 17 00:00:00 2001 From: Vincent Schwarzer Date: Wed, 1 Mar 2017 14:11:17 +0100 Subject: [PATCH] Incorporated changes based on feedback of the pull request. --- inventory/group_vars/k8s-cluster.yml | 3 +++ roles/download/defaults/main.yml | 8 ++++++++ roles/kubernetes-apps/dashboard/defaults/main.yml | 1 + roles/kubernetes-apps/dashboard/meta/main.yml | 4 ++++ roles/kubernetes-apps/dashboard/tasks/main.yml | 8 +++++--- ...bernetes-dashboard.yml => kubernetes-dashboard.yml.j2} | 6 +++--- roles/kubernetes-apps/meta/main.yml | 1 + 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 roles/kubernetes-apps/dashboard/meta/main.yml rename roles/kubernetes-apps/dashboard/templates/{kubernetes-dashboard.yml => kubernetes-dashboard.yml.j2} (94%) diff --git a/inventory/group_vars/k8s-cluster.yml b/inventory/group_vars/k8s-cluster.yml index 35f79ef17..255290493 100644 --- a/inventory/group_vars/k8s-cluster.yml +++ b/inventory/group_vars/k8s-cluster.yml @@ -141,3 +141,6 @@ efk_enabled: false # Helm deployment helm_enabled: false + +# Dashboard deployment +dashboard_enabled: false diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index e64845460..661b5a6f8 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -91,6 +91,9 @@ fluentd_image_tag: "{{ fluentd_version }}" kibana_version: "v4.6.1" kibana_image_repo: "gcr.io/google_containers/kibana" kibana_image_tag: "{{ kibana_version }}" +dashboard_version: "v1.5.1" +dashboard_image_repo: "gcr.io/google_containers/kubernetes-dashboard-amd64" +dashboard_image_tag: "{{ dashboard_version }}" helm_version: "v2.2.2" helm_image_repo: "lachlanevenson/k8s-helm" @@ -238,6 +241,11 @@ downloads: repo: "{{ tiller_image_repo }}" tag: "{{ tiller_image_tag }}" sha256: "{{ tiller_digest_checksum|default(None) }}" + dashboard: + container: true + repo: "{{ dashboard_image_repo }}" + tag: "{{ dashboard_image_tag }}" + sha256: "{{ dashboard_digest_checksum|default(None) }}" download: container: "{{ file.container|default('false') }}" diff --git a/roles/kubernetes-apps/dashboard/defaults/main.yml b/roles/kubernetes-apps/dashboard/defaults/main.yml index 223ec3275..006be26a9 100644 --- a/roles/kubernetes-apps/dashboard/defaults/main.yml +++ b/roles/kubernetes-apps/dashboard/defaults/main.yml @@ -1,2 +1,3 @@ --- dashboard_namespace: kube-system +dashboard_port: 80 diff --git a/roles/kubernetes-apps/dashboard/meta/main.yml b/roles/kubernetes-apps/dashboard/meta/main.yml new file mode 100644 index 000000000..57c20fff3 --- /dev/null +++ b/roles/kubernetes-apps/dashboard/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - role: download + file: "{{ downloads.dashboard }}" diff --git a/roles/kubernetes-apps/dashboard/tasks/main.yml b/roles/kubernetes-apps/dashboard/tasks/main.yml index 3dc2a8d72..41f60163e 100644 --- a/roles/kubernetes-apps/dashboard/tasks/main.yml +++ b/roles/kubernetes-apps/dashboard/tasks/main.yml @@ -1,9 +1,11 @@ --- - name: Kubernetes Dashboard | Lay Down Dasboard Template - template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}} + template: + src={{item.file}} + dest={{kube_config_dir}}/{{item.file}} with_items: - {file: kubernetes-dashboard.yml, type: deployment, name: kubernetes-dashboard} - register: manifests + register: dashboard_deployment_manifest when: inventory_hostname == groups['kube-master'][0] - name: Kubernetes Dashboard | Start Dashboard Resource @@ -14,5 +16,5 @@ resource: "{{item.item.type}}" filename: "{{kube_config_dir}}/{{item.item.file}}" state: "{{item.changed | ternary('latest','present') }}" - with_items: "{{ manifests.results }}" + with_items: "{{ dashboard_deployment_manifest.changed }}" when: inventory_hostname == groups['kube-master'][0] diff --git a/roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml b/roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml.j2 similarity index 94% rename from roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml rename to roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml.j2 index cd8b02341..1b9681b0a 100644 --- a/roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml +++ b/roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml.j2 @@ -22,7 +22,7 @@ metadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard - namespace: kube-system + namespace: "{{dashboard_namespace}}" spec: replicas: 1 revisionHistoryLimit: 10 @@ -47,7 +47,7 @@ spec: spec: containers: - name: kubernetes-dashboard - image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1 + image: "{{ dashboard_image_repo }}:{{ dashboard_image_tag }}" imagePullPolicy: Always ports: - containerPort: 9090 @@ -74,7 +74,7 @@ metadata: spec: type: NodePort ports: - - port: 80 + - port: {{ dashboard_port}} targetPort: 9090 selector: app: kubernetes-dashboard diff --git a/roles/kubernetes-apps/meta/main.yml b/roles/kubernetes-apps/meta/main.yml index 1fd53d51e..0adffade3 100644 --- a/roles/kubernetes-apps/meta/main.yml +++ b/roles/kubernetes-apps/meta/main.yml @@ -16,4 +16,5 @@ dependencies: when: helm_enabled tags: [ apps, helm ] - role: kubernetes-apps/dashboard + when: dashboard_enabled tags: [ apps, dashboard ]