1. Core Kubernetes Concepts

1.1 Pods

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

1.2 ReplicaSets

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

1.3 Deployments

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

2. Configuration

2.1 ConfigMaps

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

2.2 Secrets

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=

3. Multi-container Pods

3.1 Sidecar Pattern

The sidecar pattern involves adding a helper container to a pod to extend or enhance the main container.