Kubernetes pod/deploy/sts/ds example
February 26, 2023

Deployment with PV emptyDir

Пример Deployment c emptyDir.

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cameda-nginx
  labels: 
    app: nginx-prod 
    environment: prod
  annotations:
    author: cameda
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  strategy: 
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        imagePullPolicy: IfNotPresent 
        resources:
          requests:
            cpu: 300m
            memory: 300Mi
          limits:
            memory: 400Mi
        ports:
        - containerPort: 80
        - containerPort: 443
        livenessProbe:
          failureThreshold: 10
          successThreshold: 1
          httpGet:
            path: /
            port: 80
          periodSeconds: 10
          timeoutSeconds: 1
          initialDelaySeconds: 5
        readinessProbe:
          failureThreshold: 3
          successThreshold: 1
          exec:
            command:
            - curl
            - http://127.0.0.1:80
          periodSeconds: 10
          timeoutSeconds: 1
          initialDelaySeconds: 7
        volumeMounts:
        - name: cam-volume
          mountPath: /mnt/cameda
      restartPolicy: Always
      tolerations:
      - key: "cam"
        operator: "Exists"
        effect: "NoSchedule"
      - key: "cam"
        operator: "Exists"
        effect: "NoExecute"
      volumes:
      - name: cam-volume
        emptyDir: {}
EOF