Skip to content

Instantly share code, notes, and snippets.

@etoews etoews/app.yaml
Created Oct 30, 2017

Embed
What would you like to do?
apiVersion: v1
kind: ConfigMap
metadata:
name: app
data:
MYSQL_HOST: "db"
MYSQL_DATABASE: "auth"
MYSQL_USER: "app"
MYSQL_PASSWORD: "password"
MYSQL_ROOT_PASSWORD: "rootpassword"
---
apiVersion: v1
kind: Service
metadata:
name: app
labels:
role: app
spec:
selector:
role: app
ports:
- protocol: TCP
port: 80
targetPort: http
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: app
labels:
role: app
spec:
replicas: 1
template:
metadata:
labels:
role: app
spec:
containers:
- name: app
image: quay.io/etoews/app:dumb-init
args:
- --db-host=$(MYSQL_HOST)
- --db-user=$(MYSQL_USER)
- --db-password=$(MYSQL_PASSWORD)
envFrom:
- configMapRef:
name: app
resources:
limits:
cpu: 100m
memory: 100Mi
ports:
- name: http
containerPort: 8080
protocol: TCP
initContainers:
- name: wait-for-db
image: mysql
command:
- "sh"
- "-c"
- "until mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWORD -e'quit' --connect-timeout=2; do sleep 2; done"
envFrom:
- configMapRef:
name: app
---
apiVersion: v1
kind: Service
metadata:
name: db
labels:
role: db
spec:
selector:
role: db
ports:
- protocol: TCP
port: 3306
targetPort: mysql
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: db
labels:
role: db
spec:
replicas: 1
template:
metadata:
labels:
role: db
spec:
containers:
- name: db
image: mysql
ports:
- name: mysql
containerPort: 3306
resources:
limits:
cpu: 100m
memory: 1Gi
envFrom:
- configMapRef:
name: app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.