k8s部署单机redis pod
kind: ConfigMap
apiVersion: v1
metadata:
  name: redis
  namespace: default
  labels:
    app: redis
data:
  redis.conf: |-
    port 6379
    bind 0.0.0.0
    dir /data
    appendonly yes
    protected-mode no
    requirepass redis
    pidfile /data/redis-6379.pid
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  namespace: default
  labels:
    app: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - name: redis
          image: docker.io/redis:7.2.5
          command: ["bash", "-c", "redis-server /config/redis.conf & trap 'redis-cli shutdown && exit 0' SIGTERM; while true; do sleep 1; done"]
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          livenessProbe:
            tcpSocket:
              port: 6379
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            tcpSocket:
              port: 6379
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          volumeMounts:
            - name: data
              mountPath: /data
            - name: config
              mountPath: /config
      volumes:
        - name: data
          hostPath:
            path: /redisData
            type: DirectoryOrCreate
        - name: config
          configMap:
            name: redis

问题:删除pod耗时30s以上。
原因:redis-server不会响应kubelet发送的15信号,需要通过trap捕获信号后redis-cli shutdown退出。
 
                    
                     
                    
                 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号