Develop Helm Applications directly in Kubernetes

Ramiro Berrelleza
Jan 9, 2019 · 3 min read

Deploying applications in Kubernetes can be complicated. Even the simplest application will require creating a series of interdependent components (e.g.namespace, RBAC rules, ingress, services, deployments, pods, secrets ...), each with one or more YAML manifests.

Helm is the de-facto package manager for Kubernetes applications that allows developers and operators to easily package, configure, and deploy applications onto Kubernetes clusters. If you're building an application that will run in Kubernetes, you should really look into leveraging Helm.

In this tutorial we'll show you how to deploy your first Helm chart and how to use Okteto to develop your application directly in the cluster, saving you tons of time and integration problems.

This tutorial assumes that you have some Kubernetes knowledge and that you have access to a cloud provider, or you can set it up locally.

Helm 101

If you are new to Helm, I recommend you first go through one of the following articles:

Setup a Kubernetes cluster

The official Kubernetes setup guide covers this topic extensively. For the purpose of this tutorial, I recommend you either use Okteto Cloud or deploy Minikube locally.

Install Helm

For OSX you can install it via brew by running the command below.

$ brew install helm

Check the official docs for other alternatives.

Deploy your chart

Get a local version of the Sample Chart by executing the following commands:

$ git clone https://github.com/okteto/samples
$ cd samples/helm

Deploy the chart using the helm install command.

$ helm install vote chart --set service.type=NodePortNAME: vote
LAST DEPLOYED: Mon Mar 30 15:59:23 2020
NAMESPACE: ramiro
STATUS: deployed
REVISION: 1
TEST SUITE: None

The output of the install command displays a summary of the resources created, and it renders the contents of the NOTES.txt file. Run the commands listed there to get a URL of your application.

For Minikube:

$ export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services vote-chart)$ export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}")

$ echo http://$NODE_IP:$NODE_PORT

For Okteto Cloud, just log into the Okteto Cloud dashboard:

Develop your application

If you haven’t install the Okteto CLI yet, the installation guide has instructions on how to do it for MacOS, Windows, and Linux.

Okteto works by reading the okteto.yaml manifest:

name: vote
labels:
app.kubernetes.io/name: vote
command: ["python", "app.py"]
workdir: /src
environment:
- FLASK_ENV=development
forward:
- 8080:8080

Run the okteto up to start your Cloud Native Development environment.

$ okteto up                                                                               
✓ Development environment activated
✓ Files synchronized
Namespace: ramiro
Name: vote
* Serving Flask app "app" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 449-272-272

At this point, your application is running directly in the cluster (our github repo has an in-depth explanation of how this works). Notice the processed bytext near the bottom, it's your kubernetes namespace and pod name. Go back to your browser and reload your tab to see the application in action.

Try it out a few times, just to make sure everything works. Now open the source of the application on your favorite IDE. Edit the file vote/app.py and change the option_a in line 14 from "Cats" to "Otters". Save your changes.

Go back to the browser, refresh the Voting App UI, and notice that your code changes are instantly applied. No commit, build or push required!

Conclusion

Helm is a great modern choice for deploying and managing applications. But developing charts and applications using the traditional developer workflow is slow and full of friction. Developing directly in the cluster makes the entire process a lot more efficient. Okteto is here to help you with that.

Okteto

Kubernetes for Developers

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store