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 to set up the control configuration. The steps are as follows:

Step 1. Install kubectl client

Install the kubectl client to configure kubectl control.
For detailed installation instructions, refer to the Kubernetes official documentation.

info

Please check your OS environment and install the appropriate version of kubectl.

Step 2. Configure kubectl control

After installing the kubectl client, proceed to configure kubectl access for your cluster.

Configure kubeconfig

When setting up kubectl control, download the kubeconfig file for cluster access and set the environment variable.

  1. Go to the KakaoCloud Console > Container Pack > Kubernetes Engine.

  2. In the Cluster menu, click the cluster you wish to configure for kubectl.

    • Click the [kubeconfig file] button for the desired cluster.

    Image

  3. In the kubectl control setup popup, click [Download kubeconfig file].

    • A kubeconfig file will be downloaded with the format kubeconfig-{clusterName}.
  4. Set the kubeconfig environment variable for convenient declaration.

    Set the KUBE_CONFIG environment variable in the terminal:

    Set KUBE_CONFIG environment variable
    export KUBE_CONFIG="{DownloadPath}/{kubeconfigFile}"
    ParameterTypeRequiredDescription
    DownloadPathStringYesEnter the path where the kubeconfig file is located
    kubeconfigFileStringYesEnter the filename and extension
    - Example: kubeconfig-cluster.yaml

Configure KakaoCloud authentication client

Download the KakaoCloud authentication client and set the appropriate environment variables.

info

After downloading the KakaoCloud authentication client, you may need to allow the app to run depending on your OS. On Windows, antivirus software like Windows Defender may block or delete the executable. If so, register it in your antivirus whitelist.

  1. Download the KakaoCloud authentication client:

    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. Set the environment variables required to run the client.

    a. Grant execution permission:

    Grant execution permission
    cd {DownloadPath}
    chmod +x kic-iam-auth

    b. Register the path:

    Register PATH variable
    export PATH="{DownloadPath}:$PATH"

    Or copy the file to an existing directory in your PATH:

    Copy file example
    cp {DownloadPath}/kic-iam-auth /usr/local/bin

Get IAM access key

Generate an access key for authentication.
Be sure to select the project where your target cluster resides.
For detailed instructions, refer to the Credentials page.

info

If you already have an access key, you may skip this step.

Configure user authentication

Use the access key credentials to set environment variables inside your kubeconfig file.

info

Use default values for all other fields, and replace the credential ID/secret as shown below.

  1. Open your kubeconfig file and set the variables under users > user > exec > env:

    Example kubeconfig user block
    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: "{your access key ID}"
    - name: "OS_APPLICATION_CREDENTIAL_SECRET"
    value: "{your access key secret}"
    - name: "OS_REGION_NAME"
    value: "{your cluster region}"

Step 3. Verify kubectl functionality

Once setup is complete, use the command below to verify:

info
Verify kubectl
kubectl --kubeconfig=$KUBE_CONFIG get nodes
Expected output
NAME           STATUS   ROLES    AGE     VERSION
{node-name} Ready <none> 2d2h v1.18.17
{node-name} Ready <none> 2d2h v1.18.17