kubectl get all -A -o wide
kubectl get nodes [node-name] [-o wide]
kubectl describe nodes [node-name]

Namespace anlegen

Namespace mit Namen demo anlegen

kubectl create namespace demo

Namespace demo als aktuellen context festlegen

kubectl set-context --current --namespace=demo

Pod mit nginx starten und Port 80 freigeben

kubectl run web --image nginx --labels app=web --expose --port 80

Zweiten Pod mit alpine-Linux interaktiv starten, curl installieren und web-Pod (nginx) aufrufen

kubectl run test --rm --ti --image alpine -- /bin/sh
apk add curl
curl web
...
<h1>Welcome to nginx!</h1>
...

In einer anderen Console alles im Namespace demo auflisten

kubectl get all                                                                                       
NAME       READY   STATUS    RESTARTS   AGE
pod/test   1/1     Running   0          10s
pod/web    1/1     Running   0          26m

NAME          TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/web   ClusterIP   10.96.247.18   <none>        80/TCP    26m

Webapp als yaml ausgeben

kubectl run web --image nginx --labels app=web --expose --port 80 --dry-run=client --output=yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: web
status:
  loadBalancer: {}
---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web
spec:
  containers:
  - image: nginx
    name: web
    ports:
    - containerPort: 80
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}