Skip to content

Latest commit

 

History

History
65 lines (38 loc) · 2.82 KB

File metadata and controls

65 lines (38 loc) · 2.82 KB

Define And Deploy The App To Dev With Helm

At its core, a Helm chart is simply a directory that has three required items:

  • templates directory - a directory of templated Kubernetes resources. Templates are Golang-based.

  • values.yaml file - contains values for the templated resources

  • chart.yaml file - contains metadata about the chart

Helm templates are the key to defining Kubernetes resources in a dynamic, reusable way. With Helm templates, you can use programming logic to help define your Kubernetes resources. You can also create reusable functions using the Sprig framework. These functions are called partials.

Once you define all of your Kubernetes resources and specify their values in a Helm chart, you use the Helm CLI to install that chart to your Kubernetes cluster. This creates a running instance of your application called a Helm release.

Setup

chmod +x manuscript/define-deploy-dev/helm.sh

# This script sets the `ingress.host` and `image.repository` values in the helm/app/values.yaml file using environment variables that we set earlier in the journey
./manuscript/define-deploy-dev/helm.sh

Do

# List the Helm templates. There are a lot here. Some are irrelevant now - we'll get to those later in the journey.
ls -1 helm/app/templates

# View the templates for the Kubernetes Deployment, Service, and Ingress. The Helm templating is denoted by double brackets.

# Note that the values that are likely to change have been factored out. We'll set those in a values.yaml file.
cat helm/app/templates/deployment.yaml

cat helm/app/templates/service.yaml

cat helm/app/templates/ingress.yaml

# View the values.yaml file. Earlier, when we ran the `./manuscript/define-deploy-dev/helm.sh` script, we set the `ingress.host` and `image.repository` to reflect our personal journey.
cat helm/app/values.yaml

# In the values.yaml file, set the `.image.tag` to be the tag of the image we recently created.
yq --inplace ".image.tag = \"$TAG\"" helm/app/values.yaml

# See that the `.image.tag` value now reflects your image
cat helm/app/values.yaml

# Deploy your application!
helm upgrade --install cncf-demo helm/app --namespace dev

# Generate the url
echo "http://cncf-demo-dev.$DOMAIN"

# Open it in a browser. If your browser complains that it is unsafe, don't worry! We are going to add certificates next!
  • If you chose kbld to build images, you'll need to run helm template command to convert the chart into "pure" Kubernetes YAML manifests. Then with one command you can use kbld to build the images, push them to a registry, and modify the manifests with image SHAs. Next use kubectl to apply the manifests generated by kbld.

Continue The Adventure