Automatic Application Deployment Using Pulumi
Pulumi is an infrastructure as code (IaC) automation tool built on Terraform. It allows you to build, deploy, and manage cloud infrastructure throughout its lifecycle using popular programming languages such as Python, TypeScript, C#, and Go.
This section describes how to use Pulumi to deploy an application and shows the process using a specific example.
Preparations
- Create a CCE cluster and ensure that an EIP has been bound to a node for downloading images and external access.
- Prepare an ECS, bind an EIP to it, and configure kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
Installing Pulumi
- Log in to the ECS.
- Run the command below to install Pulumi. You can also visit the Pulumi official website and follow the instructions to manually install Pulumi.
curl -fsSL https://get.pulumi.com | sh
- Run the following command to check whether Pulumi is successfully installed:
pulumi version
- Go to the Pulumi official website and register a Pulumi account.
- Create a Pulumi access token.
Log in to the Pulumi console, click the user avatar, and choose Settings. Click Access Tokens and then Create token.

- Set the Pulumi access token environment variable.
export PULUMI_ACCESS_TOKEN=pul-xxxx
Using Pulumi to Deploy an Application
- Initialize a Pulumi project. The following uses Python as an example.
mkdir pulumi-demo && cd pulumi-demo pulumi new kubernetes-python
Enter the following information as prompted:
- project name: project name (for example, pulumi-cce-demo)
- description: project description
- stack name: environment stack (The default value is dev, which is used to distinguish the development, test, and production environments.)
After the initialization is complete, the following core file is automatically generated:
pulumi-demo/ ├── Pulumi.yaml # Project metadata ├── Pulumi.dev.yaml # Development environment configuration ├── __main__.py # Main infrastructure code └── venv/ # Python virtual environment

- Compile the test code __main__.py to deploy an Nginx application.
"""A Kubernetes Python Pulumi program""" import pulumi from pulumi_kubernetes.apps.v1 import Deployment app_labels = { "app": "nginx" } deployment = Deployment( "nginx", spec={ "selector": { "match_labels": app_labels }, "replicas": 1, "template": { "metadata": { "labels": app_labels }, "spec": { "containers": [{ "name": "nginx", "image": "nginx" }] } }, }) pulumi.export("name", deployment.metadata["name"]) - In the terminal, run the following command to deploy your infrastructure:
pulumi up
The resources to be created are displayed in the command output. Enter yes to confirm.

- Check whether the deployment is successful.
kubectl get pod
If the following information is displayed, the deployment is successful.

What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot