5 steps to bring DevX automation to your company
Get the guide

Develop Helm Applications directly in Kubernetes

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 the Okteto Cloud free tier 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 the Sample 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=NodePort
NAME: 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 following commands to the URL of your application:

For Minikube:

$ export NODE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].nodePort}" services vote)

$ export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}")

$ echo [http://$NODE_IP:$NODE_PORT](http://%24NODE_IP:%24NODE_PORT)

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

NGINX Okteto Cloud dashboard

Develop your application

Once we have a basic chart up and running, it's time to develop our own application. At this point, we would have to follow the typical developer workflow:

  1. Build and test the application locally
  2. Build a container
  3. Give the container a label
  4. Push the container to a registry
  5. Update the values in our chart to match the new Docker image
  6. Upgrade the chart
  7. Test your changes
  8. Go back to 1

Instead of following that workflow, we're going to save time and friction by developing our application directly in the cluster. The Cloud Native way.

Cloud Native Development

Cloud Native Development is THE way to develop Cloud Native Applications. Instead of wasting time and resources by developing locally and then testing in the cluster, we just do everything directly in the cluster. We open sourced Okteto to make it easier than ever to become a Cloud Native Developer.

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
selector:
  app.kubernetes.io/name: vote
command: ["python", "app.py"]
workdir: /src
environment:
  - FLASK_ENV=development
forward:
  - 8080:8080

Run the okteto up to activate your development container:

$ okteto up
 ✓  Development container 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.

The voting app running

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 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.

Ramiro BerrellezaCEO & Co-founder View all posts

Automate Provisioning Any Dev Resource on Any Cloud Provider With Pulumi and Okteto

The Value It is common in today's landscape to build microservices-based applications that leverage resources like RDS databases, storage buckets, etc...

October 19, 2023
Avatar of Arsh SharmaAvatar of Arsh SharmaArsh Sharma

How Developers Can Seamlessly Collaborate When Building Microservice Apps

Building microservices based applications is inherently challenging. Given the multitude of components involved, it is unrealistic to expect any individual...

October 10, 2023
Avatar of Arsh SharmaAvatar of Arsh SharmaArsh Sharma