Skip to content

Commit

Permalink
Add support for broker statefulset, kesque-dashboard (#66)
Browse files Browse the repository at this point in the history
* Cleanup for function workers with state

* Only add state service if standalone state storage is enabled

* Fix useTls setting for function worker when TLS is disabled

* Update offload test to wait for ledgers to be deleted from BookKeeper

* State storage enhancements

* Initial commit of dashboard chart

* Remove key

* Moving deprecated files to separate directory

* Add option to create a stateful set of brokers

* Small fixes plus prefix for bookkeeper PVCs

* kesque-dashboard updates
  • Loading branch information
cdbartholomew authored Sep 6, 2020
1 parent bee70ff commit ca1addc
Show file tree
Hide file tree
Showing 57 changed files with 2,153 additions and 38 deletions.
4 changes: 4 additions & 0 deletions helm-chart-sources/kesque-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: Kesque Dashboard for Apache Pulsar
name: kesque-dashboard
version: 0.0.1
2 changes: 2 additions & 0 deletions helm-chart-sources/kesque-dashboard/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Application should be accessible at: {{ .Values.application.url }}

47 changes: 47 additions & 0 deletions helm-chart-sources/kesque-dashboard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 | 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).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trimSuffix "-app" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "appname" -}}
{{- $releaseName := default .Release.Name .Values.releaseOverride -}}
{{- printf "%s" $releaseName | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "trackableappname" -}}
{{- $trackableName := printf "%s-%s" (include "appname" .) .Values.application.track -}}
{{- $trackableName | trimSuffix "-stable" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Get a hostname from URL
*/}}
{{- define "hostname" -}}
{{- . | trimPrefix "http://" | trimPrefix "https://" | trimSuffix "/" | quote -}}
{{- end -}}


{{- define "image.dockerconfigjson" -}}
{
"auths": {
"registry.gitlab.com": {
"username": "{{ .Values.image.username }}",
"password": "{{ .Values.image.password }}",
"email": "[email protected]",
"auth": "{{ tpl ("{{ .Values.image.username }}:{{ .Values.image.password }}") . | b64enc }}"
}
}
}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: wp-keys-salts
data:
WORDPRESS_AUTH_KEY: cSg+WnQ5W1pUUylJTUNXbj1BPkk+fHBgUlVsK3U4OykwbEdpUyQ8LTVwL1Vuez47cmctSlpFdldtXmx6Iz45Pgo=
WORDPRESS_SECURE_AUTH_KEY: V2s3OWxdZFRocHxPZzdNQDI2WWo9VjBPIXUqel5ePDEhO0UtQ1ohaXgpYC06fGNlKVViYXhbfkpLSCEhKzBqLQo=
WORDPRESS_LOGGED_IN_KEY: SU8yQVZ5IGdeWisrbmd0fHl0cmB3Y1h8MVtTQmdFNl0qUkMjQ3MseVhgTnw6dV07eUNzKGh6MnhdL3Z8Q3RGcAo=
WORDPRESS_NONCE_KEY: fnpGY29NZkM0fkdqY1l5XX0pVkpzZTl5WHxdajNhWi8gQVtUJTZzMHxpVFYtc09EU1MoKEZ2ZDx5NUcqK2psTgo=
WORDPRESS_AUTH_SALT: LW1hbTIoLiswfjZ4TGlJNE0jQXVze1h3fG5IcnFQRmVGZChtUlt5W0h9ZHY/K0ptRy1hMHtETSlraGMoSyxuKwo=
WORDPRESS_SECURE_AUTH_SALT: ZW1XbXx1Rk5NLTBZOFttWzNBOlR6SEJzME9LL2VSQ2MpOSFhbnQ0O1ZaZV1UXSZ9a3c0XiFGNCtYRmdsemQmdAo=
WORDPRESS_LOGGED_IN_SALT: LWwub0FfKV92RkkpVSZLK0VxSWp8e28+LUV8PjwmWm48VywsJC55eTQtbzw9eytQOk5sdWdSLWhJKzV5RF5VNwo=
WORDPRESS_NONCE_SALT: UGNqPi1LKnxEcyV1YHE4JjZSRzdOKis1KUg3YjhWQiRscFgoIXY6eSZQYi91WyspIWg0Pmtpdj4rekRjKEs8YAo=
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{- if not .Values.application.initializeCommand -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "trackableappname" . }}
labels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "appname" . }}
release: {{ .Release.Name }}
template:
metadata:
annotations:
checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ template "appname" . }}
topologyKey: "kubernetes.io/hostname"
imagePullSecrets:
- name: {{ .Values.image.secret }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.application.secretName }}
envFrom:
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: WORDPRESS_DB_HOST
value: {{ .Release.Name }}-mariadb-svc
- name: WORDPRESS_DB_USER
value: {{ .Values.application.dbUser }}
- name: WORDPRESS_DB_PASSWORD
value: {{ .Values.application.dbPassword }}
- name: WORDPRESS_DB_NAME
value: {{ .Values.application.dbName }}
- name: WORDPRESS_CONFIG_EXTRA
value: "define('FS_METHOD', 'direct' ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'DISABLE_WP_CRON', true ); define( 'ALLOW_UNFILTERED_UPLOADS', true); define( 'WP_AUTO_UPDATE_CORE', false ); define( 'W3TC_CONFIG_DATABASE', true ); define( 'WP_HOME', '{{ .Values.application.url }}' ); define( 'WP_SITEURL', '{{ .Values.application.url }}' );"
envFrom:
- configMapRef:
name: wp-keys-salts
ports:
- name: "{{ .Values.service.name }}"
containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.path }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if .Values.service.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
spec:
rules:
- host: {{ toYaml .Values.ingress.host }}
http:
paths:
- backend:
serviceName: {{ template "fullname" . }}
servicePort: {{ .Values.service.externalPort }}
path: {{ .Values.service.ingress.mainPath }}
- backend:
serviceName: {{ .Release.Name }}-nginx
servicePort: {{ .Values.service.externalPort }}
path: {{ .Values.service.ingress.apiPath }}
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ toYaml .Values.ingress.host }}
secretName: {{ .Values.ingress.tls.secretName | default (printf "%s-tls" (include "fullname" .)) }}
{{- end }}
{{- end -}}
22 changes: 22 additions & 0 deletions helm-chart-sources/kesque-dashboard/templates/dashboard/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.podDisruptionBudget.enabled }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
selector:
matchLabels:
app: {{ template "appname" . }}
release: {{ .Release.Name }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
.dockerconfigjson: {{ include "image.dockerconfigjson" . | b64enc }}
kind: Secret
metadata:
name: {{ .Values.image.secret }}
type: kubernetes.io/dockerconfigjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "appname" . }}
tier: "{{ .Values.application.tier }}"
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.application.initializeCommand -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "trackableappname" . }}-db-initialize
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation
"helm.sh/hook-weight": "0"
spec:
template:
metadata:
labels:
app: {{ template "appname" . }}
release: {{ .Release.Name }}
spec:
restartPolicy: Never
imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: ["/bin/sh"]
args: ["-c", "{{ .Values.application.initializeCommand }}"]
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.application.secretName }}
envFrom:
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: DATABASE_URL
value: {{ .Values.application.database_url | quote }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.application.migrateCommand -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "trackableappname" . }}-db-migrate
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
"helm.sh/hook-weight": "0"
spec:
template:
metadata:
labels:
app: {{ template "appname" . }}
release: {{ .Release.Name }}
spec:
restartPolicy: Never
imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: ["/bin/sh"]
args: ["-c", "{{ .Values.application.migrateCommand }}"]
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.application.secretName }}
envFrom:
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: DATABASE_URL
value: {{ .Values.application.database_url | quote }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Release.Name }}-dbinitscript"
data:
create_db_update_script.sh: |-
#!/bin/bash
INFILE=/db-startup-files/10_update-db-template.sql
OUTFILE=/docker-entrypoint-initdb.d/10_update-db.sql
URL={{ .Values.application.url }}
cp $INFILE $OUTFILE
sed 's/__DATABASENAME__/{{ .Values.application.dbName }}/g' -i $OUTFILE
sed 's/__ADMINUSER__/{{ .Values.application.adminUser }}/g' -i $OUTFILE
sed 's/__ADMINPASSWORD__/{{ .Values.application.adminPassword }}/g' -i $OUTFILE
sed 's/__ADMINEMAIL__/{{ .Values.application.adminEmail }}/g' -i $OUTFILE
sed 's/__TOKEN__/{{ .Values.application.token }}/g' -i $OUTFILE
sed "s|__URL__|$URL|g" -i $OUTFILE
sed "s|__CLUSTERNAME__|{{ .Values.application.clusterName }}|g" -i $OUTFILE
sed "s|__BROKERURL__|{{ .Values.application.brokerService }}|g" -i $OUTFILE
sed "s|__PROXYURL__|{{ .Values.application.proxyService }}|g" -i $OUTFILE
sed "s|__HTTPURL__|{{ .Values.application.httpService }}|g" -i $OUTFILE
URLLEN=${#URL}
# Need to add length of hard-coded path: /api/v1
LEN=$(($URLLEN + 7))
sed "s/__URLLEN__/$LEN/g" -i $OUTFILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.mariadb.enabled -}}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-mariadb-secret
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/component: wp-mariadb
type: Opaque
data:
wp-user: {{ .Values.application.dbUser | b64enc | quote }}
root-password: {{ .Values.mariadb.rootPassword | b64enc | quote }}
wp-password: {{ .Values.application.dbPassword | b64enc | quote }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-mysqld-exporter-secret
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/component: wp-mysql
stringData:
mysqld_exporter.sql: |
CREATE USER IF NOT EXISTS '{{ .Values.mariadb.exporter.user }}'@'127.0.0.1' IDENTIFIED BY '{{ .Values.mariadb.exporter.password }}' WITH MAX_USER_CONNECTIONS 3;
# https://dev.mysql.com/doc/refman/5.6/en/grant.html
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO '{{ .Values.mariadb.exporter.user }}'@'127.0.0.1';
FLUSH PRIVILEGES;
data:
mysqld-exporter-pass: {{ .Values.mariadb.exporter.password | b64enc | quote }}
{{- end }}
Loading

0 comments on commit ca1addc

Please sign in to comment.