Helm Developer Guide

You can upload the Helm chart of an app to KubeSphere so that tenants with necessary permissions can deploy it. This tutorial demonstrates how to prepare Helm charts using NGINX as an example.

Install Helm

If you have already installed KubeSphere, then Helm is deployed in your environment. Otherwise, refer to the Helm documentation to install Helm first.

Create a Local Repository

Execute the following commands to create a repository on your machine.

  1. mkdir helm-repo
  1. cd helm-repo

Create an App

Use helm create to create a folder named nginx, which automatically creates YAML templates and directories for your app. Generally, it is not recommended to change the name of files and directories in the top level directory.

  1. $ helm create nginx
  2. $ tree nginx/
  3. nginx/
  4. ├── charts
  5. ├── Chart.yaml
  6. ├── templates
  7. ├── deployment.yaml
  8. ├── _helpers.tpl
  9. ├── ingress.yaml
  10. ├── NOTES.txt
  11. └── service.yaml
  12. └── values.yaml

Chart.yaml is used to define the basic information of the chart, including name, API, and app version. For more information, see Chart.yaml File.

An example of the Chart.yaml file:

  1. apiVersion: v1
  2. appVersion: "1.0"
  3. description: A Helm chart for Kubernetes
  4. name: nginx
  5. version: 0.1.0

When you deploy Helm-based apps to Kubernetes, you can edit the values.yaml file on the KubeSphere console directly.

An example of the values.yaml file:

  1. # Default values for test.
  2. # This is a YAML-formatted file.
  3. # Declare variables to be passed into your templates.
  4. replicaCount: 1
  5. image:
  6. repository: nginx
  7. tag: stable
  8. pullPolicy: IfNotPresent
  9. nameOverride: ""
  10. fullnameOverride: ""
  11. service:
  12. type: ClusterIP
  13. port: 80
  14. ingress:
  15. enabled: false
  16. annotations: {}
  17. # kubernetes.io/ingress.class: nginx
  18. # kubernetes.io/tls-acme: "true"
  19. path: /
  20. hosts:
  21. - chart-example.local
  22. tls: []
  23. # - secretName: chart-example-tls
  24. # hosts:
  25. # - chart-example.local
  26. resources: {}
  27. # We usually recommend not to specify default resources and to leave this as a conscious
  28. # choice for the user. This also increases chances charts run on environments with little
  29. # resources, such as Minikube. If you do want to specify resources, uncomment the following
  30. # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  31. # limits:
  32. # cpu: 100m
  33. # memory: 128Mi
  34. # requests:
  35. # cpu: 100m
  36. # memory: 128Mi
  37. nodeSelector: {}
  38. tolerations: []
  39. affinity: {}

Refer to Helm Specifications to edit files in the nginx folder and save them when you finish editing.

Create an Index File (Optional)

To add a repository with an HTTP or HTTPS URL in KubeSphere, you need to upload an index.yaml file to the object storage in advance. Use Helm to create the index file by executing the following command in the previous directory of nginx.

  1. helm repo index .
  1. $ ls
  2. index.yaml nginx

Note

  • If the repository URL is S3-styled, an index file will be created automatically in the object storage when you add apps to the repository.

  • For more information about how to add repositories to KubeSphere, see Import an Helm Repository.

Package the Chart

Go to the previous directory of nginx and execute the following command to package your chart which creates a .tgz package.

  1. helm package nginx
  1. $ ls
  2. nginx nginx-0.1.0.tgz

Upload Your App

Now that you have your Helm-based app ready, you can load it to KubeSphere and test it on the platform.

See Also

Helm Specifications

Import an Helm Repository

Feedback

Was this page Helpful?

Yes No