kubeconfig of an On-Premises Cluster
Obtaining the kubeconfig of an On-Premises Cluster
A kubeconfig file can be used to organize information about clusters, users, namespaces, and authentication mechanisms. The kubectl command-line tool uses the kubeconfig file to find the information it needs to choose a cluster and communicate with the API server of the cluster.
You need to use ucs-ctl to obtain the kubeconfig file of an on-premises cluster.
- Use ucs-ctl to obtain the name of the on-premises cluster.
./ucs-ctl get cluster
- Use ucs-ctl to export the kubeconfig file of the on-premises cluster.
./ucs-ctl get kubeconfig -c test-redhat86 -o kubeconfig
You can run the ucs-ctl get kubeconfig -h command to view the following parameters in a kubeconfig file:
- -c, --cluster: specifies the name of the cluster whose kubeconfig file is to be exported.
- -e, --eip: specifies the EIP of the API server.
- -o, --output: specifies the name of the kubeconfig file.
Using the kubeconfig of an On-Premises Cluster
After obtaining the kubeconfig file generated by ucs-ctl, take the following steps to make this file take effect on the node:
- Copy the kubeconfig file to the node.
scp /local/path/to/kubeconfig user@remote:/remote/path/to/kubeconfig
- If environment variable EnableSecretEncrypt has been added, delete it first.
unset EnableSecretEncrypt
- Make the kubeconfig file take effect by using one of the following methods:
- Method 1: Copy the kubeconfig file to the default path.
mv /remote/path/to/kubeconfig $HOME/.kube/config
- Method 2: Specify KUBECONFIG as the environment variable.
export KUBECONFIG=/remote/path/to/kubeconfig
- Method 3: Specify kubeconfig in command lines.
kubectl --kubeconfig=/remote/path/to/kubeconfig
- Method 1: Copy the kubeconfig file to the default path.
After the preceding operations are performed, kubectl can communicate with the API server of the on-premises cluster. For details about how to use the kubeconfig file, see Organizing Cluster Access Using kubeconfig Files.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot