Charts and resources

Questions on configuring applications, charts and kubernetes resources

How do I add a chart?

To add a new chart add to the helmfiles/mynamespace/helmfile.yaml file follow the add chart guide.

How do I customise an App in an Environment?

With the new helm 3 based boot every environment uses boot - so there is a single way to configure anything whether its in the dev, staging or production environment and whether or not you are using multiple clusters.

See how to customise a chart

How do I use a chart from a secure repository

Some chart repositories need a username and password to access them.

So to access those chart repositories you can the username and password into the helmfile.yaml

However the username/passwords are probably secret. So you can create a kubernetes Secret called jx-boot-job-env-vars which is automatically used in the boot Job

e.g.

# lets make sure we are in the jx-git-operator namespace
jx ns jx-git-operator

kubectl create secret generic jx-boot-job-env-vars \
  --from-literal=MYREPO_USERNAME=someuser \
  --from-literal=MYREPO_PASSWORD='S!B\*d$zDsb='

Any environment variables defined in the jx-boot-job-env-vars Secret can then be used in your helmfile.yaml as follows:

repositories:
- name: myrepo
  url: https://something.com 
  username: '{{ requiredEnv "MYREPO_USERNAME" }}' 
  password: '{{ requiredEnv "MYREPO_PASSWORD" }}'
releases:
- chart: myrepo/mychart 
  name: mychart
  version: 1.2.3

How do I add a kubernetes resource?

To add a new kubernetes resource follow the add resources guide.

The default helmfile.yaml files take references to helm charts.

If you want to deploy one or more kubernetes resources wrap them in a local chart in your dev cluster git repository

How do I deploy an app with no chart?

Some microservices on kubernetes do not yet come packaged as a helm chart.

e.g. if the only instructions on the website of the microservice is something like

# install this appication via:
kubectl apply -f https://acme.com/foo.yaml

If you want you can just install it like the above kubectl apply command.

Though you then lose the benefits of GitOps in that all changes to your cluster are auditted and versioned in git and it’s easy to rollback changes.

So another approach is to follow the create a local chart instructions:

mkdir charts/myname/templates
curl -L https://acme.com/foo.yaml > charts/myname/templates/resources.yaml
echo "apiVersion: v1
description: A Helm chart for myname
name: myname
version: 0.0.1" > charts/myname/Chart.yaml

Then add the following chart: line to your helmfiles/$namespace/helmfile.yaml in the releases: section for the namespace you want to deploy it in…

releases:
- chart: ./charts/myname

If this is a brand new namespace which didn’t have a helmfiles/$namespace/helmfile.yaml then make sure you also add an entry in the root helmfile.yaml file of:

helmfiles:
- path: helmfiles/$namespace/helmfile.yaml

Note that $namespace in the above files should be expanded to the actual namespace you are deploying it to; e.g. jx or jx-staging or whatever.

The above may seem like a bit of work compared to kubectl apply but it does mean at any time you can upgrade the app by re-running the command:

curl -L https://acme.com/foo.yaml > charts/myname/templates/resources.yaml

You can also easily uninstall the application or modify the YAML in git at any time.


Last modified March 24, 2021: chore: fix link (36cde5c326)