AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi
Kubernetes MERN Stack Voting App
A simple voting app that uses Kubernetes.
The example shows how easy it is to deploy a containerized application to Amazon EKS. Pulumi does the following:
- Builds the Docker images
- Provisions AWS Container Registry (ECR) instance
- Pushes the images to the ECR instance
- Provisions AWS EKS cluster
- Uses the images to create Kubernetes deployments
Prerequisites
Deploying and running the program
Create a new stack:
$ pulumi stack init aws-ts-k8s-mern-voting-app
Set the AWS region and the usernames and passwords for a set of accounts the project uses:
$ pulumi config set aws:region us-west-2 $ pulumi config set sqlUserName <NAME> $ pulumi config set sqlUserPassword <PASSWORD> --secret
Restore NPM modules via
npm install
oryarn install
.Run
pulumi up -y
to deploy changes:Updating (aws-ts-k8s-mern-voting-app): Type Name Status Info + pulumi:pulumi:Stack voting-app-aws-ts-k8s-mern-voting-app created + ├─ eks:index:Cluster eksCluster created + │ ├─ eks:index:ServiceRole eksCluster-eksRole created + │ │ ├─ aws:iam:Role eksCluster-eksRole-role created + │ │ ├─ aws:iam:RolePolicyAttachment eksCluster-eksRole-90eb1c99 created + │ │ └─ aws:iam:RolePolicyAttachment eksCluster-eksRole-4b490823 created + │ ├─ eks:index:ServiceRole eksCluster-instanceRole created + │ │ ├─ aws:iam:Role eksCluster-instanceRole-role created + │ │ ├─ aws:iam:RolePolicyAttachment eksCluster-instanceRole-e1b295bd created + │ │ ├─ aws:iam:RolePolicyAttachment eksCluster-instanceRole-3eb088f2 created + │ │ └─ aws:iam:RolePolicyAttachment eksCluster-instanceRole-03516f97 created + │ ├─ pulumi-nodejs:dynamic:Resource eksCluster-cfnStackName created + │ ├─ aws:ec2:SecurityGroup eksCluster-eksClusterSecurityGroup created + │ ├─ aws:iam:InstanceProfile eksCluster-instanceProfile created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksClusterInternetEgressRule created + │ ├─ aws:eks:Cluster eksCluster-eksCluster created + │ ├─ aws:ec2:SecurityGroup eksCluster-nodeSecurityGroup created + │ ├─ pulumi-nodejs:dynamic:Resource eksCluster-vpc-cni created + │ ├─ pulumi:providers:kubernetes eksCluster-eks-k8s created + │ ├─ kubernetes:core:ConfigMap eksCluster-nodeAccess created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksClusterIngressRule created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksExtApiServerClusterIngressRule created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksNodeIngressRule created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksNodeInternetEgressRule created + │ ├─ aws:ec2:SecurityGroupRule eksCluster-eksNodeClusterIngressRule created + │ ├─ aws:ec2:LaunchConfiguration eksCluster-nodeLaunchConfiguration created + │ ├─ aws:cloudformation:Stack eksCluster-nodes created + │ └─ pulumi:providers:kubernetes eksCluster-provider created + ├─ awsx:ecr:Repository server-side-service created + │ ├─ aws:ecr:Repository server-side-service created + │ └─ aws:ecr:LifecyclePolicy server-side-service created + ├─ awsx:ecr:Repository client-side-service created + │ ├─ aws:ecr:Repository client-side-service created + │ └─ aws:ecr:LifecyclePolicy client-side-service created + ├─ awsx:ecr:Repository database-side-service created + │ ├─ aws:ecr:Repository database-side-service created + │ └─ aws:ecr:LifecyclePolicy database-side-service created + ├─ aws:ebs:Volume storage-volume created + ├─ kubernetes:apps:Deployment database-side-service created + ├─ kubernetes:core:Service database-side-listener created + ├─ kubernetes:apps:Deployment server-side-service created + ├─ kubernetes:core:Service server-side-listener created + ├─ kubernetes:apps:Deployment client-side-service created + └─ kubernetes:core:Service client-side-listener created Outputs: URL : "ab89804d273d8484cb9e64c93975f4ad-1303584037.us-west-2.elb.amazonaws.com" kubeConfig: {...} Resources: + 44 created Duration: 18m10s
Verify that the ECS instance exists by connecting to it on port 3000 in a browser window.
Clean up
To clean up resources, run pulumi destroy
and answer the confirmation question at the prompt.