Skip to content

Instantly share code, notes, and snippets.

@znorris
Last active April 18, 2018 23:08
Show Gist options
  • Save znorris/ce265951dfcd307994fff1959676c0cc to your computer and use it in GitHub Desktop.
Save znorris/ce265951dfcd307994fff1959676c0cc to your computer and use it in GitHub Desktop.
Kubernetes Proxy Sidecar Example
spec:
restartPolicy: Never
initContainers:
- name: init
image: busybox
command: ["/bin/sh"]
args: ["-c",
"touch /tmp/shared-volume/migration.lock"]
volumeMounts:
- name: shared-volume
mountPath: /tmp/shared-volume
containers:
- name: cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.11
command: ["/bin/sh"]
args: ["-c",
"/cloud_sql_proxy --dir=/cloudsql -instances=${INSTANCE_NAME}=tcp:5432 & export pid=$!; until [[ ! -f /tmp/shared-volume/migration.lock ]]; do sleep 1; done; kill ${pid}"]
volumeMounts:
- name: shared-volume
mountPath: /tmp/shared-volume
- name: migration
image: ${IMAGE}
command: ["/bin/sh", "-c",
"sleep 10; ${SOME_COMMAND}; rm -rf /tmp/shared-volume/migration.lock"]
volumeMounts:
- name: shared-volume
mountPath: /tmp/shared-volume
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment