You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Getting started
Using VCI through kubectl
Copy page
Download PDF
Using VCI through kubectl
This topic describes the procedure and parameter configurations for deploying applications running on VCI using the kubectl command-line tool after you create a VCI business-related cluster in the VKE console. This helps you quickly understand and use VKE.​
Background​
This topic takes the quick deployment of an Nginx application in a VPC-CNI cluster as an example to introduce the procedure for using VCI. For the method of using VCI in a Flannel cluster, see Using VCI in Flannel clusters.​
Step 1: Create a VKE cluster​
For detailed procedure and parameter descriptions, see the Step 1: Create a VKE cluster section of the Using VCI through the VKE console topic.​
tip​
To use an existing cluster, ensure that the cluster has public access to API Server.​
Step 2: Connect to the cluster​
You can use the kubectl tool to connect to the cluster you created.​
  1. Download and install the latest version of the kubectl tool on your on-premises computer.​
  1. On the Cluster page of the VKE console, find the cluster created in Step 1, and click its name.​
  1. On Overview page of the cluster, click Connection tab.​
  1. Select the Public network tab, and click Generate Kubeconfig. In the pop-up window, set Valid period (For this example, set the valid period to 365 days) to obtain the cluster access credentials.​
  1. Copy the obtained cluster access credentials to the local $HOME/.kube/config file generated after you install kubectl.​
warning​
$HOME/.kube/config is the file that comes with the kubectl client installed in your local environment. $HOME is a variable, and its value depends on your local operating system (such as macOS, Linux, or Windows) and the path where you install the kubectl client.​
  1. Run the following command in your kubectl client to query the status of namespaces in the cluster to check whether the cluster is connected.​
  • ​
    kubectl get namespace​
    ​
  • If you see similar messages as shown below, the kubectl is connected to the cluster successfully.​
  • ​
    NAME STATUS AGE​
    default Active 3h22m​
    kube-flannel Active 3h22m​
    kube-node-lease Active 3h22m​
    kube-public Active 3h22m​
    kube-system Active 3h22m​
    ​
Step 3: Deploy an application​
After kubectl and the cluster are connected, you can create a Deployment running on VCI by using the kubectl client.​
  1. Create a manifest named nginx.yaml in the $home directory of your local computer, and copy the following content into the file.​
tip​
Modify parameter values according to the comments in the sample code.​
  • ​
    apiVersion: apps/v1​
    kind: Deployment​
    metadata:​
    name: doc-deployment-vci # Replace with your application name​
    namespace: default # Namespace name​
    spec:​
    replicas: 1 # Number of pod instances​
    selector:​
    matchLabels:​
    app: doc-deployment-vci # Keep it the same as the value of the app field in the selector section of the Service that will be created later.​
    template:​
    metadata:​
    annotations:​
    vke.volcengine.com/burst-to-vci: enforce # This value is fixed, which indicates that VCI is enforcibly used.​
    labels:​
    app: doc-deployment-vci # Replace with your application name​
    spec:​
    containers:​
    - image: doc-cn-beijing.cr.volces.com/vke/nginx-demo:v1.0 # Replace with your image address​
    name: doc-deployment-vci-container # Replace with your container name​
    ports:​
    - containerPort: 80​
    protocol: TCP​
    ​
  1. Run the following command to deploy the application.​
  • ​
    kubectl apply -f nginx.yaml​
    ​
  1. Run the following command to view the deployment status.​
  • ​
    kubectl get deployment ${your_deployment_name}​
    ​
tip​
Replace ${your_deployment_name} with the specified workload name. For example, if the workload name is doc-deployment-vci, the complete command is as follows.​
​
kubectl get deployment doc-deployment-vci​
​
  • The information similar to the following message indicates the application has been deployed successfully.​
  • ​
    NAME READY UP-TO-DATE AVAILABLE AGE​
    doc-deployment-vci 1/1 1 1 63s​
    ​
  1. In the $home directory on your local computer, create a nginx-svc.yaml file and copy the following sample code into that file.​
tip​
Modify parameter values according to the comments in the sample code as needed. For more descriptions, see Creating Load Balancer services through kubectl.​
  • ​
    apiVersion: v1​
    kind: Service​
    metadata:​
    name: nginx-svc # Service name​
    namespace: default # Namespace name​
    spec:​
    ports:​
    - name: doc-vci-port # Port mapping name​
    port: 80 # port through which the service will be accessed​
    protocol: TCP # Port protocol.​
    targetPort: 80 # Container port, a port number or port name through which a workload provides service, e.g., the default port number for Nginx is 80​
    selector:​
    app: doc-deployment-vci # Keep it the same as the value of the app field in the matchLabels section of the created application.​
    type: LoadBalancer # Service type. Valid values: Nodeport, ClusterIP, and LoadBalancer.​
    ​
  1. Run the following command to create a service.​
  • ​
    kubectl apply -f ngixn-svc.yaml​
    ​
  • The information similar to the following message is expected to be displayed.​
  • ​
    service/nginx-svc created​
    ​
  1. Run the following command to view the service status.​
  • ​
    kubectl get svc ${your_service_name}​
    ​
tip​
Replace ${your_service_name} with the specified service name. For example, if the service workload name is nginx-svc, the complete command is as follows.​
​
kubectl get svc nginx-svc​
​
  • The information similar to the following message indicates the application has been deployed successfully.​
  • ​
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE​
    nginx-svc LoadBalancer 172.**.**.** 124.**.**.** 80:31647/TCP 17s​
    ​
  1. In your browser, enter the EXTERNAL-IP returned in the previous step to visit the Nginx welcome page.​
  • ​​​
Step 4: (Optional) Monitor the application​
After the application is deployed, you can use cloud-native observability capabilities to monitor the running status and resource usage of the application, such as CPU and memory usage, to facilitate operations and maintenance. For related descriptions, see Monitoring VCI with VMP.​
Release resources​
After you get started with VCI, if you do not need to use applications that are deployed through VCI, refer to the guidance in Managing workloads to delete the deployments. If you do not need to use the VKE cluster, refer to the guidance in Deleting clusters to delete the cluster and its associated resources. If you need to continue to use the VKE cluster and the applications deployed in the cluster through VCI, make sure that your Volcano Engine account balance is not zero when coupons are excluded and not less than CNY 100 when coupons are included. ​
If you continue to use the VKE cluster and the applications deployed in the cluster by using VCI, the following types of fees will be incurred. For detailed billing information, see Product billing.​
  • Cluster management fees: The fees are charged by VKE.​
  • VCI fees: The fees are charged by VCI.​
  • Basic cloud resource fees: The fees for services used in the cluster, such as NAT Gateway, Load Balancer, EIP, and EBS, and other Volcano Engine cloud services, are billed separately by the respective cloud services.​
Last updated: 2026.08.19 17:46:34