Skip to content

Instantly share code, notes, and snippets.

@spalladino
Created March 17, 2016 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spalladino/a4e86b9f7e5856722afe to your computer and use it in GitHub Desktop.
Save spalladino/a4e86b9f7e5856722afe to your computer and use it in GitHub Desktop.
Kubernetes sample config files for running Brium web app with a MySQL service on Google Container Engine
apiVersion: extensions/v1beta1
kind: Job
metadata:
name: brium-dbsetup
spec:
selector:
matchLabels:
app: brium-dbsetup
template:
metadata:
name: brium-dbsetup
labels:
app: brium-dbsetup
spec:
containers:
- name: brium-dbsetup
image: us.gcr.io/brium-1253/brium:latest
command: ["rake", "db:setup"]
env:
- name: DATABASE_URL
value: "mysql2://root@mysql/brium"
- name: RAILS_ENV
value: production
restartPolicy: Never
apiVersion: v1
kind: Service
metadata:
labels:
name: brium-frontend
name: brium-frontend
spec:
type: LoadBalancer
ports:
# The port that this service should serve on.
- port: 80
targetPort: 80
protocol: TCP
# Label keys and values that must match in order to receive traffic for this service.
selector:
name: brium-web
apiVersion: v1
kind: Pod
metadata:
name: brium-web
labels:
name: brium-web
spec:
containers:
- image: us.gcr.io/brium-1253/brium:latest
name: brium-web
env:
- name: DATABASE_URL
value: "mysql2://root@mysql/brium"
- name: RAILS_ENV
value: production
ports:
- containerPort: 80
name: brium-web
apiVersion: v1
kind: Service
metadata:
labels:
name: mysql
name: mysql
spec:
ports:
- port: 3306
# Label keys and values that must match in order to receive traffic for this service.
selector:
name: mysql
apiVersion: v1
kind: Pod
metadata:
name: mysql
labels:
name: mysql
spec:
containers:
- resources:
limits:
cpu: 0.3
requests:
cpu: 0.1
image: mysql:5.6
name: mysql
env:
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "yes"
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
# Create with `gcloud compute disks create --size 30GB mysql-data`
- name: mysql-persistent-storage
gcePersistentDisk:
pdName: mysql-data
fsType: ext4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment