Skip to content

Instantly share code, notes, and snippets.

@simbo1905
Created September 2, 2019 14:49
Show Gist options
  • Save simbo1905/3096062c8b6a43c0a0aa88ac3f9a1ada to your computer and use it in GitHub Desktop.
Save simbo1905/3096062c8b6a43c0a0aa88ac3f9a1ada to your computer and use it in GitHub Desktop.
write out a config file to a PVCs wihin an initContainer
#!/bin/bash
cat | oc create -f - <<EOF
---
apiVersion: "v1"
kind: "PersistentVolumeClaim"
metadata:
name: "config-data-claim"
spec:
accessModes:
- "ReadWriteMany"
resources:
requests:
storage: "1Gi"
---
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: realworld
image: docker.io/simonmassey/react-redux-realworld:v0.0.2
env:
- name: API_ROOT
value: https://conduit.productionready.io/api
volumeMounts:
- mountPath: /data
name: config-data-claim
initContainers:
- name: config-data
image: busybox
command: ["sh", "-c", "echo {'address':'10.0.1.192:2379/db'} > /data/config"]
volumeMounts:
- mountPath: /data
name: config-data-claim
volumes:
- name: config-data-claim
persistentVolumeClaim:
claimName: config-data-claim
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment