k8s command line management tool kubectl & cluster configuration kubeconfig

1. View k8s command=》# kubectl --help

Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/

k8s command auto-completion toolkit , installation reference=" bash command completion tool bash-completion

2.kubeconfig | kubectl Use the kubeconfig authentication file to connect to the k8s cluster, and use the kubectl config command to produce the kubeconfig file.

The above configuration file indicates which cluster is currently connected, and what identity (permission) the corresponding client uses to access the cluster, so as to achieve better granular management of k8s cluster information; 

[Context] The role and use scenario, when there are multiple configuration information in the k8s cluster, how to describe it through a configuration file? The context here is to achieve this function. It corresponds to the above [Cluster] and the following [Client Authentication] information. The final decision to use the cluster configuration information is specified by the [Current Context];

Note: When other nodes enter the kubectl command, it prompts [ error: the server doesn't have a resource type "node" ]. At this time, you only need to copy the current kubeconfig configuration file to the node where the kubectl command is to be executed (if k8s- node01)

Copy files across node hosts and copy configuration files to the specified host

--kubeconfig configures node cluster related information, which can be viewed by any node

At this point, execute the kubectl command on the moved target node (k8s-node01) again, such as => kubectl get node  still prompts the same error message above, continue to move the copied kubeconfig file to the specified folder

  • Move the configuration file to the specified directory => # mv admin.conf .kube/config

In order to simplify the operation of the command to point to the configuration, move the admin.conf configuration file to .kube/config, and then enter the kubectl command => kubectl get node  displays the command execution information normally.

If you don’t move the configuration file, you can also use the kubectl command via --kubeconfig named;

3. The environment variable KUBERNETES_MASTER specifies the external exposure address of kube-apiserver

 kubeconfig configuration file default address /etc/kubernetes/admin.conf

View the configuration information of admin.conf as shown below:

4. kubelet tool start and stop

  • Start kubelet tool=》# systemctl start kubelet
  • Stop kubelet tool=》# systemctl stop kubelet

 

Summary: The above briefly introduced the kubectl command line tool and the kubeconfig cluster configuration file;

  • kubectl is a command line tool on k8s:
  1. =》kubectl controls the Kubernetes cluster manager, and uses the Kubernetes command line tool kubectl to deploy and manage applications on Kubernetes.
  2. = "Using kubectl, you can check cluster resources; create, delete and update components; take a look at your new cluster; and come up with sample applications.

More kubectl reference https://kubernetes.io/docs/reference/kubectl/overview/

  • kubeconfig describes k8s cluster configuration information:
  1. =》Realize granular management of k8s cluster information;

Attachment reference: [ Introduction and use of kubectl  ] & [ Usage of kubeconfig in kubernetes ]

Guess you like

Origin blog.csdn.net/ChaITSimpleLove/article/details/110210961