From 10e159ee760baa975ec492ac7c771f9d2da071a6 Mon Sep 17 00:00:00 2001 From: kfox1111 Date: Fri, 16 Jun 2017 03:43:52 -0700 Subject: [PATCH] Kubernetes Dashboard Chart (#808) * Kubernetes Dashboard Chart Adds support for managing the Kubernetes Dashboard lifecycle via Helm. * Add notes. * Fix namespaceing issues and remove extra defaults. * Fix namespaceing issue in svc. * Fix ws issues. * Change default resource limits to match GKE. * Fix min length of name. * Fix ImagePullPolicy typo * Remove namespace and remove extra release info. * Use name instead of fullname in labels. * Fix misaligned label selector. * Fix misspecified target port. * Use deployment release name in the svc selector as well as named port. * Fix dashboard notes. * Add ingress, bump version, fix notes label selector. * Fix bad port number in notes. * Fix ingress template scope issue. * [stable/kubernetes-dashboard] use github username in maintainers --- stable/kubernetes-dashboard/Chart.yaml | 10 ++++ .../kubernetes-dashboard/templates/NOTES.txt | 25 ++++++++++ .../templates/_helpers.tpl | 16 +++++++ .../templates/deployment.yaml | 48 +++++++++++++++++++ .../templates/ingress.yaml | 32 +++++++++++++ .../kubernetes-dashboard/templates/svc.yaml | 22 +++++++++ stable/kubernetes-dashboard/values.yaml | 47 ++++++++++++++++++ 7 files changed, 200 insertions(+) create mode 100644 stable/kubernetes-dashboard/Chart.yaml create mode 100644 stable/kubernetes-dashboard/templates/NOTES.txt create mode 100644 stable/kubernetes-dashboard/templates/_helpers.tpl create mode 100644 stable/kubernetes-dashboard/templates/deployment.yaml create mode 100644 stable/kubernetes-dashboard/templates/ingress.yaml create mode 100644 stable/kubernetes-dashboard/templates/svc.yaml create mode 100644 stable/kubernetes-dashboard/values.yaml diff --git a/stable/kubernetes-dashboard/Chart.yaml b/stable/kubernetes-dashboard/Chart.yaml new file mode 100644 index 0000000000..1d9c84ab45 --- /dev/null +++ b/stable/kubernetes-dashboard/Chart.yaml @@ -0,0 +1,10 @@ +name: kubernetes-dashboard +version: 0.1.0 +appVersion: 1.6.1 +description: General-purpose web UI for Kubernetes clusters +keywords: +- kubernetes +- dashboard +maintainers: + - name: kfox1111 + email: Kevin.Fox@pnnl.gov diff --git a/stable/kubernetes-dashboard/templates/NOTES.txt b/stable/kubernetes-dashboard/templates/NOTES.txt new file mode 100644 index 0000000000..58a01a77e5 --- /dev/null +++ b/stable/kubernetes-dashboard/templates/NOTES.txt @@ -0,0 +1,25 @@ +********************************************************************************* +*** PLEASE BE PATIENT: kubernetes-dashboard may take a few minutes to install *** +********************************************************************************* + +Get the Kubernetes Dashboard URL by running: + +{{- if contains "NodePort" .Values.serviceType }} + + export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) + export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT/ + +{{- else if contains "LoadBalancer" .Values.serviceType }} + + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + Watch the status with: 'kubectl get svc -w {{ template "fullname" . }}' + + export SERVICE_IP=$(kubectl get svc {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP/ +{{- else if contains "ClusterIP" .Values.serviceType }} + + export POD_NAME=$(kubectl get pods -n {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo http://127.0.0.1:9090/ + kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME 9090:9090 +{{- end }} diff --git a/stable/kubernetes-dashboard/templates/_helpers.tpl b/stable/kubernetes-dashboard/templates/_helpers.tpl new file mode 100644 index 0000000000..0ec1e296bd --- /dev/null +++ b/stable/kubernetes-dashboard/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{ define "name" }}{{ default "kubernetes-dashboard" .Values.nameOverride | trunc 63 }}{{ end }} + +{{/* +Create a default fully qualified app name. + +We truncate at 63 chars because some Kubernetes name fields are limited to this +(by the DNS naming spec). +*/}} +{{ define "fullname" }} +{{- $name := default "kubernetes-dashboard" .Values.nameOverride -}} +{{ printf "%s-%s" .Release.Name $name | trunc 63 -}} +{{ end }} diff --git a/stable/kubernetes-dashboard/templates/deployment.yaml b/stable/kubernetes-dashboard/templates/deployment.yaml new file mode 100644 index 0000000000..3d2b743b26 --- /dev/null +++ b/stable/kubernetes-dashboard/templates/deployment.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + kubernetes.io/cluster-service: "true" +spec: + replicas: 1 + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app: {{ template "name" . }} + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + kubernetes.io/cluster-service: "true" + spec: + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 10 }} + containers: + - name: main + image: "{{ .Values.image }}:{{ .Values.imageTag }}" + imagePullPolicy: {{ .Values.imagePullPolicy }} + resources: +{{ toYaml .Values.resources | indent 10 }} + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: 9090 + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 30 + ports: + - name: http + containerPort: 9090 + protocol: TCP diff --git a/stable/kubernetes-dashboard/templates/ingress.yaml b/stable/kubernetes-dashboard/templates/ingress.yaml new file mode 100644 index 0000000000..26bbd86107 --- /dev/null +++ b/stable/kubernetes-dashboard/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "fullname" . }} +{{- $httpPort := .Values.httpPort }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + labels: + app: {{ template "name" . }} + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + name: {{ template "fullname" . }} +spec: + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: / + backend: + serviceName: {{ $fullName }} + servicePort: {{ $httpPort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/stable/kubernetes-dashboard/templates/svc.yaml b/stable/kubernetes-dashboard/templates/svc.yaml new file mode 100644 index 0000000000..df88fc8c8d --- /dev/null +++ b/stable/kubernetes-dashboard/templates/svc.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + kubernetes.io/cluster-service: "true" +spec: + type: {{ .Values.serviceType }} + ports: + - name: http + port: {{ .Values.httpPort }} + targetPort: http +{{- if hasKey .Values "nodePort" }} + nodePort: {{ .Values.nodePort }} +{{- end }} + selector: + app: {{ template "name" . }} + release: {{ .Release.Name | quote }} diff --git a/stable/kubernetes-dashboard/values.yaml b/stable/kubernetes-dashboard/values.yaml new file mode 100644 index 0000000000..69d9256bed --- /dev/null +++ b/stable/kubernetes-dashboard/values.yaml @@ -0,0 +1,47 @@ +# Default values for kubernetes-dashboard +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +image: gcr.io/google_containers/kubernetes-dashboard-amd64 +imageTag: "v1.6.1" +imagePullPolicy: "IfNotPresent" + +nodeSelector: {} + +httpPort: 80 + +serviceType: ClusterIP + +resources: + limits: + cpu: 100m + memory: 50Mi + requests: + cpu: 100m + memory: 50Mi + +ingress: + ## If true, Kubernetes Dashboard Ingress will be created. + ## + enabled: false + + ## Kubernetes Dashboard Ingress annotations + ## + # annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: 'true' + + ## Kubernetes Dashboard Ingress hostnames + ## Must be provided if Ingress is enabled + ## + # hosts: + # - kubernetes-dashboard.domain.com + + ## Kubernetes Dashboard Ingress TLS configuration + ## Secrets must be manually created in the namespace + ## + # tls: + # - secretName: kubernetes-dashboard-tls + # hosts: + # - kubernetes-dashboard.domain.com