Remember, kubectl contacts with apis of nodes and controls the nodes. The way it does is that, it has a config file where it keeps all of the IP address of the APIs.
- Firstly, we will now see our nodes using
kubectl get node
If it responses, it means that your command line is working and you are getting back data.
You can even use
kubectl get nodes
or,
kubectl get no
if you wish.
You can even get the node information in a brief or wide format with more informations
kubectl get nodes -o wide
We can also check this information in yaml
It shows all of the information!!!!!!!!
- We will use describe command to see more informations about a node
kubectl describe node <node>
Don't copy the command. First use
kubectl get node
and copy the node name you get and then use it instead if
- Let's check resources we have
kubectl api-resources
You can see the node has a kind "no"
Remember, we could use
kubectl get no
instead of
kubectl get node
SO, this is how this resources will help you understand short formats too.
Now , we can know much more of a particular resource using this command:
kubectl explain <type>
instead of type, we can take "node" for an example:
if we want to check the spec, we can type
kubectl explain node.spec
to get the list of all fields and sub-fields:
kubectl explain node --recursive
This command basically shows in a list format.
Some resources names to be clear about:
Note: You can use kubectl api-resources and explain to see the details of resources or check from the official documentation
But , you should be able to do both
- Lets check out services(A service is a stable endpoint to connect to "something")
kubectl get services
or use,
kubectl get svc
Lets check out the pods:
kubectl get pods
Ahha!!!!!!! NO pods. Isn't it obvious? Have we created any containers or pods yet?
NO!!
So, how can we expect to have pods?
But, what is "default namespace" ???
Actually the commands we are using by now, use "namespace" to filter certain things. Like there are pods we did not create yet but we could not see them while using "kubectl get pods" because namespace filtered it for us.
Lets check what this namespace has got
You know what ... This kube-system thing looks suspicious.
In fact, I'm pretty sure it showed up earlier, when we did:
kubectl describe node <node-name>
So, we have pods actually.
Lets check more ..what is inside the namespace.
kubectl get pods --all-namespaces
or,
kubectl get pods -A
This output is a bit different than the "kubernetes get namespace", right?
now we can see status and many more here.
You can see the coredns, node, controller etc
SO, these are basically the control plane pods . To know more about them, you can check out this image:
Note: Till now we checked out "default" namespaces. we can change it to any particular namespace. To list only the pods in the kube-system namespace
kubectl get pods --namespace=kube-system
kubectl get pods -n kube-system
Here, -n is used to mean namespace.
More to know:
Some other basics:
kube-public: Used for installation and then connecting to something.
Lets check what is inside of it
kubectl -n kube-public get pods
There is nothing, right? So, what is this for? Actually this helps in configuring.It basically gives us interesting information of how to connect.
Let's check the config file:
kubectl -n kube-public get configmaps
We can check out any of them using "file name -o yaml" adding at the end of the previous command. Here -o is to show output
Top comments (0)