Skip to content

Deployment

Overview

See the official documentation.

Operations

List the deployments

Current namespace:

kubectl get deployment

Specific namespace:

kubectl -n ${namespace} get deployment

All namespaces:

kubectl get -A deployment

Create a deployment

Current namespace:

kubectl apply -f ${file}

Specific namespace:

kubectl -n ${namespace} apply -f ${file}

Example deployment file (i.e. ${file}):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  labels:
    app: hello-world
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - image: registry.k8s.io/echoserver:latest
        name: hello-world
        ports:
        - containerPort: 8080
      restartPolicy: Always

Expose a deployment

See the Service documentation.