A Kubernetes resource is a named object used to deploy or manage something in a cluster. For a containerized API, a Pod holds the application container; a ReplicaSet maintains a specified number of Pods; and a Deployment manages the ReplicaSet and application updates. Defining these objects in YAML makes the deployment repeatable. section 3.3.3
Read a workload manifest from its top-level fields:
- apiVersion identifies the resource API; kind selects the object type, such as Pod or Deployment. section 3.3.3
- metadata names the object and can hold labels. Labels let other resources select the intended Pods. section 3.3.3
- spec describes the workload: a Pod specifies containers and images; a ReplicaSet or Deployment also specifies a Pod template, replica count, and label selector. section 3.3.3
Listing 3.6 deployment.yaml: creating a deployment
apiVersion: apps/v1 #1
kind: Deployment #2
metadata:
name: joker-deployment #3
labels:
app: fast-api
spec:
template: #4
metadata:
name: joker
labels:
app: fast-api
spec:
containers:
- name: hello-joker
image: varunmallya/hello-joker:v1
ports:
- containerPort: 8083
replicas: 3
selector:
matchLabels:
app: fast-api
This Deployment manifest ties three replicas to a Pod template through matching labels. Its container image can be changed and the manifest applied again to initiate an update. section 3.3.3
Apply, inspect, and recover
Create a resource with `kubectl create -f deployment.yaml`; use `kubectl get deployments` to check availability. After changing the image, run `kubectl apply -f deployment.yaml` and inspect rollout events with `kubectl describe deployment joker-deployment`. If the update fails, `kubectl rollout undo deployment/joker-deployment` reverts it. For a Pod reporting `ErrImagePull`, inspect it with `kubectl describe pod joker`; use `kubectl logs joker` to check application output. section 3.3.3
Resources also organize and configure the application. A Namespace scopes resource names; resources without an explicit namespace go into `default`. Set `metadata.namespace` to place a Deployment or Service elsewhere, and use `kubectl get pod -n funny` to inspect that namespace. ConfigMaps hold configuration data, while Secret manifests hold base64-encoded data that can be retrieved and decoded. These are additional resource kinds, not fields of the Deployment. section 3.3.5




