Skip to main content

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.

info

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.

  1. Navigate to KakaoCloud Console > Container Pack > Kubernetes Engine.

  2. In the Cluster menu, click on the cluster to configure kubectl control.

    • Click the [kubeconfig file] button for the cluster you want to configure.

    Image

  3. 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}.
  4. Set the kubeconfig environment variable for easier declaration of the kubeconfig file.

    In the Mac terminal, set the KUBE_CONFIG environment variable as shown below:

    Set KUBE_CONFIG environment variable
    export KUBE_CONFIG="{DownloadPath}/{kubeconfigFile}"
    ParameterTypeRequiredDescription
    DownloadPathStringRequiredPath where the kubeconfig file is located
    kubeconfigFileStringRequiredName and extension of the kubeconfig file
    - Example: kubeconfig-cluster.yaml

Configure KakaoCloud authentication client

Download the KakaoCloud authentication client and set the environment variables.

info

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.

  1. Download the KakaoCloud authentication client for user authentication.

    FileVersionDownload Link
    Linux x86_64 64Bit0.1.2Download
    Linux ARM_64 64Bit0.1.2Download
    Linux i386 32Bit0.1.2Download
    Windows x86_64 64Bit0.1.2Download
    Windows i386 32Bit0.1.2Download
    Mac x86_64 64Bit0.1.2Download
    Mac ARM_64 64Bit0.1.2Download
  2. Rename the downloaded file to kic-iam-auth.

    kic-iam-auth
  3. After downloading, set the environment variables to run the KakaoCloud authentication client.

    a. Grant execute permission for the KakaoCloud authentication client.

    Grant execute permission for Mac/Linux file
    cd {DownloadPath}
    chmod +x kic-iam-auth
    ParameterTypeRequiredDescription
    DownloadPathStringRequiredEnter the directory path where the KakaoCloud authentication client is located

    b. Register the environment variable in the PATH.

    Register PATH environment variable for Mac/Linux
    export 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 example
    cp {DownloadPath}/kic-iam-auth /usr/local/bin
    ParameterTypeRequiredDescription
    DownloadPathStringRequiredEnter the directory path where the KakaoCloud authentication client 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.

info

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.

info

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.

  1. 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 VariableDescriptionNote
    OS_AUTH_URLServer URL for user authenticationhttps://iam.kakaocloud.com/identity/v3
    OS_AUTH_TYPEUser authentication typev3applicationcredential
    OS_APPLICATION_CREDENTIAL_IDAccess key IDIssued Access key ID
    OS_APPLICATION_CREDENTIAL_SECRETAPI secret access keyIssued API secret access key
    OS_REGION_NAMERegion where the cluster is locatedkr-central-1 or kr-central-2
  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 variables
    users:
    - 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.
info
Verify kubectl functionality
kubectl --kubeconfig=$KUBE_CONFIG get nodes
Result
NAME           STATUS   ROLES    AGE     VERSION
{node-name} Ready <none> 2d2h v1.18.17
{node-name} Ready <none> 2d2h v1.18.17