Skip to content

Kubernetes manifests ​

Encyclopedia home · Search machine-readable catalog

CF-021 ​

Dedicated staging namespace

Copy to namespace.yaml.

yaml
apiVersion: v1
kind: Namespace
metadata:
  name: staging
  labels:
    pod-security.kubernetes.io/enforce: restricted

Verification. Verify target cluster before application. Dependent Pods must comply with Pod Security.

Validation syntax-validated. Official reference

CF-022 ​

Minimal web deployment

Copy to deployment.yaml.

yaml
apiVersion: apps/v1
kind: Deployment
metadata: {name: web}
spec:
  replicas: 2
  selector: {matchLabels: {app: web}}
  template:
    metadata: {labels: {app: web}}
    spec:
      containers:
        - {name: web, image: "registry.example.com/lab/web:fixture", ports: [{containerPort: 8000}]}

Verification. Set the real digest and merge the restricted security context before applying in restricted namespaces.

Validation syntax-validated. Official reference

CF-023 ​

ClusterIP service

Copy to service.yaml.

yaml
apiVersion: v1
kind: Service
metadata: {name: web}
spec:
  selector: {app: web}
  ports: [{name: http, port: 80, targetPort: 8000}]

Verification. Verify endpoints are Ready and curl http://web/healthz from the same namespace.

Validation syntax-validated. Official reference

CF-024 ​

Readiness and memory budget

Copy to deployment container fragment.

yaml
readinessProbe:
  httpGet: {path: /healthz, port: 8000}
  periodSeconds: 5
resources:
  requests: {cpu: 100m, memory: 64Mi}
  limits: {cpu: "1", memory: 128Mi}

Verification. Tune using workload evidence. Check readiness and cgroups after applying.

Validation syntax-validated. Official reference

CF-025 ​

Namespace quota

Copy to quota.yaml.

yaml
apiVersion: v1
kind: ResourceQuota
metadata: {name: lab-budget}
spec:
  hard: {"requests.cpu":"2","requests.memory":"2Gi","limits.cpu":"4","limits.memory":"4Gi",pods:"12"}

Verification. Apply only to the intended namespace. Pod specs must satisfy required resource limits.

Validation syntax-validated. Official reference

CF-026 ​

Default resource limits

Copy to limits.yaml.

yaml
apiVersion: v1
kind: LimitRange
metadata: {name: container-defaults}
spec:
  limits:
    - type: Container
      default: {cpu: 500m, memory: 256Mi}
      defaultRequest: {cpu: 100m, memory: 128Mi}

Verification. Check admitted Pod values, especially when the Deployment omits explicitly configured resources.

Validation syntax-validated. Official reference

CF-027 ​

Pod security context

Copy to deployment Pod spec fragment.

yaml
securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  seccompProfile: {type: RuntimeDefault}

Verification. Also set allowPrivilegeEscalation false and drop ALL capabilities on each container.

Validation syntax-validated. Official reference

CF-028 ​

Restricted container context

Copy to deployment container fragment.

yaml
securityContext:
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities: {drop: [ALL]}

Verification. Test writable volume mounts for required paths before enabling.

Validation syntax-validated. Official reference

CF-029 ​

Ingress health route

Copy to ingress.yaml.

yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: {name: web}
spec:
  ingressClassName: nginx
  rules:
    - host: web.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend: {service: {name: web, port: {number: 80}}}

Verification. Use a tested controller class and configure TLS in the target environment.

Validation syntax-validated. Official reference

CF-030 ​

Deny ingress by default

Copy to deny-ingress.yaml.

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: deny-ingress}
spec:
  podSelector: {}
  policyTypes: [Ingress]

Verification. Require a policy enforcing CNI. Add explicit allowed routes before applying to active workloads.

Validation syntax-validated. Official reference

CF-031 ​

Permit traffic from test clients

Copy to allow-client.yaml.

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: web-client}
spec:
  podSelector: {matchLabels: {app: web}}
  policyTypes: [Ingress]
  ingress:
    - from: [{podSelector: {matchLabels: {role: smoke-client}}}]
      ports: [{protocol: TCP, port: 8000}]

Verification. Validate both allow and deny cases in the lab.

Validation syntax-validated. Official reference

CF-032 ​

Namespace-scoped rollout role

Copy to role.yaml.

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: {name: deploy-web}
rules:
  - apiGroups: [apps]
    resources: [deployments]
    resourceNames: [web]
    verbs: [get, patch, update]

Verification. Add a reviewed RoleBinding and determine separate watch access if rollout status needs it.

Validation syntax-validated. Official reference

CF-033 ​

Disable app API token mounts

Copy to serviceaccount.yaml.

yaml
apiVersion: v1
kind: ServiceAccount
metadata: {name: web}
automountServiceAccountToken: false

Verification. Set serviceAccountName: web in workloads needing no API access.

Validation syntax-validated. Official reference

CF-034 ​

CPU autoscaling

Copy to hpa.yaml.

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata: {name: web}
spec:
  scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: web}
  minReplicas: 2
  maxReplicas: 6
  metrics:
    - type: Resource
      resource: {name: cpu, target: {type: Utilization, averageUtilization: 70}}

Verification. Requires CPU requests and metrics. Verify under controlled load.

Validation syntax-validated. Official reference

CF-035 ​

Availability during voluntary evictions

Copy to pdb.yaml.

yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata: {name: web}
spec:
  minAvailable: 1
  selector: {matchLabels: {app: web}}

Verification. Verify disruption budgets before a lab node drain. This cannot prevent involuntary disruption.

Validation syntax-validated. Official reference