Nginx workload manifests
Nginx as an application, not a controller
A Deployment maintains a desired number of interchangeable Nginx Pods. The Service provides a stable network entry while the backing Pods change. This chapter runs ordinary Nginx: it never watches Ingress resources and does not need Kubernetes API credentials. A controller is a different workload that observes API objects and reconciles traffic configuration. The lab serves a tiny catalog marker on port 8080; a ClusterIP Service exposes port 80 inside the cluster.
apiVersion: v1kind: Servicemetadata: name: catalogspec: type: ClusterIP selector: app: bm-catalog ports: - port: 80 targetPort: httpFollow the Service to a Pod
The Service selector matches Pod labels, not the Deployment name. Its named targetPort must match a container port declaration. That declaration is metadata; Nginx still needs listen 8080 to actually open the socket. In the same namespace a client can usually use catalog; from another namespace catalog.bm-nginx49 is a convenient DNS name. Cluster DNS suffixes can vary. A regular Service typically resolves to a virtual IP, whereas a headless Service exposes endpoint records. ClusterIP is not a security boundary: network policy and application authorization remain necessary.
server { listen 8080; location = / { return 200 "catalog-v1\n"; }}Run with least privilege
The Pod specifies a nonroot UID/GID, drops capabilities, uses the default seccomp profile, disables privilege escalation and does not mount a service-account token. The high port avoids depending on privileged bind behavior. The root filesystem and config are read-only; a size-limited emptyDir at /tmp provides writable PID and temporary directories. fsGroup requests compatible volume group permissions, not ownership of all image files. Validate the selected image can run as UID 101 and write the mounted path. Requests inform scheduling, CPU limits can throttle work and memory limits may lead to OOM termination. Values in this lab are examples, not measured capacity.
securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALLresources: requests: cpu: 50m memory: 32Mi ephemeral-storage: 16Mi limits: cpu: 250m memory: 96Mi ephemeral-storage: 64MiVerify each boundary separately
Only use an approved disposable cluster and a reviewed, preloaded image digest. The complete lab manifest contains the volume definitions, matching labels, two replicas and private Service. First validate manifest shape and admission in that cluster, then check Pods and EndpointSlices, then verify the HTTP body. Port forwarding selects a Pod and does not prove that the Service data plane load balances. Use a separate approved in-cluster client for that check. No public LoadBalancer is needed.
kubectl --context "$LAB_CONTEXT" -n bm-nginx49 get deploy,pods,svckubectl --context "$LAB_CONTEXT" -n bm-nginx49 get endpointslices -l kubernetes.io/service-name=catalogUse the Chapter 49 manual practice and lab. Configuration and manifest snippets are illustrative. Kubernetes execution and image compatibility have not been verified; no cluster is required for offline study.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Nginx workload manifests
Assess decisions from the lesson and original lab.
What selects the Pods for a Service?
What opens port 8080 in the container?
Why mount emptyDir at /tmp?
Does ordinary Nginx need a Kubernetes API token in this lab?
What does a successful port-forward test establish?