Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

kubectl Configuration Guide

Updated on 2024-11-01 GMT+08:00

CCI allows you to use native or customized kubectl to create resources such as workloads. Native kubectl is recommended.

Downloading kubectl

Download the kubectl of version 1.19 from the Kubernetes version release page.

NOTE:

For a device that uses the Apple M1 chip, download the kubectl corresponding to the darwin-arm64 architecture.

Downloading cci-iam-authenticator

Download the cci-iam-authenticator binary from the CCI official website. The latest version is v2.6.17.

Table 1 lists the addresses for downloading cci-iam-authenticator.

Installing and Configuring kubectl

Perform the following operations to install and configure kubectl on a Linux OS. For more details, see Install Tools.

  1. Grant the execute permission on kubectl downloaded in Downloading kubectl and save it to the PATH directory.

    chmod +x ./kubectl

    mv ./kubectl $PATH

    In the preceding command, $PATH indicates the PATH directory (for example, /usr/local/bin). Replace it with the actual value.

    You can run the following command to view the kubectl version:

    kubectl version --client=true

    Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T14:30:33Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

  2. Configure IAM authentication information and persistently store it to the local host.

    1. Grant the execute permission on cci-iam-authenticator downloaded in Downloading cci-iam-authenticator and save it to the PATH directory.

      chmod +x ./cci-iam-authenticator

      mv ./cci-iam-authenticator $PATH

    2. Initialize the cci-iam-authenticator configuration.
      You can initialize the cci-iam-authenticator configuration by using either of the following methods:
      • Using AK/SK

        cci-iam-authenticator generate-kubeconfig --cci-endpoint=https://$endpoint --ak=xxxxxxx --sk=xxxxxx

        endpoint is an endpoint of CCI. For details about CCI endpoints, see Regions and Endpoints. For details about how to obtain the AK and SK, see Obtaining an AK/SK. ak is the access key in the file, and sk is the secret key in the file.

        For example, if endpoint is https://cci.cn-north-4.myhuaweicloud.com, the value of ak is my-ak, and the value of sk is ABCDEFAK.., run the following command:

        cci-iam-authenticator generate-kubeconfig --cci-endpoint=https://cci.cn-north-4.myhuaweicloud.com --ak=my-ak --sk=ABCDEFAK..

        Information similar to the following is displayed:

        Switched to context "cci-context-cn-north-4-my-ak"

        In the preceding command, cci-context-cn-north-4-my-ak is the context name, which can be viewed by running kubectl config get-contexts.

      • Using username and password

        cci-iam-authenticator generate-kubeconfig --cci-endpoint=https://$endpoint --domain-name=xxxxxxx --user-name=xxxxxx --password='xxxxxx'

        In the preceding command, endpoint is the CCI endpoint, domain-name is the tenant name, user-name is the IAM username, and password is the IAM user password. Replace them with the actual values.

        NOTE:
        • If there is no IAM user, set user-name to the same value as domain-name. Alternatively, do not set user-name.
        • For details about IAM endpoints, see Regions and Endpoints. Note that the endpoint must be in the same region as CCI.
        • If kubectl is used in an insecure environment, you are advised to configure environment variables to reconfigure the authentication information after this step is complete. For details, see Configuring kubectl in an Insecure Environment.

  3. After the configuration is complete, you can run kubectl commands to perform operations on CCI resources.

    For example, run the following command to view the namespace resources in CN North-Beijing4:

    kubectl get ns

    No resources found.

    The command output shows that there is no namespace in CN North-Beijing4. Before creating resources in CCI, create a namespace by following the procedure described in Namespace and Network.

WARNING:
  • When you access public cloud services through APIs, the username/password or AK/SK pair is required to encrypt the requests. This mechanism ensures the confidentiality and integrity of the requests as well as the correctness of the identities of both parties. Keep the $HOME/.kube/config configuration file secure to prevent unauthorized use of the AK/SK.
  • If the function of caching tokens is enabled to improve access performance, the tokens are saved as files in the $HOME/.cci/cache directory. Delete the tokens in a timely manner when they are unnecessary.
  • If your access key is used by an unauthorized person due to loss or leakage, you can delete the access key or notify the administrator of resetting it and then configure the access key again.
  • Deleted access keys cannot be recovered.

Configuring kubectl in an Insecure Environment

  1. Follow the preceding steps to install and configure kubectl.
  2. Edit the kubeconfig file and delete sensitive information.

    On a Linux OS, the kubeconfig file is stored in $HOME/.kube/config by default.
    Table 2 Sensitive information to be deleted

    Command Flag

    Environment Value

    Description

    --domain-name

    DOMAIN_NAME

    Tenant name

    --user-name

    USER_NAME

    Sub-user name

    --password

    PASSWORD

    User password

    --ak

    ACCESS_KEY_ID

    Access key ID

    --sk

    SECRET_ACCESS_KEY

    Secret access key

    --cache

    CREDENTIAL_CACHE

    Whether to cache tokens

    For details about more parameters, see cci-iam-authenticator Usage Reference.

  3. Configure the environment variables corresponding to the deleted parameters. For example, configure AK, SK, and whether to cache tokens.

    NOTE:

    Hardcoded or plaintext AK and SK are risky. For security, encrypt your AK and SK and store them in the configuration file or as environment variables.

    export ACCESS_KEY_ID={Access Key} #Replace it with HUAWEICLOUD_SDK_AK.

    export SECRET_ACCESS_KEY={Secret Key} #Replace it with HUAWEICLOUD_SDK_SK.

    export CREDENTIAL_CACHE=false

    kubectl get ns

    Information similar to the following is displayed:

    No resources found.

Obtaining an AK/SK

AK: access key ID. It is a unique ID associated with an SK. AK is used together with SK to sign requests.

SK: secret access key. It is used together with an AK to sign requests. They can identify request senders and prevent requests from being modified.

  1. Log in to the management console.
  2. Hover over the username and select My Credentials from the drop-down list.
  3. Choose Access Keys from the navigation pane.
  4. Click Create Access Key, and enter the verification code.
  5. Click OK to generate an access key and download it.

    NOTE:

    Keep the AK/SK file confidential to prevent information leakage.

Obtaining CCI Endpoints

Obtain the endpoint from the Regions and Endpoints page, as shown in the following table.

Table 3

Region Name

Region

Endpoint

LA-Sao Paulo1

sa-brazil-1

cci.sa-brazil-1.myhuaweicloud.com

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback