Skip to content

Instantly share code, notes, and snippets.

@russmckendrick
Last active November 13, 2016 15:33
Show Gist options
  • Save russmckendrick/f151fa18d55a64428ef97c7b5522f132 to your computer and use it in GitHub Desktop.
Save russmckendrick/f151fa18d55a64428ef97c7b5522f132 to your computer and use it in GitHub Desktop.
Example Kubernetes App
apiVersion: v1
kind: Service
metadata:
name: moby-counter-frontend
labels:
app: moby-counter
tier: frontend
spec:
type: NodePort
ports:
# the port that this service should serve on
- port: 80
nodePort: 30080
selector:
app: moby-counter
tier: frontend
---
apiVersion: v1
kind: ReplicationController
metadata:
name: moby-counter
# these labels can be applied automatically
# from the labels in the pod template if not set
labels:
purpose: demo
spec:
replicas: 3
template:
metadata:
labels:
app: moby-counter
tier: frontend
spec:
containers:
- name: moby-counter
image: russmckendrick/moby-counter
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: redis
labels:
app: redis
spec:
ports:
# the port that this service should serve on
- port: 6379
targetPort: 6379
selector:
app: redis
---
apiVersion: v1
kind: ReplicationController
metadata:
name: redis
# these labels can be applied automatically
# from the labels in the pod template if not set
labels:
purpose: demo
spec:
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 6379
hostPort: 6379
protocol: TCP
volumeMounts:
# name must match the volume name below
- name: redis-data
mountPath: "/data"
volumes:
- name: redis-data
flocker:
datasetName: FlockerVolume1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment