-
Install pulumi
brew install pulumi/tap/pulumi
-
Install nodejs
brew install node
-
Install kubernetes cluster using docker desktop
This should create an entry in your /etc/hosts as below
# Added by Docker Desktop # To allow the same kube context to work on the host and the container: 127.0.0.1 kubernetes.docker.internal # End of section
-
Create a folder and unzip the code.
mkdir pulumi && cd pulumi unzip pulumi-hello-world cd pulumi-hello-world
-
Deploy the app into k8s cluster using the following command
pulumi up --logtostderr
You should see something similar on your console as shown below when app gets deployed in k8s cluster.
Type Name Status
+ pulumi:pulumi:Stack hello-world-hello-world created (0.70s)
+ ├─ kubernetes:core/v1:Namespace hello-app created (0.18s)
+ ├─ kubernetes:core/v1:ConfigMap hello-app created (0.17s)
+ ├─ kubernetes:core/v1:Service hello-app created (10s)
+ └─ kubernetes:apps/v1:Deployment hello-app created (2s)
Resources:
+ 5 created
Duration: 13s
Copy the following URL into your browser
http://kubernetes.docker.internal/hello
You should be able to see similar output.
Hello from the Kubernetes worker node with IP address: 192.168.65.4
This repository contains a nodejs application under app
directory. It hosts the endpoint /hello
, which
returns a pre-configured message and IP address of the node where the application pod is running.
-
To build node js application docker container run the following command.
docker build . -t node-hello-world
-
Tag the image
docker tag node-hello-world:latest <your-repo>/node-hello-world:latest
-
Push the docker image into a docker repository
docker push <your-repo>/node-hello-world:latest