Created
September 27, 2017 15:49
-
-
Save KushalP/b48f2c09132abb263afd3bd17b7d7e9a to your computer and use it in GitHub Desktop.
Example of how to set up a redis cluster in kubernetes. To apply: `kubectl create -f redis.yml` Raw
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
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: redis-cluster | |
labels: | |
app: redis-cluster | |
data: | |
redis.conf: |+ | |
cluster-enabled yes | |
cluster-require-full-coverage no | |
cluster-node-timeout 15000 | |
cluster-config-file /data/nodes.conf | |
cluster-migration-barrier 1 | |
appendonly yes | |
protected-mode no | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
annotations: | |
service.alpha.kubernetes.io/tolerate-unready-endpoints: "false" | |
name: redis-cluster | |
labels: | |
app: redis-cluster | |
spec: | |
ports: | |
- port: 6379 | |
targetPort: 6379 | |
name: client | |
- port: 16379 | |
targetPort: 16379 | |
name: gossip | |
clusterIP: None | |
selector: | |
app: redis-cluster | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: redis-cluster | |
labels: | |
app: redis-cluster | |
spec: | |
serviceName: redis-cluster | |
replicas: 6 | |
template: | |
metadata: | |
labels: | |
app: redis-cluster | |
spec: | |
containers: | |
- name: redis-cluster | |
image: redis | |
ports: | |
- containerPort: 6379 | |
name: client | |
- containerPort: 16379 | |
name: gossip | |
command: ["redis-server"] | |
args: ["/conf/redis.conf"] | |
readinessProbe: | |
exec: | |
command: | |
- sh | |
- -c | |
- "redis-cli -h $(hostname) ping" | |
initialDelaySeconds: 15 | |
timeoutSeconds: 5 | |
livenessProbe: | |
exec: | |
command: | |
- sh | |
- -c | |
- "redis-cli -h $(hostname) ping" | |
initialDelaySeconds: 20 | |
periodSeconds: 3 | |
volumeMounts: | |
- name: conf | |
mountPath: /conf | |
readOnly: false | |
- name: data | |
mountPath: /data | |
readOnly: false | |
volumes: | |
- name: conf | |
configMap: | |
name: redis-cluster | |
items: | |
- key: redis.conf | |
path: redis.conf | |
volumeClaimTemplates: | |
- metadata: | |
name: data | |
labels: | |
name: redis-cluster | |
annotations: | |
volume.alpha.kubernetes.io/storage-class: anything | |
spec: | |
accessModes: [ "ReadWriteOnce" ] | |
resources: | |
requests: | |
storage: 100Mi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can set up the cluster using: