A Kubernetes resource is an API-managed object created in a cluster to express part of an application's desired deployment state. Resources are declared in YAML manifests and created or updated by applying those manifests with kubectl. section 3.3.3
A containerized application exposed outside a cluster commonly needs these resources:
- Deployment — manages the lifecycle of a stateless replicated application; each replica is a Pod representing the application container. section 3.3.3
- Service — makes a Deployment reachable for network calls, usually within the cluster. section 3.3.3
- Ingress — makes a Service reachable from outside the cluster. section 3.3.3
- ConfigMap or Secret — can supply application properties or credentials. Secret data is usually Base64-encoded, which is not encryption. section 3.3.3
Resources make deployment declarative, but they add work to the local development loop. After a code change, developers typically build an image, load it into the local cluster, update manifests, and apply them to create or update resources. This can slow feedback and shift attention away from application logic. section 3.3.2
Appointments application deployment
An Appointments service can use a Deployment manifest with labels, a container image, and environment values read from a database Secret. A PostgreSQL database can itself be provisioned as a Cluster resource through the CloudNativePG operator; the application resources can then be applied from a configuration directory. section 3.3.3
Listing 3.1 Deployment configuration for a cloud native application.
apiVersion: apps/v1
kind: Deployment
metadata:
name: appointments #A
labels:
app: appointments
spec:
selector:
matchLabels:
app: appointments
template:
metadata:
labels:
app: appointments
spec:
containers:
- name: appointments #B
image: ko.local/appointments:0.0.1-SNAPSHOT #C
env: #D
- name: POSTGRES_HOST
valueFrom:
secretKeyRef:
name: db-appointments-app
key: host
- name: POSTGRES_PORT
valueFrom:
secretKeyRef:
name: db-appointments-app
key: port
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: db-appointments-app
key: dbname
- name: POSTGRES_USERNAME
valueFrom:
secretKeyRef:
name: db-appointments-app
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: db-appointments-app
key: password
...
Inspect the Deployment manifest to see an API version, resource kind, metadata, pod template, container image, and Secret-backed environment configuration in one resource definition. section 3.3.3





