From 9e329d05b8dc44fb05cec24a8cac0311ce347bee Mon Sep 17 00:00:00 2001 From: Emile Fugulin Date: Fri, 29 May 2020 15:29:16 -0400 Subject: [PATCH] Add wave chart --- charts/wave/Chart.yaml | 11 +++++ charts/wave/templates/_helpers.tpl | 23 +++++++++++ charts/wave/templates/clusterrole.yaml | 40 +++++++++++++++++++ charts/wave/templates/clusterrolebinding.yaml | 16 ++++++++ charts/wave/templates/configmap.yaml | 9 +++++ charts/wave/templates/deployment.yaml | 33 +++++++++++++++ charts/wave/templates/serviceaccount.yaml | 11 +++++ charts/wave/values.yaml | 37 +++++++++++++++++ 8 files changed, 180 insertions(+) create mode 100644 charts/wave/Chart.yaml create mode 100644 charts/wave/templates/_helpers.tpl create mode 100644 charts/wave/templates/clusterrole.yaml create mode 100644 charts/wave/templates/clusterrolebinding.yaml create mode 100644 charts/wave/templates/configmap.yaml create mode 100644 charts/wave/templates/deployment.yaml create mode 100644 charts/wave/templates/serviceaccount.yaml create mode 100644 charts/wave/values.yaml diff --git a/charts/wave/Chart.yaml b/charts/wave/Chart.yaml new file mode 100644 index 0000000..6d0e652 --- /dev/null +++ b/charts/wave/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +name: wave +description: wave chart that runs on kubernetes +version: 1.0.0 +appVersion: v0.4.0 +keywords: + - wave + - kubernetes +home: https://github.com/pusher/wave +sources: +- https://github.com/pusher/wave diff --git a/charts/wave/templates/_helpers.tpl b/charts/wave/templates/_helpers.tpl new file mode 100644 index 0000000..8c864a2 --- /dev/null +++ b/charts/wave/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "wave-name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" | lower -}} +{{- 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 "wave-fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "wave-labels.chart" -}} +app: {{ template "wave-name" . }} +release: {{ .Release.Name | quote }} +chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +heritage: {{ .Release.Service | quote }} +{{- end -}} diff --git a/charts/wave/templates/clusterrole.yaml b/charts/wave/templates/clusterrole.yaml new file mode 100644 index 0000000..547f23f --- /dev/null +++ b/charts/wave/templates/clusterrole.yaml @@ -0,0 +1,40 @@ +{{- if .Values.global.rbac.enabled }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + labels: +{{ include "wave-labels.chart" . | indent 4 }} + name: {{ template "wave-fullname" . }} +rules: + - apiGroups: + - "" + resources: + - configmaps + - secrets + verbs: + - list + - get + - update + - patch + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - update + - patch + - apiGroups: + - apps + resources: + - deployments + - daemonsets + - statefulsets + verbs: + - list + - get + - update + - patch + - watch +{{- end }} diff --git a/charts/wave/templates/clusterrolebinding.yaml b/charts/wave/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..1d5ee36 --- /dev/null +++ b/charts/wave/templates/clusterrolebinding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.global.rbac.enabled }} +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + labels: +{{ include "wave-labels.chart" . | indent 4 }} + name: {{ template "wave-fullname" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "wave-fullname" . }} +subjects: + - kind: ServiceAccount + name: {{ .Values.serviceAccount.name | default (include "wave-fullname" .) }} + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/charts/wave/templates/configmap.yaml b/charts/wave/templates/configmap.yaml new file mode 100644 index 0000000..bd6493d --- /dev/null +++ b/charts/wave/templates/configmap.yaml @@ -0,0 +1,9 @@ +{{- if gt .Values.replicas 1.0 }} +apiVersion: v1 +kind: ConfigMap +metadata: + labels: +{{ include "wave-labels.chart" . | indent 4 }} + name: {{ template "wave-fullname" . }} +data: +{{- end }} diff --git a/charts/wave/templates/deployment.yaml b/charts/wave/templates/deployment.yaml new file mode 100644 index 0000000..813e805 --- /dev/null +++ b/charts/wave/templates/deployment.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: {{ toYaml .Values.annotations | nindent 4 }} + labels: +{{ include "wave-labels.chart" . | indent 4 }} + name: {{ template "wave-fullname" . }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: +{{ include "wave-labels.chart" . | indent 6 }} + template: + metadata: + labels: +{{ include "wave-labels.chart" . | indent 8 }} + spec: + containers: + - image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + name: {{ template "wave-fullname" . }} + args: + {{- if gt .Values.replicas 1.0 }} + - --leader-election=true + - --leader-election-id={{ template "wave-fullname" . }} + - --leader-election-namespace={{ .Release.Namespace }} + {{- end }} + {{- if .Values.syncPeriod }} + - --sync-period={{ .Values.syncPeriod }} + {{- end }} + securityContext: {{ toYaml .Values.securityContext | nindent 8 }} + serviceAccountName: {{ .Values.serviceAccount.name | default (include "wave-fullname" .) }} + nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }} diff --git a/charts/wave/templates/serviceaccount.yaml b/charts/wave/templates/serviceaccount.yaml new file mode 100644 index 0000000..a5ba1ef --- /dev/null +++ b/charts/wave/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +{{- if .Values.global.imagePullSecrets }} +imagePullSecrets: {{ toYaml .Values.global.imagePullSecrets | nindent 2 }} +{{- end }} +metadata: + labels: +{{ include "wave-labels.chart" . | indent 4 }} + name: {{ .Values.serviceAccount.name | default (include "wave-fullname" .) }} +{{- end }} diff --git a/charts/wave/values.yaml b/charts/wave/values.yaml new file mode 100644 index 0000000..8076926 --- /dev/null +++ b/charts/wave/values.yaml @@ -0,0 +1,37 @@ +global: + ## Reference to one or more secrets to be used when pulling images + ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + ## + imagePullSecrets: [] + # - name: "image-pull-secret" + rbac: + enabled: true + +# Annotations for the wave pods +annotations: {} +image: + name: quay.io/pusher/wave + tag: v0.4.0 + pullPolicy: IfNotPresent + +# Node selector for the wave pods +nodeSelector: {} + +# Replicas > 1 will enable leader election +replicas: 1 + +# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ +securityContext: + runAsNonRoot: true + runAsUser: 1000 + +# Service account config for the agent pods +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + +# Period for reconciliation +# syncPeriod: 5m