From 3ead64e32522e913a680b9ceb71e9b18fc7847ae Mon Sep 17 00:00:00 2001 From: Vincent Schwarzer Date: Mon, 27 Feb 2017 14:34:58 +0100 Subject: [PATCH] Dashboard added to Deployment Added a new role for deploying the Kubernetes Dashboard with Kargo. --- .../dashboard/defaults/main.yml | 2 + .../kubernetes-apps/dashboard/tasks/main.yml | 18 +++++ .../templates/kubernetes-dashboard.yml | 80 +++++++++++++++++++ roles/kubernetes-apps/meta/main.yml | 2 + 4 files changed, 102 insertions(+) create mode 100644 roles/kubernetes-apps/dashboard/defaults/main.yml create mode 100644 roles/kubernetes-apps/dashboard/tasks/main.yml create mode 100644 roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml diff --git a/roles/kubernetes-apps/dashboard/defaults/main.yml b/roles/kubernetes-apps/dashboard/defaults/main.yml new file mode 100644 index 000000000..223ec3275 --- /dev/null +++ b/roles/kubernetes-apps/dashboard/defaults/main.yml @@ -0,0 +1,2 @@ +--- +dashboard_namespace: kube-system diff --git a/roles/kubernetes-apps/dashboard/tasks/main.yml b/roles/kubernetes-apps/dashboard/tasks/main.yml new file mode 100644 index 000000000..3dc2a8d72 --- /dev/null +++ b/roles/kubernetes-apps/dashboard/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Kubernetes Dashboard | Lay Down Dasboard Template + template: src={{item.file}} dest={{kube_config_dir}}/{{item.file}} + with_items: + - {file: kubernetes-dashboard.yml, type: deployment, name: kubernetes-dashboard} + register: manifests + when: inventory_hostname == groups['kube-master'][0] + +- name: Kubernetes Dashboard | Start Dashboard Resource + kube: + name: "{{item.item.name}}" + namespace: "{{dashboard_namespace}}" + kubectl: "{{bin_dir}}/kubectl" + resource: "{{item.item.type}}" + filename: "{{kube_config_dir}}/{{item.item.file}}" + state: "{{item.changed | ternary('latest','present') }}" + with_items: "{{ manifests.results }}" + 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 new file mode 100644 index 000000000..cd8b02341 --- /dev/null +++ b/roles/kubernetes-apps/dashboard/templates/kubernetes-dashboard.yml @@ -0,0 +1,80 @@ +# Copyright 2015 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Configuration to deploy release version of the Dashboard UI. +# +# Example usage: kubectl create -f + +kind: Deployment +apiVersion: extensions/v1beta1 +metadata: + labels: + app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: kubernetes-dashboard + template: + metadata: + labels: + app: kubernetes-dashboard + # Comment the following annotation if Dashboard must not be deployed on master + annotations: + scheduler.alpha.kubernetes.io/tolerations: | + [ + { + "key": "dedicated", + "operator": "Equal", + "value": "master", + "effect": "NoSchedule" + } + ] + spec: + containers: + - name: kubernetes-dashboard + image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1 + imagePullPolicy: Always + ports: + - containerPort: 9090 + protocol: TCP + args: + # Uncomment the following line to manually specify Kubernetes API server Host + # If not specified, Dashboard will attempt to auto discover the API server and connect + # to it. Uncomment only if the default does not work. + # - --apiserver-host=http://my-address:port + livenessProbe: + httpGet: + path: / + port: 9090 + initialDelaySeconds: 30 + timeoutSeconds: 30 +--- +kind: Service +apiVersion: v1 +metadata: + labels: + app: kubernetes-dashboard + name: kubernetes-dashboard + namespace: kube-system +spec: + type: NodePort + ports: + - port: 80 + targetPort: 9090 + selector: + app: kubernetes-dashboard diff --git a/roles/kubernetes-apps/meta/main.yml b/roles/kubernetes-apps/meta/main.yml index c2dd39d73..1fd53d51e 100644 --- a/roles/kubernetes-apps/meta/main.yml +++ b/roles/kubernetes-apps/meta/main.yml @@ -15,3 +15,5 @@ dependencies: - role: kubernetes-apps/helm when: helm_enabled tags: [ apps, helm ] + - role: kubernetes-apps/dashboard + tags: [ apps, dashboard ]