Link Search Menu Expand Document

Deployment

init-container-msg.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: init-container-msg-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: init-container-msg-app
  template:
    metadata:
      labels:
        app: init-container-msg-app
    spec:
      initContainers:
        - command:
            - "/bin/sh"
            - "-c"
            - "echo 'message from init' > /init-container-msg-mount-path/this"
          image: busybox
          name: init-container-msg-container-init
          volumeMounts:
            - mountPath: /init-container-msg-mount-path
              name: init-container-msg-volume
      containers:
        - command:
            - "/bin/sh"
            - "-c"
            - "while true; do cat /init-container-msg-mount-path/this; sleep 5; done"
          image: busybox
          name: init-container-msg-container-main
          volumeMounts:
            - mountPath: /init-container-msg-mount-path
              name: init-container-msg-volume
      volumes:
        - emptyDir: {}
          name: init-container-msg-volume

simple-deployment-privileged.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployments-simple-deployment-privileged-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deployments-simple-deployment-privileged-app
  template:
    metadata:
      labels:
        app: deployments-simple-deployment-privileged-app
    spec:
      containers:
        - name: busybox
          image: busybox
          command:
            - /bin/sh
            - -c
            #- export A=$(echo $POD_IP | tr '.' '-' | sed 's/$/.q-connector.pod.cluster.local/g') && echo ${A}
            - sleep 3600
          #securityContext:
          #  capabilities:
          #    add:
          #      - CAP_SYS_ADMIN

simple-deployment-with-environment.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployments-simple-deployment-with-environment-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deployments-simple-deployment-with-environment-app
  template:
    metadata:
      labels:
        app: deployments-simple-deployment-with-environment-app
    spec:
      containers:
        - name: busybox
          image: busybox
          command:
            - sleep
            - "3600"
          env:
            # Plain Text ENV
            - name: DEMO_GREETING
              value: "Hello from the environment"
            # Load from a secret
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: database_secrets
                  key: password
            # Load from a configMap
            - name: KAFKA_TOPIC
              valueFrom:
                configMapKeyRef:
                  name: kafka_config_map
                  key: topic

simple-deployment.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployments-simple-deployment-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: deployments-simple-deployment-app
  template:
    metadata:
      labels:
        app: deployments-simple-deployment-app
    spec:
      containers:
        - name: busybox
          image: busybox
          command:
            - sleep
            - "3600"

webserver.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webserver-simple-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: webserver-simple-app
  template:
    metadata:
      labels:
        app: webserver-simple-app
    spec:
      containers:
        - name: webserver-simple-container
          image: python:3
          command:
            - python
            - -m
            - http.server
          ports:
            - containerPort: 8000
---
# https://kubernetes.io/docs/concepts/services-networking/service/
apiVersion: v1
kind: Service
metadata:
  name: webserver-simple-service
spec:
  selector:
    app: webserver-simple-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8000