Node is a worker point in Kubernetes, previously called minion. Actually, Node is in the form of Virtual Machine or Physical Machine (Bare Metal), but there is additional management by Kubernetes.
Like the previous material, nodes already have kubelet, kube-proxy, and container-manager. You can see the picture below :
Well, as explained earlier, there is no need to know where Kubernetes places the node, because it is already the task of Kubernetes, only need to determine how many nodes are working on Kubernetes. If for example 2 nodes have been run, it turns out to be almost full or high traffic, then simply add a node without having to bother with manual settings.
To see the nodes that have been added to minukube Type the following command after starting Minikube :
For details, just type the command:
Replace (nodename) with the existing node name without any brackets.
And then it will outputed like this :
Pod is the smallest unit that can be deployed in Kubernetes Cluster. Similar to deploying an application in Docker that is placed in a Container, the difference is deploying in Kubernetes will be deployed into a Pod, why is that? because in Kubernetes Pod can be filled with 1 or more containers. Yes, simply put, Pod contains applications that are run in Kubernetes Cluster.
The picture is like this :
As seen in the picture in Pod can be 2 containers. Kubernetes uses a different layer called pod to run 2 or more containers directly.
How to view all Pods :
To view Pod details:
Replace (podname) with the existing node name without any brackets.
So, it will outputed like this :
Yeah, because i didn't make Pod it will outputed No resources found in default namespace.
To create a pod, make sure you do it in the following steps:
Creating a Configuration File
The first step to take to create a Pod is to use a yaml file, as below:
4.2.2.1-template-pod.yaml
With the explanation below:
For example, here we will try with the nginx application, a lightweight web service application that runs on port 80.
4.2.2.2-nginx-pod.yaml
Create a Pod with the .yaml file that has been created
After creating the .yaml file, run it in the terminal with the command as below :
Replace (podfile) with the existing node name without any brackets.
If you use a file created like the example, it will look like this :
So it produces the output :
Check the installed Pod
Just like before to check the list of installed pods, use the command :
So it will produce output :
If you see, in that example Pod status is creating just wait and BOOM, like this :
You can also get more details from the pod list with the command :
So it will produce output :
And, for details of a single pod, you can type in the command :
Replace (podname) with the existing node name without any brackets.
And the example this :
And it will outputed like this :
Yeah, its full of description and info that need it.
In certain cases, it is necessary to check whether the pod is running properly or not. To check the Pod, use the access method with the command:
Replace podname, portaccess, and podport with the existing node names without brackets. portaccess is the port that will be accessed through your device, podport is the port running in the Container according to the configuration
For example, to access a previously created port :
It will outputed like this :
And if you check use cat command ($ curl 127.0.0.1:8888
) it wil outputed nginx hello like this :
**
For certain cases, sometimes it is necessary to delete Pods, the way to delete Pods can use the following method:
or
if there are many pods to delete, or
If based on a specific label key, and finally, if you want to delete what is based on namespace, you can use :
Just adjust it for what kind of use. Here's some example :
and the nginx-pod will deleted :
Labels in Kubernetes are useful for marking Pods, so that Pods will be organized, Pods will also be clearer because there is additional information in the Pod Label.
Labels are also not only for Pods, but all resources in Kubernetes, such as Replication Controllers, Replica Sets, Services, etc.
Here is an example of a Pod template with labels :
4.3.1-template-pod-label.yaml
Actually it's the same, but the only difference is that there are additional labels, and here we will use nginx as before :
4.3.2-nginx-pod-labeled.yaml
Here to write free labels as needed and as efficient as possible.
To insert Pods is the same as before:
Make sure the metadata name is different from the previously created Pod, or differentiate the Pod metadata name in the yaml so that it can be added.
If happen like this :
Error from server (AlreadyExists): error when creating "4.3.2-nginx-pod-labeled.yaml": pods "nginx-pod" already exists
You must delete the same Pod or use diffrent name in yaml configuration file
To see previously created labels, use the command:
Sehingga akan beroutput :
You can also use descibe :
And the output, it will diffrent :
It is also possible to add or change labels in Pods directly, but this is not recommended. Here is the command to add:
Meanwhile, to change, here is the command:
Here's a quick example, to add a flag:
And an example of a command to change it:
And the output :
As you can see, the label is change, as the command .
Maybe you are thinking right now whether the label is just like that? Of course not, the labels that we have written or added can be searched, this is for ease of searching among other pods, here's how:
Example for searching labels:
Annotation is similar to Label, only cannot be filtered or queried like label, usually used to add additional information in large sizes, only holds information up to 256kB.
Annotation because of its small memory is usually only for adding information, such as Documentation, Description, etc.
Here is an example of an Annotation template on Kubernetes:
4.4.1-template-pod-annotation.yaml
The only difference is that annotations are added, here is an example:
4.4.2-nginx-pod-annotation.yaml
To see it, run as before:
Ganti podname dengan nama node yang ada tanpa ada tanda kurung.
Lets try :
Then it will come out like this:
You can also add annotations directly, same like label, use with this command:
and to change with this command:
Namespaces in Kubernetes are a way to share cluster resources between multiple users, teams, or projects. So the case of having the same resources can be resolved.
When to Use Namespaces?
To see the namespace use this command:
or
or
Then it will come out with the output:
As an example, we will try to see the Namespace on the Pod :
or
Replace namespacename with the name of the namespace you want to search for without the brackets.
Direct example of the code :
default in namespace is the basic value if the value is not specified by the user
Then it will produce the output:
To create a namespace on Kubernetes, here is a template for a namespace:
4.5.1-template-namespace.yaml
For Example :
4.5.2-finance-namespace.yaml
To enter namespace yaml into Kubernetes use the usual command :
Replace (file.yaml) with the name of the namespace you want to search for without the brackets.
For Example :
To create a Pod in a Namespace, you can do the following:
Replace (yamlpod.yaml), (namespacename) with the name of the namespace you want to search for without the brackets.
For Example :
If you search without namespace name, it will outputed like this :
Because nginx-pod in finance namespace :
And done, nginx-pod in finance namespace.
Things to note about namespaces:
Unfortunately, if you already have a Pod and want to put it in a namespace, you can't do it directly, you have to delete the Pod or directly add a new one.
Deleting a Namespace
Replace namespacename with the name of the namespace you want to search for without the brackets.