4. Pods

Check ‘kuard-pod.yaml’ manifest which will run kuard application once it is imported to Kubernetes

$ tee files/kuard-pod.yaml << EOF
apiVersion: v1
kind: Pod
  name: kuard
    - image: gcr.io/kuar-demo/kuard-amd64:1
      name: kuard
        - containerPort: 8080
          name: http
          protocol: TCP

Start pod from the pod manifest via Kubernetes API (see the ‘ContainerCreating’ status)

$ kubectl apply --filename=files/kuard-pod.yaml; kubectl get pods
$ sleep 40

List pods (-o yaml will print all details)

$ kubectl get pods --namespace myns -o wide

Check pod details

$ kubectl describe pods kuard

Get IP for a kuard pod

$ kubectl get pods kuard -o jsonpath --template={.status.podIP}

Configure secure port-forwarding to access the specific pod exposed port using Kubernetes API Access the pod by opening the web browser with url: and{etc,var,home}

$ kubectl port-forward kuard 8080:8080 &

Stop port forwarding

$ pkill -f "kubectl port-forward kuard 8080:8080"

Get the logs from pod (-f for tail) (–previous will get logs from a previous instance of the container)

$ kubectl logs kuard

Copy files to/from containers running in the pod

$ kubectl cp --container=kuard /etc/os-release kuard:/tmp/

Run commands in your container with exec (-it for interactive session). Check if I am in container

$ kubectl exec kuard -- cat /etc/os-release

Delete pod - see the status ‘Terminating’

$ kubectl delete pods/kuard; kubectl get pods
$ sleep 30

Check pods - the kuard should disappear form the ‘pod list’

$ kubectl get pods