Last active
May 22, 2017 19:44
-
-
Save mjudeikis/6de11e457256aec62b56f66143ef613d to your computer and use it in GitHub Desktop.
This file contains 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
# A headless service to create DNS records | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
annotations: | |
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" | |
name: redis | |
labels: | |
app: redis | |
spec: | |
ports: | |
- port: 6379 | |
name: peer | |
# *.redis.default.svc.cluster.local | |
clusterIP: None | |
selector: | |
app: redis | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: rd | |
spec: | |
serviceName: "redis" | |
replicas: 3 | |
template: | |
metadata: | |
labels: | |
app: redis | |
annotations: | |
pod.alpha.kubernetes.io/initialized: "true" | |
pod.alpha.kubernetes.io/init-containers: '[ | |
{ | |
"name": "install", | |
"image": "gcr.io/google_containers/redis-install:0.1", | |
"imagePullPolicy": "Always", | |
"args": ["--version=3.2.0", "--install-into=/opt", "--work-dir=/work-dir"], | |
"volumeMounts": [ | |
{ | |
"name": "opt", | |
"mountPath": "/opt" | |
}, | |
{ | |
"name": "workdir", | |
"mountPath": "/work-dir" | |
} | |
] | |
}, | |
{ | |
"name": "bootstrap", | |
"image": "debian:jessie", | |
"command": ["/work-dir/peer-finder"], | |
"args": ["-on-start=\"/work-dir/on-start.sh\"", "-service=redis"], | |
"env": [ | |
{ | |
"name": "POD_NAMESPACE", | |
"valueFrom": { | |
"fieldRef": { | |
"apiVersion": "v1", | |
"fieldPath": "metadata.namespace" | |
} | |
} | |
} | |
], | |
"volumeMounts": [ | |
{ | |
"name": "opt", | |
"mountPath": "/opt" | |
}, | |
{ | |
"name": "workdir", | |
"mountPath": "/work-dir" | |
} | |
] | |
} | |
]' | |
spec: | |
containers: | |
- name: redis | |
image: debian:jessie | |
ports: | |
- containerPort: 6379 | |
name: peer | |
command: | |
- /opt/redis/redis-server | |
args: | |
- /opt/redis/redis.conf | |
readinessProbe: | |
exec: | |
command: | |
- sh | |
- -c | |
- "/opt/redis/redis-cli -h $(hostname) ping" | |
initialDelaySeconds: 15 | |
timeoutSeconds: 5 | |
volumeMounts: | |
- name: datadir | |
mountPath: /data | |
- name: opt | |
mountPath: /opt | |
volumes: | |
- name: opt | |
emptyDir: {} | |
- name: workdir | |
emptyDir: {} | |
- name: datadir | |
emptyDir: {} | |
#volumeClaimTemplates: | |
#- metadata: | |
# name: datadir | |
# annotations: | |
# volume.alpha.kubernetes.io/storage-class: anything | |
# spec: | |
# accessModes: [ "ReadWriteOnce" ] | |
# resources: | |
# requests: | |
# storage: 20Gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment