Configure kubectl control
kubectl is the Kubernetes command-line tool used to control clusters. To configure kubectl control, first install the kubectl client, then proceed with kubectl control configuration. Here's how to configure kubectl control.
Step 1. Install kubectl client
To configure kubectl control, install the kubectl client. For detailed instructions on installing the kubectl client, refer to the Kubernetes official documentation.
Ensure to follow the installation method for your OS environment and check the kubectl version before proceeding.
Step 2. Configure kubectl control
After installing the kubectl client, proceed with setting up kubectl control for your cluster.
Configure kubeconfig
To configure kubectl control, first download the kubeconfig file for cluster access, then set the environment variable.
-
Navigate to KakaoCloud Console > Container Pack > Kubernetes Engine.
-
In the Cluster menu, click on the cluster to configure kubectl control.
- Click the [kubeconfig file] button for the cluster you want to configure.
-
In the kubectl control configuration popup, click the [Download kubeconfig file] button.
- The file containing the cluster access information is downloaded with the name
kubeconfig-{clusterName}
.
- The file containing the cluster access information is downloaded with the name
-
Set the kubeconfig environment variable for easier declaration of the kubeconfig file.
- Mac/Linux
- Windows (Command Prompt)
In the Mac terminal, set the KUBE_CONFIG environment variable as shown below:
Set KUBE_CONFIG environment variableexport KUBE_CONFIG="{DownloadPath}/{kubeconfigFile}"
Parameter Type Required Description DownloadPath String Required Path where the kubeconfig file is located kubeconfigFile String Required Name and extension of the kubeconfig file
- Example: kubeconfig-cluster.yamlIn the Windows terminal, set the OS environment variable as shown below:
Set OS environment variableset KUBE_CONFIG={DownloadPath}\{kubeconfigFile}
Parameter Type Required Description DownloadPath String Required Path where the kubeconfig file is located kubeconfigFile String Required Name and extension of the kubeconfig file
- Example: kubeconfig-cluster.yaml
Configure KakaoCloud authentication client
Download the KakaoCloud authentication client and set the environment variables.
After downloading the KakaoCloud authentication client, you may need to allow the application to open based on your OS settings. On Windows, the file might be flagged by Windows Defender or other antivirus programs and may not run or be automatically deleted. In such cases, you will need to whitelist the file in your antivirus program.
-
Download the KakaoCloud authentication client for user authentication.
File Version Download Link Linux x86_64 64Bit 0.1.2 Download Linux ARM_64 64Bit 0.1.2 Download Linux i386 32Bit 0.1.2 Download Windows x86_64 64Bit 0.1.2 Download Windows i386 32Bit 0.1.2 Download Mac x86_64 64Bit 0.1.2 Download Mac ARM_64 64Bit 0.1.2 Download -
Rename the downloaded file to
kic-iam-auth
.kic-iam-auth
-
After downloading, set the environment variables to run the KakaoCloud authentication client.
- Mac/Linux KakaoCloud authentication client setup
- Windows (Command Prompt)
a. Grant execute permission for the KakaoCloud authentication client.
Grant execute permission for Mac/Linux filecd {DownloadPath}
chmod +x kic-iam-authParameter Type Required Description DownloadPath String Required Enter the directory path where the KakaoCloud authentication client is located b. Register the environment variable in the PATH.
Register PATH environment variable for Mac/Linuxexport PATH="{DownloadPath}:$PATH"
Alternatively, you can copy the file to a directory that already exists in the PATH. Below is an example of copying the file to a directory in the PATH.
File copy examplecp {DownloadPath}/kic-iam-auth /usr/local/bin
Parameter Type Required Description DownloadPath String Required Enter the directory path where the KakaoCloud authentication client is located Register the environment variable in the PATH using the Windows command prompt.
Register PATH environment variable in Windowsset path=%PATH%;{DownloadPath}
Parameter Type Required Description DownloadPath String Required Enter the path where the file is located
Get access key
Generate an access key to use user authentication information. When creating an access key, you must assign the project that contains the cluster you want to manage. For detailed instructions on generating an access key, refer to Get access key.
If you already have an access key in use, you can skip this step and proceed to the next.
Configure user authentication
Configure user authentication using the information from the access key.
Use the default values for the current environment variables. For OS_APPLICATION_CREDENTIAL_ID and OS_APPLICATION_CREDENTIAL_SECRET, use the information from the issued access key.
-
To configure user authentication for the Access key, enter the following user authentication environment variables into the kubeconfig file downloaded in the previous step.
User authentication OS environment variables
Environment Variable Description Note OS_AUTH_URL Server URL for user authentication https://iam.kakaocloud.com/identity/v3
OS_AUTH_TYPE User authentication type v3applicationcredential
OS_APPLICATION_CREDENTIAL_ID Access key ID Issued Access key ID OS_APPLICATION_CREDENTIAL_SECRET API secret access key Issued API secret access key OS_REGION_NAME Region where the cluster is located kr-central-1 or kr-central-2 -
Enter the user authentication environment variables under users > user > exec > env in the kubeconfig file downloaded in the previous step.
Example of entering user authentication environment variablesusers:
- name: {Cluster name}-admin
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args: null
command: kic-iam-auth
env:
- name: "OS_AUTH_URL"
value: "https://iam.kakaocloud.com/identity/v3"
- name: "OS_AUTH_TYPE"
value: "v3applicationcredential"
- name: "OS_APPLICATION_CREDENTIAL_ID"
value: "{Enter Access key ID}"
- name: "OS_APPLICATION_CREDENTIAL_SECRET"
value: "{Enter API secret access key}"
- name: "OS_REGION_NAME"
value: "{Enter the region of the cluster}"
Step 3. Verify kubectl functionality
After completing the kubectl control configuration, enter the kubectl command in the terminal to verify that it works properly.
- For Windows, use
%KUBE_CONFIG%
instead of$KUBE_CONFIG
.
- The example command checks the nodes in the cluster. You can find more commands in the Kubernetes official documentation.
- For details on configuring access to multiple clusters using the kubeconfig file, refer to Kubernetes official documentation.
kubectl --kubeconfig=$KUBE_CONFIG get nodes
NAME STATUS ROLES AGE VERSION
{node-name} Ready <none> 2d2h v1.18.17
{node-name} Ready <none> 2d2h v1.18.17