k8s_pkg_manager
Introduction
Helm is the best way to find, share, and use software built Kubernetes, a software in k8s may be one separate deployment or several deployments that works together to provides service to user, Helm manages these yaml files with concept Chart, Chart is a bundle of yaml files and other files related to the software
, Chart helps you define, install, and upgrade, rollback
even the most complex Kubernetes application, Chart likes deb package
which creates package with xx.deb, while to create an application for k8s by Helm, you need to create Chart files with fixed layout and follow its syntax
.
For Helm, there are three important concepts:
- The chart is a bundle of information necessary to create an instance of a Kubernetes application. mostly for complex application, but for deployment only, no auto scale, no monitor with Chart.
- The config contains configuration information that can be merged into a packaged chart to create a releasable object.
- 🟢 A release is a running instance of a chart, combined with a specific config. with release version, we can update/rollback a chart
Command
In order to use helm, we need to install it firstly with below command
1 | # Centos7 to install snap |
🔴 As helm installs application in k8s(create deployment), hence in order to use it, you MUST have kubernetes and kubectl installed before. there are required!!!
Helm and K8s compatibility
1 | Helm Version Supported Kubernetes Versions |
Command used for helm
1 | $ sudo snap install helm --classic |
Build a pkg with Helm
A chart is a collection of files that describe a related set of Kubernetes resources
. A single chart might be used to deploy something simple, like a memcached pod, or something complex, like a full web app stack with HTTP servers, databases, caches, and so on.
Charts are created as files laid out in a particular directory tree. They can be packaged into versioned archives to be deployed.
1 | wordpress/ |
Details about charts, refer to charts guidline
Helm Chart templates are written in the Go template language, with the addition of 50 or so add-on template functions from the Sprig library and a few other specialized functions.
All template files are stored in a chart’s templates/ folder. When Helm renders the charts, it will pass every file in that directory through the template engine
Predefined Values
Values that are supplied via a values.yaml file (or via the –set flag) are accessible from the .Values
object in a template. But there are other pre-defined pieces of data you can access in your templates.
The following values are pre-defined, are available to every template, and cannot be overridden. As with all values, the names are case sensitive.
- Release.Name: The name of the release (not the chart)
- Release.Namespace: The namespace the chart was released to.
- Release.Service: The service that conducted the release.
- Release.IsUpgrade: This is set to true if the current operation is an upgrade or rollback.
- Release.IsInstall: This is set to true if the current operation is an install.
- Chart: The contents of the Chart.yaml. Thus, the chart version is obtainable as Chart.Version and the maintainers are in Chart.Maintainers.
- Files: A map-like object containing all non-special files in the chart. This will not give you access to templates, but will give you access to additional files that are present (unless they are excluded using .helmignore). Files can be accessed using { { index .Files “file.name” } } or using the { {.Files.Get name } } function. You can also access the contents of the file as byte using { { .Files.GetBytes } }
- Capabilities: A map-like object that contains information about the versions of Kubernetes ({ { .Capabilities.KubeVersion } }) and the supported Kubernetes API versions ({ { .Capabilities.APIVersions.Has “batch/v1” } })
NOTE: Any unknown Chart.yaml fields will be dropped. They will not be accessible inside of the Chart object. Thus, Chart.yaml cannot be used to pass arbitrarily structured data into the template. The values file can be used for that, though.
Steps to create your own chart
1 | $ helm create mychart |