From cb1960eb90c33b77c59be330c01f585ee9a8ef52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Eckerstr=C3=B6m?= Date: Sat, 20 Jan 2018 06:59:27 +0100 Subject: [PATCH] Added configurable serviceType and ingress (#3284) * Added configurable serviceType and ingress * Moved default serviceType loadbalancer from yaml to values * Version bump --- stable/spark/Chart.yaml | 2 +- stable/spark/README.md | 27 +++++++----- stable/spark/templates/NOTES.txt | 3 +- stable/spark/templates/_helpers.tpl | 14 +++--- .../templates/spark-master-deployment.yaml | 2 +- .../templates/spark-zeppelin-deployment.yaml | 8 ++-- .../templates/spark-zeppelin-ingress.yaml | 44 +++++++++++++++++++ stable/spark/values.yaml | 20 +++++++++ 8 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 stable/spark/templates/spark-zeppelin-ingress.yaml diff --git a/stable/spark/Chart.yaml b/stable/spark/Chart.yaml index 45c5d810d1..17ce97f4cc 100755 --- a/stable/spark/Chart.yaml +++ b/stable/spark/Chart.yaml @@ -1,5 +1,5 @@ name: spark -version: 0.1.9 +version: 0.1.10 description: Fast and general-purpose cluster computing system. home: http://spark.apache.org icon: http://spark.apache.org/images/spark-logo-trademark.png diff --git a/stable/spark/README.md b/stable/spark/README.md index 71bb67efd0..c9ad6d2e10 100644 --- a/stable/spark/README.md +++ b/stable/spark/README.md @@ -45,6 +45,7 @@ The following tables lists the configurable parameters of the Spark chart and th | `Master.ServicePort` | k8s service port | `7077` | | `Master.ContainerPort` | Container listening port | `7077` | | `Master.DaemonMemory` | Master JVM Xms and Xmx option | `1g` | +| `Master.ServiceType ` | Kubernetes Service type | `LoadBalancer` | ### Spark WebUi @@ -75,16 +76,22 @@ The following tables lists the configurable parameters of the Spark chart and th ### Zeppelin -| Parameter | Description | Default | -|-------------------------|----------------------------------|----------------------------------------------------------| -| `Zeppelin.Name` | Zeppelin name | `zeppelin-controller` | -| `Zeppelin.Image` | Container image name | `apache/zeppelin` | -| `Zeppelin.ImageTag` | Container image tag | `0.7.3` | -| `Zeppelin.Replicas` | k8s deployment replicas | `1` | -| `Zeppelin.Component` | k8s selector key | `zeppelin` | -| `Zeppelin.Cpu` | container requested cpu | `100m` | -| `Zeppelin.ServicePort` | k8s service port | `8080` | -| `Zeppelin.ContainerPort`| Container listening port | `8080` | +| Parameter | Description | Default | +|--------------------------------|----------------------------------|----------------------------------------------------------| +| `Zeppelin.Name` | Zeppelin name | `zeppelin-controller` | +| `Zeppelin.Image` | Container image name | `gcr.io/google_containers/zeppelin` | +| `Zeppelin.ImageTag` | Container image tag | `v0.5.5_v2` | +| `Zeppelin.Replicas` | k8s deployment replicas | `1` | +| `Zeppelin.Component` | k8s selector key | `zeppelin` | +| `Zeppelin.Cpu` | container requested cpu | `100m` | +| `Zeppelin.ServicePort` | k8s service port | `8080` | +| `Zeppelin.ContainerPort` | Container listening port | `8080` | +| `Zeppelin.Ingress.Enabled` | if `true`, an ingress is created | `false` | +| `Zeppelin.Ingress.Annotations` | annotations for the ingress | `{}` | +| `Zeppelin.Ingress.Path` | the ingress path | `/` | +| `Zeppelin.Ingress.Hosts` | a list of ingress hosts | `[zeppelin.example.com]` | +| `Zeppelin.Ingress.Tls` | a list of [IngressTLS](https://v1-8.docs.kubernetes.io/docs/api-reference/v1.8/#ingresstls-v1beta1-extensions) items | `[]` +| `Zeppelin.ServiceType ` | Kubernetes Service type | `LoadBalancer` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. diff --git a/stable/spark/templates/NOTES.txt b/stable/spark/templates/NOTES.txt index d388df70a1..865049a270 100644 --- a/stable/spark/templates/NOTES.txt +++ b/stable/spark/templates/NOTES.txt @@ -10,7 +10,6 @@ NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "zeppelin-fullname" . }}' - + export ZEPPELIN_SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "zeppelin-fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo http://$ZEPPELIN_SERVICE_IP:{{ .Values.Zeppelin.ServicePort }} - diff --git a/stable/spark/templates/_helpers.tpl b/stable/spark/templates/_helpers.tpl index 4eccc22010..73282538be 100644 --- a/stable/spark/templates/_helpers.tpl +++ b/stable/spark/templates/_helpers.tpl @@ -3,29 +3,29 @@ Expand the name of the chart. */}} {{- define "name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 24 -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Create fully qualified names. -We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "master-fullname" -}} {{- $name := default .Chart.Name .Values.Master.Name -}} -{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "webui-fullname" -}} {{- $name := default .Chart.Name .Values.WebUi.Name -}} -{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "worker-fullname" -}} {{- $name := default .Chart.Name .Values.Worker.Name -}} -{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "zeppelin-fullname" -}} {{- $name := default .Chart.Name .Values.Zeppelin.Name -}} -{{- printf "%s-%s" .Release.Name $name | trunc 24 -}} -{{- end -}} \ No newline at end of file +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/spark/templates/spark-master-deployment.yaml b/stable/spark/templates/spark-master-deployment.yaml index 05c4b0c714..3e2a7cf4f9 100644 --- a/stable/spark/templates/spark-master-deployment.yaml +++ b/stable/spark/templates/spark-master-deployment.yaml @@ -29,7 +29,7 @@ spec: targetPort: {{ .Values.WebUi.ContainerPort }} selector: component: "{{ .Release.Name }}-{{ .Values.Master.Component }}" - type: "LoadBalancer" + type: {{ .Values.Master.ServiceType }} --- apiVersion: extensions/v1beta1 kind: Deployment diff --git a/stable/spark/templates/spark-zeppelin-deployment.yaml b/stable/spark/templates/spark-zeppelin-deployment.yaml index a26a86df7e..0587a04d57 100644 --- a/stable/spark/templates/spark-zeppelin-deployment.yaml +++ b/stable/spark/templates/spark-zeppelin-deployment.yaml @@ -9,11 +9,12 @@ metadata: component: "{{ .Release.Name }}-{{ .Values.Zeppelin.Component }}" spec: ports: - - port: {{ .Values.Zeppelin.ServicePort }} + - name: http + port: {{ .Values.Zeppelin.ServicePort }} targetPort: {{ .Values.Zeppelin.ContainerPort }} selector: component: "{{ .Release.Name }}-{{ .Values.Zeppelin.Component }}" - type: "LoadBalancer" + type: {{ .Values.Zeppelin.ServiceType }} --- apiVersion: extensions/v1beta1 kind: Deployment @@ -44,9 +45,10 @@ spec: image: "{{ .Values.Zeppelin.Image }}:{{ .Values.Zeppelin.ImageTag }}" ports: - containerPort: {{ .Values.Zeppelin.ContainerPort }} + name: http resources: requests: cpu: "{{ .Values.Zeppelin.Cpu }}" env: - name: SPARK_MASTER - value: "spark://{{ template "master-fullname" . }}:{{ .Values.Master.ServicePort }}" \ No newline at end of file + value: "spark://{{ template "master-fullname" . }}:{{ .Values.Master.ServicePort }}" diff --git a/stable/spark/templates/spark-zeppelin-ingress.yaml b/stable/spark/templates/spark-zeppelin-ingress.yaml new file mode 100644 index 0000000000..463bd62697 --- /dev/null +++ b/stable/spark/templates/spark-zeppelin-ingress.yaml @@ -0,0 +1,44 @@ +{{- $ingress := .Values.Zeppelin.Ingress -}} +{{- $fullName := include "zeppelin-fullname" . -}} +{{- if $ingress.Enabled }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "zeppelin-fullname" . }} +{{- if $ingress.Annotations }} + annotations: +{{ toYaml $ingress.Annotations | indent 4 }} +{{- end }} + labels: + heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name | quote }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + component: "{{ .Release.Name }}-{{ .Values.Zeppelin.Component }}" +spec: +{{- if $ingress.Tls }} + tls: + {{- range $ingress.Tls }} + - hosts: + {{- range .Hosts }} + - {{ . }} + {{- end }} + secretName: {{ .SecretName | default (printf "%s-tls" $fullName) }} +{{- end }} +{{- end }} + {{- if $ingress.Hosts }} + rules: + {{- range $ingress.Hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingress.Path }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- else }} + backend: + serviceName: {{ template "zeppelin-fullname" . }} + servicePort: http +{{- end }} +{{- end }} \ No newline at end of file diff --git a/stable/spark/values.yaml b/stable/spark/values.yaml index 4a9a92e58d..a1ea98fba2 100644 --- a/stable/spark/values.yaml +++ b/stable/spark/values.yaml @@ -15,6 +15,7 @@ Master: ContainerPort: 7077 # Set Master JVM memory. Default 1g # DaemonMemory: 1g + ServiceType: LoadBalancer WebUi: Name: webui @@ -44,3 +45,22 @@ Zeppelin: Cpu: "100m" ServicePort: 8080 ContainerPort: 8080 + ServiceType: LoadBalancer + Ingress: + Enabled: false + Path: "/" + Tls: [] + # - Hosts: + # SecretName: zeppelin + # Used to create an Ingress record. + # Hosts: + # - example.local + # Annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # Tls: + # Enabled: true + # Secrets must be manually created in the namespace. + # SecretName: example-tls + # Hosts: + # - example.local