Uncategorized

Kubernetes Ctrl Commands

Spread the love

kubectl commands list :

Use the following syntax to run kubectl commands from your terminal window:

kubectl [command] [TYPE] [NAME] [flags] where command, TYPE, NAME, and flags are:

** command: Specifies the operation that you want to perform on one or more resources, for example create, get, describe, delete.

** TYPE: Specifies the resource type. Resource types are case-insensitive and you can specify the singular, plural, or abbreviated forms. For example, the following commands produce the same output:
       kubectl get pod pod1
       kubectl get pods pod1
       kubectl get po pod1

** NAME: Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.
   To specify resources by type and name:
   To group resources if they are all the same type: TYPE1 name1 name2 name<#>
   Example: kubectl get pod example-pod1 example-pod2
   To specify multiple resource types individually: TYPE1/name1 TYPE1/name2 TYPE2/name3 TYPE<#>/name<#>.
   Example: kubectl get pod/example-pod1 replicationcontroller/example-rc1

**flags: Specifies optional flags. For example, you can use the -s or --server flags to specify the address and port of the Kubernetes API server.


         ( If you need help, just run kubectl help from the terminal window.)
  • Kubectl controls the Kubernetes Cluster. It is one of the key components of Kubernetes which runs on the workstation on any machine when the setup is done.
    It has the capability to manage the nodes in the cluster.
  • kubectl api-version; = It prints the supported versions of API on the cluster.
  • kubectl wait = Wait for a specific condition on one or many resources.
  • kubectl version = Display the Kubernetes version running on the client and server
  • kubectl uncordon NODE = Mark node as schedulable.
  • kubectl top = Display Resource (CPU/Memory/Storage) usage.
  • kubectl taint NODE NAME = Update the taints on one or more nodes.
  • kubectl set SUBCOMMAND = Configure application resources.
  • kubectl scale = Update the size of the specified replication controller
  • kubectl run NAME = Run a specified image on the cluster
  • kubectl rollout SUBCOMMAND =Manage the rollout of a resource. Valid resource types include: deployments, daemonsets and statefulsets.
  • kubectl replace -f FILENAME = Replace a resource from a file or stdin.
  • kubectl proxy [–port=PORT] = Run a proxy to the Kubernetes API server.
  • kubectl port-forward POD = Forward one or more local ports to a pod.
  • kubectl plugin = Provides utilities for interacting with plugins
  • kubectl patch (-f FILENAME | TYPE NAME | TYPE/NAME) –patch PATCH [flags] = Update one or more fields of a resource by using the strategic merge patch process
  • kubectl options = List of global command-line options, which apply to all commands.
  • kubectl logs POD = Print the logs for a container in a pod.
  • kubectl label = Add or update the labels of one or more resources
  • kubectl kustomize [flags] [options] = List a set of API resources generated from instructions in a kustomization.yaml file.
  • kubectl get = List one or more resources.
  • kubectl expose = Expose a replication controller, service, or pod as a new Kubernetes service
  • kubectl explain [–recursive=false] [flags] = Get documentation of various resources. For instance pods, nodes, services, etc.
  • kubectl exec POD = Execute a command against a container in a pod
  • kubectl edit = Edit and update the definition of one or more resources on the server by using the default editor.
  • kubectl drain NODE = Drain node in preparation for maintenance.
  • kubectl diff -f FILENAME [flags] = Diff file or stdin against live configuration
  • kubectl describe = Display the detailed state of one or more resources.
  • kubectl delete = Delete resources either from a file, stdin, or specifying label selectors, names, resource selectors, or resources.
  • kubectl create -f FILENAME [flags] = Create one or more resources from a file or stdin.
  • kubectl cp = Copy files and directories to and from containers.
  • kubectl cordon NODE = Mark node as unschedulable.
  • kubectl convert -f = Convert config files between different API versions. Both YAML and JSON formats are accepted.
  • kubectl config SUBCOMMAND = Modifies kubeconfig files. See the individual subcommands for details.
  • kubectl completion SHELL = Output shell completion code for the specified shell (bash or zsh).
  • kubectl cluster-info = Display endpoint information about the master and services in the cluster.
  • kubectl certificate SUBCOMMAND = Modify certificate resources.
  • kubectl autoscale = Automatically scale the set of pods that are managed by a replication controller.
  • kubectl auth [flags] [options] = Inspect authorization.
  • kubectl attach POD -c CONTAINER = Attach to a running container either to view the output stream or interact with the container (stdin).
  • kubectl apply -f FILENAME = Apply a configuration change to a resource from a file or stdin.
  • kubectl api-versions = List the API versions that are available.
  • kubectl api-resources [flags] = List the API resources that are available.
  • kubectl annotate (-f FILENAME | TYPE NAME | TYPE/NAME) = Add or update the annotations of one or more resources.
  • kubectl alpha SUBCOMMAND = List the available commands that correspond to alpha features, which are not enabled in Kubernetes clusters by default.

KUBEADM:

                 Kubeadm is a tool built to provide kubeadm init and kubeadm join as best-  practice “fast paths” for creating Kubernetes clusters. kubeadm performs the actions necessary to get a minimum viable cluster up and running. By design, it cares only about bootstrapping, not about provisioning machines.

KUBEADM COMMANDS:

  • kubeadm init-This command initializes a Kubernetes control-plane node.
  • kubeadm join-This command initializes a Kubernetes worker node and joins it to the cluster.
  • kubeadm upgrade-kubeadm upgrade is a user-friendly command that wraps complex upgrading logic behind one command, with support for both planning an upgrade and actually performing it.
  • kubeadm-config-Using this command, you can view the ConfigMap in the cluster where the configuration for kubeadm is located.

          The configuration is located in the “kube-system” namespace in the “kubeadm-config” ConfigMap.

  • kubeadm token-Bootstrap tokens are used for establishing bidirectional trust between a node joining the cluster and a control-plane node, as described in authenticating with bootstrap tokens.
  • kubeadm reset-Performs a best effort revert of changes made by kubeadm init or kubeadm join.

kubeadm alpha-kubeadm alpha provides a preview of a set of features made available for gathering feedback from the community

Leave a Reply

Your email address will not be published. Required fields are marked *