docs
uk8s
Cluster Management
Manage Cluster via Kubectl
Installation and Configuration of Kubectl

Installation and Configuration of Kubectl

Since viewing cluster credentials allows direct login to the cluster, the operation of viewing cluster credentials has been classified under the add permission in user role permissions. If you need to view the cluster credentials, please ensure that the appropriate authority has been enabled in your role for UK8S.

This section mainly demonstrates how to install and configure kubectl on SurferCloud cloud server and manage Kubernetes clusters. The cluster's Master node has installed kubectl by default. If you only need to do some simple tests on the Master node, please skip this section.

Cloud Server Environment

Operating System: Linux. For windows, please refer to the official documentation (opens in a new tab).

Belonging VPC: Same VPC as the cluster

Extranet access: Yes

I. Install kubectl

  1. Download the installation package. We download the V1.13.5 kubectl installation package. For other versions, please go to official website download (opens in a new tab).
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.13.5/bin/linux/amd64/kubectl

If you want to download the latest version of the installation package, use the following command: Replace v1.13.5 with $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt).

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  1. Add execution permissions
chmod +x ./kubectl
  1. Move to the working path
sudo mv ./kubectl /usr/local/bin/kubectl
  1. Confirm whether it is successfully installed.
kubectl version

Note: If you need to install kubectl on ubuntu or other Linux distributions, or you want to use yum to install, you can refer to the official documentation (opens in a new tab).

II. Acquire and Configure Cluster Credentials

You can obtain the credentials of the cluster you created via UK8S Console、SCP、API.

Note: No credentials are needed for cluster internal access, you can access directly.

  1. Obtain cluster credentials via Console

Enter , click "cluster credentials"

Copy and save cluster information to ~/.kube/config file

  1. Download cluster credentials to local machine from Master node via SCP

First, click to enter the cluster details page, get the IP of any Master node, and then execute the following command on the local machine:

scp root@YOURMASTERIP:~/.kube/config ~/.kube/config

III. Access Cluster

You can run the following command to verify whether kubectl can successfully access cluster information:

# kubectl cluster-info

IV. Set up Command Auto-completion

Install on the node where kubectl is located

yum install bash-completion -y

kubectl supports command auto-completion, you can open it by executing the following commands:

echo "source <(kubectl completion bash)" >> ~/.bashrc
  • Company
  • ContactUs
  • Blog
Copyright © 2024 SurferCloud All Rights Reserved