cat <<EOF | kubectl apply -f -
kind: ConfigMap
apiVersion: v1
metadata:
  name: redis-test-config
  namespace: basic-apps
  labels:
    app: redis-test
data:
  redis.conf: |-
    dir /data
    port 6379
    bind 0.0.0.0
    appendonly yes
    protected-mode no
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-test
  namespace: basic-apps
  labels:
    app: redis-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-test
  template:
    metadata:
      labels:
        app: redis-test
    spec:
      containers:
        - name: redis-test
          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: 100m
          volumeMounts:
            - name: config
              mountPath: /usr/local/etc/redis/redis.conf
              subPath: redis.conf
      volumes:
        - name: config
          configMap:
            name: redis-test-config
---
apiVersion: v1
kind: Service
metadata:
  name: redis-test
  namespace: basic-apps
  labels:
    app: redis-test
spec:
  type: ClusterIP
  ports:
    - name: redis-6379
      port: 6379
  selector:
    app: redis-test
EOF
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐