Skip to content

Instantly share code, notes, and snippets.

@richardjkendall
Created March 12, 2021 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardjkendall/35d46d652b2d490eb43858386df2debe to your computer and use it in GitHub Desktop.
Save richardjkendall/35d46d652b2d490eb43858386df2debe to your computer and use it in GitHub Desktop.
Create a simple redis kv store on K8s
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
configMapGenerator:
- name: redis-config
files:
- redis-config
resources:
- redis-deployment.yaml
requirepass **password**
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
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