Created
January 22, 2018 14:12
-
-
Save onelittlenightmusic/d503f0d66d248ca8ca3194d7b37e8360 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: myapp-svc | |
spec: | |
selector: | |
app: myapp | |
ports: | |
- protocol: TCP | |
port: 5432 | |
#targetPort: 5432 | |
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: myapp-pod | |
labels: | |
app: myapp | |
spec: | |
containers: | |
- name: myapp-container | |
image: postgres | |
# command: ['sh', '-c', 'echo The app is running! && sleep 3600'] | |
tty: true | |
ports: | |
- containerPort: 5432 | |
--- | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: db | |
spec: | |
template: | |
metadata: | |
name: db | |
annotations: | |
pod.beta.kubernetes.io/init-containers: '[ | |
{ | |
"name": "init-myservice", | |
"image": "busybox", | |
"command": ["sh", "-c", "until nslookup myapp-svc; do echo waiting for myapp-svc; sleep 2; done;"] | |
}, | |
]' | |
spec: | |
containers: | |
- name: db-init | |
image: postgres | |
command: ['sh', '-c'] | |
args: ['PGPASSWORD=postgres psql --command="create database test;" -h myapp-svc -U postgres-p 5432 postgres'] | |
restartPolicy: Never | |
#initContainers: | |
#- name: wait-db | |
# image: busybox | |
# command: ["sh", "-c", "until nslookup myapp-pod; do echo waiting for myapp-pod; sleep 2; done;"] | |
#- name: init-mydb | |
#image: busybox | |
#command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment