97 lines
2.3 KiB
YAML
97 lines
2.3 KiB
YAML
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: redis-svc
|
|
namespace: redis
|
|
labels:
|
|
app: redis
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- name: redis
|
|
port: 6379
|
|
selector:
|
|
app: redis
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: redis-dep
|
|
namespace: redis
|
|
labels:
|
|
app: redis
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: redis
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: redis
|
|
spec:
|
|
# 进行初始化操作,修改系统配置,解决 Redis 启动时提示的警告信息
|
|
initContainers:
|
|
- name: system-init
|
|
image: busybox:1.32
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- "sh"
|
|
- "-c"
|
|
- "echo 2048 > /proc/sys/net/core/somaxconn && echo never > /sys/kernel/mm/transparent_hugepage/enabled"
|
|
securityContext:
|
|
privileged: true
|
|
runAsUser: 0
|
|
volumeMounts:
|
|
- name: sys
|
|
mountPath: /sys
|
|
containers:
|
|
- name: redis
|
|
image: redis:5.0.8
|
|
command:
|
|
- "sh"
|
|
- "-c"
|
|
- "redis-server /usr/local/etc/redis/redis.conf"
|
|
ports:
|
|
- containerPort: 6379
|
|
resources:
|
|
limits:
|
|
cpu: 1000m
|
|
memory: 1024Mi
|
|
requests:
|
|
cpu: 1000m
|
|
memory: 1024Mi
|
|
livenessProbe:
|
|
tcpSocket:
|
|
port: 6379
|
|
initialDelaySeconds: 300
|
|
timeoutSeconds: 1
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
tcpSocket:
|
|
port: 6379
|
|
initialDelaySeconds: 5
|
|
timeoutSeconds: 1
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
failureThreshold: 3
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /data
|
|
- name: config
|
|
mountPath: /usr/local/etc/redis/redis.conf
|
|
subPath: redis.conf
|
|
volumes:
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: redis-pvc
|
|
- name: config
|
|
configMap:
|
|
name: redis-config
|
|
- name: sys
|
|
hostPath:
|
|
path: /sys
|