k8s部署单个redis

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: bcia
    ms-name: redis
  name: bcia-redis
  namespace: bcia
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bcia
      ms-name: redis
  template:
    metadata:
      labels:
        app: bcia
        ms-name: redis
      name: bcia-redis
    spec:
     containers:
     - name: bcia-redis
       image: redis:v5.0.5
       volumeMounts:
       - name: redis-data
         mountPath: "/data"
       - name: redis-config
         mountPath: "/usr/local/etc"
       command:
         - "redis-server"
       args:
         - "/usr/local/etc/redis.conf"
     volumes:
     - name: redis-data
       nfs:
         path: /redis/data
         server: uat-n2
     - name: redis-config
       nfs:
         path: /redis/config
         server: uat-n2

---
apiVersion: v1
kind: Service
metadata:
  name: bcia-redis-svc
  namespace: bcia
  labels:
    app: bcia
    ms-name: redis
spec:
  selector:
    app: bcia
    ms-name: redis
  type: NodePort
  ports:
  - port: 6379
    targetPort: 6379
    nodePort: 30379


配置文件内容:

[root@uat-n2 config]# cat redis.conf
requirepass 123
bind 0.0.0.0
save 900 1
save 300 10
save 60 10000

你可能感兴趣的:(Linux,k8s)