apiVersion: apps/v1 kind: StatefulSet metadata: name: redis spec: serviceName: redis replicas: 1 selector: matchLabels: app: redis template: metadata: labels: app: redis spec: containers: - name: redis image: redis:alpine ports: - containerPort: 6379 name: client securityContext: readOnlyRootFilesystem: true runAsNonRoot: true runAsUser: 999 command: ["redis-server", "--save", "", "--requirepass", "$(REDIS_PASSWORD)"] env: - name: REDIS_PASSWORD valueFrom: secretKeyRef: name: redis-secrets key: REDIS_PASSWORD - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP --- apiVersion: v1 kind: Service metadata: name: redis spec: type: ClusterIP ports: - port: 6379 targetPort: 6379 name: client selector: app: redis