Good day, Readers! In this blog, we’ll look at how to deploy a Nginx Web server with Pulumi. Before you begin using pulumi, you should be familiar with Kubernetes workloads.
What is Pulumi?
Pulumi is an open-source infrastructure as code tool that simplifies the provisioning and management of cloud resources by utilising the most popular programming languages.
Pulumi, which was founded in 2017, has fundamentally altered the way DevOps teams approach the concept of infrastructure-as-code. Instead of relying on domain-specific languages, Pulumi enables organisations to provision and decommission cloud-native infrastructure using real programming languages.
What is Infrastructure as Code(IaC)?
- Infrastructure-as-Code (IaC) is the process of using descriptive coding languages to automate resource provisioning and management schemes.
- System administrators had to manually configure, deploy, and manage server resources prior to infrastructure as code (IaC). Before they could deploy apps, they would need to configure bare metal machines. Many issues arose as a result of manually managing infrastructure. It was costly, slow, difficult to scale, and prone to human error.
- The introduction of cloud computing simplified the deployment of virtualized environments, but administrators still had to deploy the environment manually. They needed to access the cloud provider’s web-based dashboard and click buttons to deploy the desired server configurations.
How it Works?
Because of its multi-language and multi-cloud capabilities, Pulumi has become the preferred infrastructure-as-code tool in DevOps environments. It gives DevOps engineers a familiar way of managing resources.
This is accomplished by Pulumi’s cloud object model and evaluation runtime. It takes your programme in any language, determines which cloud resources you want to manage, and executes it. All of this is possible because it is language-neutral and cloud-neutral by nature.
The Pulumi system is made up of three parts:
- Language host: Your Pulumi programme is run by the language host to create an environment and register resources with the deployment engine.
- Deployment engine: It performs numerous checks and computations to determine whether resources should be created, updated, deleted, or replicated.
- Resource providers: Pulumi downloads packages and plugins in the background based on your language and cloud provider preferences.
Install Pulumi CLI:
curl -fsSL https://get.pulumi.com | sh
After installing Pulumi, verify everything is in working order by running the
Get started with Kubernetes
For a quick demonstration of how Pulumi deploys infrastructure on Kubernetes, follow these steps to easily deploy an NGINX web server
Create a New Project:
Now that you have set up your environment let’s create your first Pulumi program.
mkdir demo && cd demo && pulumi new kubernetes-python
Initially, you will be asked for a project name and description. Later, you will be asked for the name of a stack.
After the command completes, the project and stack will be ready.
Deploy the Stack:
This command instructs Pulumi to determine the resources needed to create the stack. First, a preview of the upcoming changes is shown
$ pulumi up
Previewing update (dev) Type Name Plan + pulumi:pulumi:Stack nginx-project-dev create + └─ kubernetes:apps/v1:Deployment nginx create Outputs: name: "nginx-fc09142e" Resources: + 2 to create Do you want to perform this update? > yes > no
yes will create resources in Kubernetes.
Do you want to perform this update? yes Updating (dev) Type Name Status + pulumi:pulumi:Stack nginx-project-dev created + └─ kubernetes:apps/v1:Deployment nginx created Outputs: name: "nginx-7076e6df" Resources: + 2 created Duration: 10s
The name of the deployment that we exported is shown as a Stack Output.
Destroy the Stack:
Now that we’ve seen how to deploy changes to our programme, let’s go over how to clean up and deconstruct the resources that comprise our stack.
Execute the following commands to destroy resources:
$ pulumi destroy
To delete the stack, run:
$ pulumi stack rm dev
This removes the stack entirely from the Pulumi Service, along with all of its update history.