Pods are the smallest deployable units in Kubernetes. They can contain one or more containers that share network and storage resources.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: nginx:latest
ReplicaSets ensure a specified number of pod replicas are running at any given time.
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-replicaset
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: nginx:latest
Deployments provide declarative updates for Pods and ReplicaSets. They manage the rollout of new versions of your application.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: nginx:latest
ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable.
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
data:
APP_COLOR: blue
APP_MODE: prod
Secrets are used to store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.
apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
data:
username: dXNlcm5hbWU=
password: cGFzc3dvcmQ=
The sidecar pattern involves adding a helper container to a pod to extend or enhance the main container.