Installing the Kubernetes CLI (kubectl)
To access your cluster by using the command line interface (CLI), you must install and configure kubectl
, the Kubernetes command line tool.
-
Synchronize the clocks in between the client computer and the nodes in the IBM® Cloud Private cluster . To synchronize your clocks, you can use network time protocol (NTP). For more information about setting up NTP, see the user documentation for your operating system.
-
From the IBM Cloud Private management console, click Menu > Command Line Tools > Cloud Private CLI.
-
Expand Install Kubernetes CLI to download the installer by using a
curl
command. Copy and run the curl command for your operating system, then continue the installation procedure:Choose the curl command for the applicable operating system. For example, you can run the following command for macOS:
curl -kLo <install_file> https://<cluster ip>:<port>/api/cli/kubectl-darwin-amd64
-
Change the file to an executable, then move the file to a directory that is included in your PATH environment variable. See the following commands where
<path_to_installer>
is the location of the file that you downloaded and<install_file>
is the name of the file:-
For Linux® and macOS, run the following commands to change the permissions of the file and move the file to a directory that is included in your PATH environment variable:
chmod 755 <path_to_installer>/<install_file>
sudo mv <path_to_installer>/<install_file> /usr/local/bin/kubectl
In this example, it is moved to the
/usr/local/bin/kubectl
directory. -
For Windows™, rename the downloaded file to
kubectl
and place the file in a directory that is listed in the PATH environment variable.
Note: You can also download from Kubernetes. See Install and Set Up kubectl .
-
-
Obtain the cluster configuration details. You can obtain the cluster configuration details by using the IBM Cloud Private CLI or management console.
-
To obtain the configuration details from the management console:
- Log in to your cluster management console. See Accessing your IBM Cloud Private cluster by using the management console.
-
Select the user icon , then click Configure client. The cluster configuration details display and resemble the following code:
kubectl config set-cluster {cluster_name} --server=https://<Cluster Master Host>:8001 --insecure-skip-tls-verify=true kubectl config set-context {cluster_name}-context --cluster={cluster_name} kubectl config set-credentials {cluster_name}-user --token={token} kubectl config set-context {cluster_name}-context --user={cluster_name}-user --namespace=default kubectl config use-context {cluster_name}-context
Where,
<Cluster Master Host>
is defined in Master endpoint. -
Copy and paste the configuration information to your command line, and press Enter.
-
To obtain the configuration details from the IBM Cloud Private CLI:
- Install the IBM Cloud Private command line interface (CLI) and log in to your cluster. See Installing the IBM Cloud Private CLI.
Note: This configuration expires in 8 hours. To continue to use the CLI, you must log in and reconfigure
kubectl
every 8 hours. To avoid this limitation, you can configure your CLI by using service accounts. See Configuring the Kubernetes CLI by using service account tokens .
-