Helm
Create a helm-chart
I will use my publicly available comments app to build a helm-chart. Get the default scaffolding from helm with:
helm create comments
What I changed to begin with:
In Charts.yaml I changed a few:
- appVersion: “53” (so that it matches the tag of the image I want to deploy)
- name: comments
- Description: A Helm chart for the comments stack
In values.yaml:
- replicaCount: 3 (because I have 3 worker nodes on my cluster)
- image.repository: toubivankenoubi/comments (my image is available on docker hub)
Furthermore, some snippets from the values.yaml with a little explanation:
service:
type: ClusterIP
port: 8080
ingress:
enabled: true
className: "nginx"
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: k8s-node-1.tobisyurt.local
paths:
- path: /comments
pathType: Prefix
- host: k8s-node-2.tobisyurt.local
paths:
- path: /comments
pathType: Prefix
- host: k8s-node-3.tobisyurt.local
paths:
- path: /comments
pathType: Prefix
- host: tobisyurt.net
paths:
- path: /comments
pathType: Prefix
tls: []
I only changed the port of the clusterIp service, because I was used to 8080.
In the Ingress I added a lot of hosts. The important one is tobisyurt.net which is the public facing. Because I want to be able to test it locally too, I added my internal(private network) DNS entries for the 3 k8s nodes.
helm dependencies
The comments app is dependent on a mongodb, so we add that to the dependencies in the Chart.yaml:
...
dependencies:
- name: mongodb
version: "12.15.4"
repository: "https://registry-2.docker.io/bitnamicharts"
If you deploy this chart as is, it would deploy the subchart mongodb with all its defaults. Normally you need to override some of these values, so that your pods talk to each other properly.
In the values.yml
in your main chart you can override values of your subcharts as follows:
... other values of your chart ...
mongodb:
persistence:
size: 499Mi
auth:
rootPassword: "a password..."
Using the helm chart
Deployed with:
helm install comments-test ./comments -n comments
Uninstalled with:
helm uninstall comments-test -n comments
Test it without deploying it on the cluster (dry run):
helm install --debug --dry-run comments-test ./comments
Upgrade to the latest chart release:
helm upgrade comments-test . -n comments