Created
March 12, 2021 02:25
-
-
Save richardjkendall/35d46d652b2d490eb43858386df2debe to your computer and use it in GitHub Desktop.
Create a simple redis kv store on K8s
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
To deploy this, put the files below in a directory and create a PV and PVC. | |
PVC should be called `redis-vol-claim` | |
Then in the directory containing the files run the following: | |
1. kubectl apply -k . | |
2. kubectl apply -f redis-service.yaml |
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
configMapGenerator: | |
- name: redis-config | |
files: | |
- redis-config | |
resources: | |
- redis-deployment.yaml |
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
requirepass **password** |
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: apps/v1 | |
kind: Deployment | |
metadata: | |
name: redis | |
spec: | |
selector: | |
matchLabels: | |
app: redis | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: redis | |
spec: | |
containers: | |
- name: redis | |
image: redis:5 | |
command: | |
- redis-server | |
- "/redis-master/redis.conf" | |
env: | |
- name: MASTER | |
value: "true" | |
ports: | |
- containerPort: 6379 | |
resources: | |
limits: | |
cpu: "0.25" | |
volumeMounts: | |
- mountPath: /data | |
name: data | |
- mountPath: /redis-master | |
name: config | |
volumes: | |
- name: data | |
persistentVolumeClaim: | |
claimName: redis-vol-claim | |
- name: config | |
configMap: | |
name: redis-config | |
items: | |
- key: redis-config | |
path: redis.conf |
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: Service | |
metadata: | |
name: redis-svc | |
labels: | |
app: redis | |
spec: | |
ports: | |
- port: 6379 | |
targetPort: 6379 | |
protocol: TCP | |
selector: | |
app: redis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment