Kubernetes 101 : Kubectl basic commands
Kubectl command:
Checking the nodes in a cluster:
Deploying pods:
We can check the deployment status using:
To check out the newly deployed pods, we use:
The pod's mame is combination of the deployment_name and a random hash number.
The deployment component takes care of creating the pods.
Replicasets:
Replicasets are used to keep a number of pod replicas to guarantee availability of the applications.
To get the status of replicas, we use:
Changing the configuration of components:
We get an auto-generated file to which we can make the needed changes.
The old version of the pod terminates and a new one with the new configuration gets deployed.
We can use the "kubectl get pods"to check that.
We can use the "kubectl get pods"to check that.
Checking the logs:
We can check the logs using for debugging purposes:
Getting a shell-like access inside the application:
Deleting a kubernetes component:
To delete a component, for example a pod, we delete the deployment that we used to create it:
Remark:
We create, modify or delete resources at the deployment level, kubernetes takes care of the rest.
Creating components using a Yaml configuration file:
When the amount of options is too overwhelming to fit on the kubectl command line, we can use a Yaml configuration file to create the components. We them run the file using:
Example :
Below the Yaml file for the creation of five replicas of a Debian pod:
We check the creation of the pods using the "kubectl get pods" command.
To delete resources we use:
To delete resources we use:
Comments