Explore Your App
Pods, Nodes, Kubectl main commands
Kubernetes Pods
pod: a Kubernetes abstraction that represents one or more application containers (e.g. Docker or rkt) and some shared resources for those containers
hosts your application instance
Resources include:
shared storage, as Volumes
networking, as a unique cluster IP address
information about how to run each container (e.g. the container image version or specific ports to use)
a Pod models an application-specific "logical host"
logical host: a logical server environment that acts as the execution environment
can contain different application containers that are tightly coupled
e.g. it might include a container with your Node.js app and a different container that feeds the data to be published by the Node.js webserver
the containers in a Pod share an IP Address and port
spacecontainers are co-located and co-scheduled
run in a shared context on the same Node
pods are the atomic unit on Kubernetes
a Deployment on Kubernetes creates Pods with containers inside them (as opposed to creating containers directly)
each Pod is tied to the Nod where it is scheduled
remains there until termination or deletion
if a Node fails, identical Pods are scheduled on other available Nodes in the cluster
Nodes
a Pod always runs on a Node
node: a worker machine in Kubernetes that can be a virtual or physical machine, depending on the cluster
nodes are managed by the Master
can have multiple pods
Kubernetes master automatically handles scheduling pods across Nodes in the cluster
the Master's automatic scheduling takes into account the available resources on each Node
each k8s Node runs at least:
Kubelet: a process responsible for communication between the Master and the Node
manages the Pods and the containers running on a machine
a container runtime (e.g. Docker, rkt) that pulls the container image from a registry, unpacks the container, and runs the application
Troubleshooting with kubectl
the following are common operations that can be done with kubectl:
kubectl get
- list resourceskubectl describe
- show detailed information about a resourcekubectl logs
- print the logs from a container in a podkubectl exec
- execute a command from a container in a pod
you can use these commands to see when applications were deployed, what their current statuses are, where they are running and what their configurations are
Check application configuration
kubectl get pods
- look for existing pods
if no pods are running, it means the interactive environment is still reloading its previous state
wait a few seconds and list the Pods again
kubectl describe pods
- view what containers are inside the Pod and what images are used to build the containers
you can see details about the Pod's container:
IP addres
ports used
list of events related to the life cycle of the pod
Note: the describe command can be used to get detailed information about most of the kubernetes primitives: node, pods, deployments. The describe output is designed to be human readable, not to be scripted against.
Show the app in the terminal
pods run in an isolated, private network so you need proxy access to debug and interact with them
use the
kubectl proxy
command to run a proxy in a second terminal window
kubectl proxy
- run the proxy
again, we need to get the Pod name and query the pod through the proxy
export POD_NAME=$(kubectl get pods -o go-template --template '')
echo Name of the Pod: $POD_NAME
to see the output of the application, you can use
curl
curl
Last updated