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
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.
- Download and install the latest version of the kubectl tool on your on-premises computer.
- On the Cluster page of the VKE console, find the cluster created in Step 1, and click its name.
- On Overview page of the cluster, click Connection tab.
- 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.
- 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.
- Run the following command in your kubectl client to query the status of namespaces in the cluster to check whether the cluster is connected.
- If you see similar messages as shown below, the kubectl is connected to the cluster successfully.
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.
- 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.
- Run the following command to deploy the application.
- Run the following command to view the deployment status.
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.
- The information similar to the following message indicates the application has been deployed successfully.
- In the $home directory on your local computer, create a nginx-svc.yaml file and copy the following sample code into that file.
- Run the following command to create a service.
- The information similar to the following message is expected to be displayed.
- Run the following command to view the service status.
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.
- The information similar to the following message indicates the application has been deployed successfully.
- 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. 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.