How to Deploy a Helm “Hello World” app onto Kubernetes

We will create a simple Hello World static HTTP Service using Helm, package it and release it to an AWS EKS Cluster.

This tutorial expects you to have kubectl as well as helm installed on your computer.

Build our Docker image

Create a file called Dockerfile and place the below into it:

FROM busybox ADD index.html /www/index.html EXPOSE 8008 CMD httpd -p 8008 -h /www; tail -f /dev/null
Code language: Dockerfile (dockerfile)

Now we need to create our index.html file.

Create a new file called index.html and add the following code into it:

<h1>Hello World</h1>
Code language: HTML, XML (xml)

Now you can run Docker, and push all your files!

docker build -t hello-world . docker run -p 80:8008 hello-world
Code language: Bash (bash)

Confirm you can reach http://localhost in your web browser, if you see your Hello World HTML file, then let’s push this Docker image to Docker Hub.

docker login docker tag hello-world aogl/hello-world docker push aogl/hello-world:latest
Code language: Bash (bash)

Note to replace aogl in the above commands with your own username!

Package and install with Helm

Let’s create a skeleton Helm application, use the CLI to do this:

helm create helloworld-chart
Code language: Bash (bash)

Now you should have a new directory called helloworld-chart, which is the same as what you asked Helm to create for you in the previous step.

You can run a helm lint within this directory, if you want Helm to run some config checks against the files. This is not required though, so only do it when you’ve made changes to the files later on.

Now you want to update the values.yaml file and replace a couple of things in the image and service sections:

image: repository: aogl/hello-world tag: latest pullPolicy: IfNotPresent service: name: hello-world type: LoadBalancer externalPort: 80 internalPort: 8008 port: 80
Code language: YAML (yaml)

So minus all the comments, your values.yaml should now look something like this:

replicaCount: 1 image: repository: aogl/hello-world tag: latest pullPolicy: IfNotPresent imagePullSecrets: [] nameOverride: "" fullnameOverride: "" serviceAccount: create: true annotations: {} name: podSecurityContext: {} securityContext: {} service: name: hello-world type: LoadBalancer externalPort: 80 internalPort: 8008 port: 80 ingress: enabled: false annotations: {} hosts: - host: chart-example.local paths: [] tls: [] resources: {} nodeSelector: {} tolerations: [] affinity: {}
Code language: YAML (yaml)

Now we are ready to package our Helm application, run the following from the CLI:

helm package helloworld-chart
Code language: Bash (bash)

You will now have a file called helloworld-chart-0.1.0.tgz which we will now install to our Kubernetes cluster.

helm install helloworld helloworld-chart-0.1.0.tgz kubectl get svc --watch
Code language: Bash (bash)

The --watch command above will sit and wait to receive an IP address for you.

Now using your web browser, you should be able to navigate to your IP or Load Balancer public IP that kubectl gave in response to the last step kubectl get svc.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments