-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4010 from lsst-sqre/tickets/DM-48184
DM-48184: Bump Wobbly to 0.2.0, add maintenance CronJob
- Loading branch information
Showing
5 changed files
with
185 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: "wobbly-maintenance" | ||
labels: | ||
{{- include "wobbly.labels" . | nindent 4 }} | ||
spec: | ||
schedule: {{ .Values.maintenance.schedule | quote }} | ||
concurrencyPolicy: "Forbid" | ||
jobTemplate: | ||
spec: | ||
activeDeadlineSeconds: {{ .Values.maintenance.deadlineSeconds }} | ||
ttlSecondsAfterFinished: {{ .Values.maintenance.cleanupSeconds }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
labels: | ||
{{- include "wobbly.selectorLabels" . | nindent 12 }} | ||
app.kubernetes.io/component: "maintenance" | ||
spec: | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.cloudsql.enabled }} | ||
serviceAccountName: "wobbly" | ||
{{- else }} | ||
automountServiceAccountToken: false | ||
{{- end }} | ||
containers: | ||
{{- if .Values.cloudsql.enabled }} | ||
- name: "cloud-sql-proxy" | ||
# Running the sidecar as normal causes it to keep running and | ||
# thus the Pod never exits, the Job never finishes, and the hook | ||
# blocks the sync. Have the main pod signal the sidecar by | ||
# writing to a file on a shared emptyDir file system, and use a | ||
# simple watcher loop in shell in the sidecar container to | ||
# terminate the proxy when the main container finishes. | ||
# | ||
# Based on https://stackoverflow.com/questions/41679364/ | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
- | | ||
/cloud_sql_proxy -ip_address_types=PRIVATE -log_debug_stdout=true -structured_logs=true -instances={{ required "cloudsql.instanceConnectionName must be specified" .Values.cloudsql.instanceConnectionName }}=tcp:5432 & | ||
PID=$! | ||
while true; do | ||
if [[ -f "/lifecycle/main-terminated" ]]; then | ||
kill $PID | ||
exit 0 | ||
fi | ||
sleep 1 | ||
done | ||
image: "{{ .Values.cloudsql.image.repository }}:{{ .Values.cloudsql.image.tag }}{{ .Values.cloudsql.image.schemaUpdateTagSuffix }}" | ||
imagePullPolicy: {{ .Values.cloudsql.image.pullPolicy | quote }} | ||
{{- with .Values.cloudsql.resources }} | ||
resources: | ||
{{- toYaml . | nindent 16 }} | ||
{{- end }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- "all" | ||
readOnlyRootFilesystem: true | ||
runAsNonRoot: true | ||
runAsUser: 65532 | ||
runAsGroup: 65532 | ||
volumeMounts: | ||
- name: "lifecycle" | ||
mountPath: "/lifecycle" | ||
{{- end }} | ||
- name: {{ .Chart.Name }} | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
- | | ||
wobbly expire | ||
touch /lifecycle/main-terminated | ||
env: | ||
- name: "WOBBLY_DATABASE_PASSWORD" | ||
valueFrom: | ||
secretKeyRef: | ||
name: "wobbly" | ||
key: "database-password" | ||
{{- if .Values.config.slackAlerts }} | ||
- name: "WOBBLY_SLACK_WEBHOOK" | ||
valueFrom: | ||
secretKeyRef: | ||
name: "wobbly" | ||
key: "slack-webhook" | ||
{{- end }} | ||
{{- if .Values.config.metrics.enabled }} | ||
- name: "KAFKA_BOOTSTRAP_SERVERS" | ||
valueFrom: | ||
secretKeyRef: | ||
name: "wobbly-kafka" | ||
key: "bootstrapServers" | ||
- name: "KAFKA_CLIENT_CERT_PATH" | ||
value: "/etc/wobbly-kafka/user.crt" | ||
- name: "KAFKA_CLIENT_KEY_PATH" | ||
value: "/etc/wobbly-kafka/user.key" | ||
- name: "KAFKA_CLUSTER_CA_PATH" | ||
value: "/etc/wobbly-kafka/ca.crt" | ||
- name: "KAFKA_SECURITY_PROTOCOL" | ||
valueFrom: | ||
secretKeyRef: | ||
name: "wobbly-kafka" | ||
key: "securityProtocol" | ||
{{- end }} | ||
envFrom: | ||
- configMapRef: | ||
name: "wobbly" | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
resources: | ||
{{- toYaml .Values.resources | nindent 16 }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- "all" | ||
readOnlyRootFilesystem: true | ||
volumeMounts: | ||
- name: "lifecycle" | ||
mountPath: "/lifecycle" | ||
{{- if .Values.config.metrics.enabled }} | ||
- name: "kafka" | ||
mountPath: "/etc/wobbly-kafka/ca.crt" | ||
readOnly: true | ||
subPath: "ssl.truststore.crt" | ||
- name: "kafka" | ||
mountPath: "/etc/wobbly-kafka/user.crt" | ||
readOnly: true | ||
subPath: "ssl.keystore.crt" | ||
- name: "kafka" | ||
mountPath: "/etc/wobbly-kafka/user.key" | ||
readOnly: true | ||
subPath: "ssl.keystore.key" | ||
{{- end }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
restartPolicy: "Never" | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
volumes: | ||
- name: "lifecycle" | ||
emptyDir: {} | ||
{{- if .Values.config.metrics.enabled }} | ||
- name: "kafka" | ||
secret: | ||
secretName: "wobbly-kafka" | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters