Last active
August 17, 2018 10:11
-
-
Save shudipta/a4d011783d63f68367d89d4b7db74e96 to your computer and use it in GitHub Desktop.
redis-ha-sentinel
This file contains hidden or 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: Pod | |
metadata: | |
name: redis-master | |
labels: | |
app: sentinel | |
role: master | |
spec: | |
containers: | |
- name: redis-master | |
image: redis:4.0 | |
# env: | |
# - name: MASTER | |
# value: "true" | |
ports: | |
- containerPort: 6379 | |
protocol: TCP | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: redis-master | |
labels: | |
app: sentinel | |
role: master | |
spec: | |
type: ClusterIP | |
selector: | |
app: sentinel | |
role: master | |
ports: | |
- protocol: TCP | |
port: 6379 | |
targetPort: 6379 |
This file contains hidden or 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 | |
data: | |
sentinel-conf: | | |
port 5000 | |
# sentinel monitor mymaster 127.0.0.1 6379 2 | |
sentinel monitor mymaster redis-master 6379 2 | |
sentinel down-after-milliseconds mymaster 5000 | |
sentinel failover-timeout mymaster 60000 | |
sentinel parallel-syncs mymaster 1 | |
metadata: | |
name: s-5000 | |
labels: | |
app: sentinel | |
role: sentinel | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: s-5000 | |
labels: | |
app: sentinel | |
role: sentinel | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: sentinel | |
role: sentinel | |
template: | |
metadata: | |
labels: | |
app: sentinel | |
role: sentinel | |
spec: | |
initContainers: | |
- name: copy | |
image: busybox | |
command: ["cp", "/conf/sentinel.conf", "/redis/sentinel.conf"] | |
volumeMounts: | |
- mountPath: /redis | |
name: conf-dst | |
- mountPath: /conf | |
name: conf-src | |
containers: | |
- name: s-5002 | |
image: redis:4.0 | |
command: | |
- "redis-server" | |
- "/redis/sentinel.conf" | |
- "--sentinel" | |
ports: | |
- containerPort: 26379 | |
protocol: "TCP" | |
volumeMounts: | |
- mountPath: /redis | |
name: conf-dst | |
- mountPath: /conf | |
name: conf-src | |
volumes: | |
- name: conf-dst | |
emptyDir: {} | |
- name: conf-src | |
configMap: | |
name: s-5000 | |
items: | |
- key: sentinel-conf | |
path: sentinel.conf | |
defaultMode: 0777 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: sentinel | |
labels: | |
app: sentinel | |
role: sentinel | |
spec: | |
type: NodePort | |
selector: | |
app: sentinel | |
role: sentinel | |
ports: | |
- protocol: TCP | |
port: 26379 | |
nodePort: 30079 | |
targetPort: 26379 |
This file contains hidden or 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: Service | |
metadata: | |
name: redis-slave | |
labels: | |
app: sentinel | |
role: slave | |
spec: | |
ports: | |
- port: 6380 | |
targetPort: 6380 | |
protocol: "TCP" | |
clusterIP: None | |
selector: | |
app: sentinel | |
role: slave | |
--- | |
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: redis-slave | |
spec: | |
selector: | |
matchLabels: | |
app: sentinel # has to match .spec.template.metadata.labels | |
role: slave | |
serviceName: "redis-slave" | |
replicas: 1 # by default is 1 | |
template: | |
# name: redis-slave | |
metadata: | |
labels: | |
app: sentinel # has to match .spec.selector.matchLabels | |
role: slave | |
spec: | |
# terminationGracePeriodSeconds: 10 | |
containers: | |
- name: redis-slave | |
image: redis:4.0 | |
args: | |
- "--slaveof" | |
- "redis-master" | |
# - "172.17.0.8" | |
- "6379" | |
ports: | |
- containerPort: 6380 | |
protocol: "TCP" | |
volumeMounts: | |
- name: slave-storage | |
mountPath: /data | |
volumeClaimTemplates: | |
- metadata: | |
name: slave-storage | |
spec: | |
accessModes: [ "ReadWriteOnce" ] | |
storageClassName: "standard" | |
resources: | |
requests: | |
storage: 1Gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment