Commands and Namespaces
Lab Objectives
This lab has you run a few different commands to familiarize yourself with kubectl
.
Lab Structure - Overview
- List Kubernetes Pods and Nodes
- List Kubernetes Services and Namespaces
- Look at Kubernetes components
Execute on the Leader node
The following commands should all be executed in the VS Code window connected to the leader node.
List Pods and Nodes
- Enter the following to list Pods in the
default
namespacekubectl get pods
NOTE: This will return ‘no resources found’
- List Pods in all namespaces.
kubectl get pods --all-namespaces
- List nodes
kubectl get nodes
- List nodes and additional information (labels, name, IP etc.)
kubectl get nodes -o wide
List Services and Namespaces
- List Services in
default
namespacekubectl get services
- List Services in all namespaces.
kubectl get services --all-namespaces
PROTIP: substitute
svc
forservices
- List Namespaces
kubectl get namespaces
- Create a new Namespace.. Use
kubectl create --help
if you get stuck.
Explore Kubernetes
Using kubectl
interact with the Kubernetes cluster.
- Look at documentation
kubectl --help
- Retrieve information about Kubernetes resources
kubectl get <random resources>
- Look at node details
kubectl describe node <node from cluster>
- Look at Pod details
kubectl describe pod -n kube-system coredns
- Check out service details
kubectl describe svc kubernetes
- Look at deployment details
kubectl describe deployment -n kube-system coredns
Now you should have a better understanding of Kubernetes resources and using the kubectl
client.