# Teaching manifest. Review image provenance and policies for your environment.
# Apply deliberately: kubectl apply -f workload.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: academy-demo
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: academy-demo
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      automountServiceAccountToken: false
      securityContext:
        runAsNonRoot: true
        runAsUser: 101
        runAsGroup: 101
        fsGroup: 101
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: nginx
          image: nginxinc/nginx-unprivileged:1.28-alpine
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 50m
              memory: 32Mi
            limits:
              cpu: 250m
              memory: 128Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: [ALL]
          volumeMounts:
            - name: temporary
              mountPath: /tmp
          readinessProbe:
            httpGet:
              path: /
              port: 8080
            initialDelaySeconds: 3
            periodSeconds: 5
          livenessProbe:
            httpGet:
              path: /
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 10
      volumes:
        - name: temporary
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: academy-demo
spec:
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
  type: ClusterIP
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: web
  namespace: academy-demo
spec:
  minAvailable: 2
  selector:
    matchLabels:
      app: web
