Skip to content

Commit

Permalink
Helm charts for deployment on GKE (apache#1993)
Browse files Browse the repository at this point in the history
* Helm charts for deployment on GKE

* Repackaginh helm charts under deployment/kubernetes/helm

* Formatting licences

* Removing cloud specific values to enable more generic deployments
  • Loading branch information
DanielFerreiraJorge authored and merlimat committed Jun 25, 2018
1 parent f7c5696 commit b506793
Show file tree
Hide file tree
Showing 39 changed files with 2,507 additions and 0 deletions.
23 changes: 23 additions & 0 deletions deployment/kubernetes/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

This directory contains the Helm Chart required
to do a complete Pulsar deployment on Kubernetes.
21 changes: 21 additions & 0 deletions deployment/kubernetes/helm/pulsar/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
24 changes: 24 additions & 0 deletions deployment/kubernetes/helm/pulsar/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

apiVersion: v1
appVersion: "1.0"
description: Apache Pulsar Helm chart for Kubernetes
name: pulsar
version: 1.0.0
32 changes: 32 additions & 0 deletions deployment/kubernetes/helm/pulsar/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "pulsar.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- 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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "pulsar.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "pulsar.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

{{- if .Values.extra.autoRecovery }}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.autoRecovery.component }}"
namespace: {{ .Values.namespace }}
labels:
app: {{ template "pulsar.name" . }}
chart: {{ template "pulsar.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.autoRecovery.component }}
cluster: {{ template "pulsar.fullname" . }}
data:
zkServers:
{{- $global := . }}
{{ range $i, $e := until (.Values.zookeeper.replicaCount | int) }}{{ if ne $i 0 }},{{ end }}{{ printf "%s-%s-%s-%d.%s-%s-%s" $global.Release.Name $global.Chart.Name $global.Values.zookeeper.component $i $global.Release.Name $global.Chart.Name $global.Values.zookeeper.component }}{{ end }}
{{ toYaml .Values.autoRecovery.configData | indent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

{{- if .Values.extra.autoRecovery }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.autoRecovery.component }}"
namespace: {{ .Values.namespace }}
labels:
app: {{ template "pulsar.name" . }}
chart: {{ template "pulsar.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.autoRecovery.component }}
cluster: {{ template "pulsar.fullname" . }}
spec:
replicas: {{ .Values.autoRecovery.replicaCount }}
selector:
matchLabels:
app: {{ template "pulsar.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.autoRecovery.component }}
template:
metadata:
labels:
app: {{ template "pulsar.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.autoRecovery.component }}
cluster: {{ template "pulsar.fullname" . }}
annotations:
{{ toYaml .Values.autoRecovery.annotations | indent 8 }}
spec:
{{- if .Values.autoRecovery.nodeSelector }}
nodeSelector:
{{ toYaml .Values.autoRecovery.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.autoRecovery.tolerations }}
tolerations:
{{ toYaml .Values.autoRecovery.tolerations | indent 8 }}
{{- end }}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- "{{ template "pulsar.name" . }}-{{ .Values.bookkeeper.component }}"
- key: "release"
operator: In
values:
- {{ .Release.Name }}
- key: "component"
operator: In
values:
- {{ .Values.bookkeeper.component }}
topologyKey: "kubernetes.io/hostname"
terminationGracePeriodSeconds: {{ .Values.dashboard.gracePeriod }}
initContainers:
# This init container will wait for zookeeper to be ready before
# deploying the bookies
- name: wait-zookeeper-ready
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["sh", "-c"]
args:
- >-
until nslookup {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ add (.Values.zookeeper.replicaCount | int) -1 }}.{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}.{{ .Values.namespace }}; do
sleep 3;
done;
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.autoRecovery.component }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.autoRecovery.resources }}
resources:
{{ toYaml .Values.autoRecovery.resources | indent 10 }}
{{- end }}
command: ["sh", "-c"]
args:
- >
bin/apply-config-from-env.py conf/bookkeeper.conf &&
bin/bookkeeper autorecovery
envFrom:
- configMapRef:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.autoRecovery.component }}"
{{- end }}
35 changes: 35 additions & 0 deletions deployment/kubernetes/helm/pulsar/templates/bastion-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

{{- if .Values.extra.bastion }}
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bastion.component }}"
namespace: {{ .Values.namespace }}
labels:
app: {{ template "pulsar.name" . }}
chart: {{ template "pulsar.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.bastion.component }}
cluster: {{ template "pulsar.fullname" . }}
data:
{{ toYaml .Values.bastion.configData | indent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

{{- if .Values.extra.bastion }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bastion.component }}"
namespace: {{ .Values.namespace }}
labels:
app: {{ template "pulsar.name" . }}
chart: {{ template "pulsar.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: {{ .Values.bastion.component }}
cluster: {{ template "pulsar.fullname" . }}
spec:
replicas: {{ .Values.bastion.replicaCount }}
selector:
matchLabels:
app: {{ template "pulsar.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.bastion.component }}
template:
metadata:
labels:
app: {{ template "pulsar.name" . }}
release: {{ .Release.Name }}
component: {{ .Values.bastion.component }}
cluster: {{ template "pulsar.fullname" . }}
annotations:
{{ toYaml .Values.bastion.annotations | indent 8 }}
spec:
{{- if .Values.bastion.nodeSelector }}
nodeSelector:
{{ toYaml .Values.bastion.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.bastion.tolerations }}
tolerations:
{{ toYaml .Values.bastion.tolerations | indent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.bastion.gracePeriod }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bastion.component }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.bastion.resources }}
resources:
{{ toYaml .Values.bastion.resources | indent 10 }}
{{- end }}
command: ["sh", "-c"]
args:
- >
bin/apply-config-from-env.py conf/client.conf &&
sleep 10000000000
envFrom:
- configMapRef:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bastion.component }}"
env:
- name: webServiceUrl
value: http://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}:8080/
- name: brokerServiceUrl
value: pulsar://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}:6650/
{{- end }}
Loading

0 comments on commit b506793

Please sign in to comment.