Interacting with running Pods

  • Viewing Logs of a Pod: The command shows the logs of the pod mentioned once the pod started.
$ kubectl logs [pod-name]

 

  • Get an Interactive terminal for a pod: The command starts an interactive terminal of the Nginx pod so that we can control the pod directly through its terminal.
$ kubectl exec -it [pod-name] -- bin/bash

 

  • Get info about a Resource: The command gives details about the nginx deployment
$ kubectl describe <resource_type> [resource-name]

 

Kubernetes – Kubectl Commands

Pre-requisites: Kubernetes 

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. Some basic Kubectl commands in a Kubernetes cluster are as follows:

Similar Reads

kubectl Commands

The most popular kubectl commands and flags are listed below....

Kubectl apply

We can update or apply the configuration to a cluster with the aid of “kubectl apply”. With the help of the apply command, Kubernetes resources can be modified and created using a configuration file or a collection of configurations from a directory....

Viewing and Finding Resources

These commands are used to show all the resources. It works like a READ operation. It is used to view resources like nodes, deployments, services, config maps, etc....

Creating Resources

These commands are used to create resources like deployments, services, secrets, config maps, etc....

Editing Resources

After running the command below you can update the resource configuration file and if there are any changes the resource will be updated according to it....

Deleting Resources

These commands are used to delete resources like deployments, services, config maps, pods, secrets, etc. You can choose a particular resource name of a resource type or you can also delete all resources of a resource type by specifying –all flag...

Using Configuration File for CRUD

These commands are used to use YAML configuration files for CRUD operations in a cluster....

Interacting with running Pods

Viewing Logs of a Pod: The command shows the logs of the pod mentioned once the pod started....

Copying Files and Directories to and from Containers

With the help of the “kubectl cp” command, we can copy files from host to container and vice versa....

Updating Resources

The “kubectl get rs” command allows us to check the list of deployments, To update them, look up the revision history of prior deployments, and roll back to a specific revision if necessary. Using the following commands....