Skip to content

Commit d61f7be

Browse files
authored
Merge pull request #1875 from paigecalvert/add-v4-placeholder
Copy v3 versioned_docs to v4 docs
2 parents 0bedbb6 + 73acf71 commit d61f7be

File tree

144 files changed

+17498
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+17498
-13
lines changed

docs/_v4-in-progress.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:::warning
2+
This page has not yet been updated for Helm 4. Some of the content might be inaccurate or not applicable to Helm 4. For more information about the Helm 4 new features, improvements, and breaking changes, see [Helm 4 Overview](/overview.md).
3+
:::

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 2
3-
sidebar_label: Full Changelog
3+
sidebar_label: Helm 4 Full Changelog
44
---
55

66
# Helm 4 Full Changelog
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: General Conventions
3+
description: General conventions for charts.
4+
sidebar_position: 1
5+
---
6+
7+
This part of the Best Practices Guide explains general conventions.
8+
9+
## Chart Names
10+
11+
Chart names must be lower case letters and numbers. Words _may_ be separated
12+
with dashes (-):
13+
14+
Examples:
15+
16+
```
17+
drupal
18+
nginx-lego
19+
aws-cluster-autoscaler
20+
```
21+
22+
Neither uppercase letters nor underscores can be used in chart names. Dots
23+
should not be used in chart names.
24+
25+
## Version Numbers
26+
27+
Wherever possible, Helm uses [SemVer 2](https://semver.org) to represent version
28+
numbers. (Note that Docker image tags do not necessarily follow SemVer, and are
29+
thus considered an unfortunate exception to the rule.)
30+
31+
When SemVer versions are stored in Kubernetes labels, we conventionally alter
32+
the `+` character to an `_` character, as labels do not allow the `+` sign as a
33+
value.
34+
35+
## Formatting YAML
36+
37+
YAML files should be indented using _two spaces_ (and never tabs).
38+
39+
## Usage of the Words Helm and Chart
40+
41+
There are a few conventions for using the words _Helm_ and _helm_.
42+
43+
- _Helm_ refers to the project as a whole
44+
- `helm` refers to the client-side command
45+
- The term `chart` does not need to be capitalized, as it is not a proper noun
46+
- However, `Chart.yaml` does need to be capitalized because the file name is
47+
case sensitive
48+
49+
When in doubt, use _Helm_ (with an uppercase 'H').
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Custom Resource Definitions
3+
description: How to handle creating and using CRDs.
4+
sidebar_position: 7
5+
---
6+
7+
This section of the Best Practices Guide deals with creating and using Custom
8+
Resource Definition objects.
9+
10+
When working with Custom Resource Definitions (CRDs), it is important to
11+
distinguish two different pieces:
12+
13+
- There is a declaration of a CRD. This is the YAML file that has the kind
14+
`CustomResourceDefinition`
15+
- Then there are resources that _use_ the CRD. Say a CRD defines
16+
`foo.example.com/v1`. Any resource that has `apiVersion: example.com/v1` and
17+
kind `Foo` is a resource that uses the CRD.
18+
19+
## Install a CRD Declaration Before Using the Resource
20+
21+
Helm is optimized to load as many resources into Kubernetes as fast as possible.
22+
By design, Kubernetes can take an entire set of manifests and bring them all
23+
online (this is called the reconciliation loop).
24+
25+
But there's a difference with CRDs.
26+
27+
For a CRD, the declaration must be registered before any resources of that CRDs
28+
kind(s) can be used. And the registration process sometimes takes a few seconds.
29+
30+
### Method 1: Let `helm` Do It For You
31+
32+
With the arrival of Helm 3, we removed the old `crd-install` hooks for a more
33+
simple methodology. There is now a special directory called `crds` that you can
34+
create in your chart to hold your CRDs. These CRDs are not templated, but will
35+
be installed by default when running a `helm install` for the chart. If the CRD
36+
already exists, it will be skipped with a warning. If you wish to skip the CRD
37+
installation step, you can pass the `--skip-crds` flag.
38+
39+
#### Some caveats (and explanations)
40+
41+
There is no support at this time for upgrading or deleting CRDs using Helm. This
42+
was an explicit decision after much community discussion due to the danger for
43+
unintentional data loss. Furthermore, there is currently no community consensus
44+
around how to handle CRDs and their lifecycle. As this evolves, Helm will add
45+
support for those use cases.
46+
47+
The `--dry-run` flag of `helm install` and `helm upgrade` is not currently
48+
supported for CRDs. The purpose of "Dry Run" is to validate that the output of
49+
the chart will actually work if sent to the server. But CRDs are a modification
50+
of the server's behavior. Helm cannot install the CRD on a dry run, so the
51+
discovery client will not know about that Custom Resource (CR), and validation
52+
will fail. You can alternatively move the CRDs to their own chart or use `helm
53+
template` instead.
54+
55+
Another important point to consider in the discussion around CRD support is how
56+
the rendering of templates is handled. One of the distinct disadvantages of the
57+
`crd-install` method used in Helm 2 was the inability to properly validate
58+
charts due to changing API availability (a CRD is actually adding another
59+
available API to your Kubernetes cluster). If a chart installed a CRD, `helm` no
60+
longer had a valid set of API versions to work against. This is also the reason
61+
behind removing templating support from CRDs. With the new `crds` method of CRD
62+
installation, we now ensure that `helm` has completely valid information about
63+
the current state of the cluster.
64+
65+
### Method 2: Separate Charts
66+
67+
Another way to do this is to put the CRD definition in one chart, and then put
68+
any resources that use that CRD in _another_ chart.
69+
70+
In this method, each chart must be installed separately. However, this workflow
71+
may be more useful for cluster operators who have admin access to a cluster
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Dependencies
3+
description: Covers best practices for Chart dependencies.
4+
sidebar_position: 4
5+
---
6+
7+
import Helm4 from "../_v4-in-progress.mdx"
8+
9+
<Helm4/>
10+
11+
This section of the guide covers best practices for `dependencies` declared in
12+
`Chart.yaml`.
13+
14+
## Versions
15+
16+
Where possible, use version ranges instead of pinning to an exact version. The
17+
suggested default is to use a patch-level version match:
18+
19+
```yaml
20+
version: ~1.2.3
21+
```
22+
23+
This will match version `1.2.3` and any patches to that release. In other
24+
words, `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0`
25+
26+
For the complete version matching syntax, please see the [semver
27+
documentation](https://github.com/Masterminds/semver#checking-version-constraints).
28+
29+
### Prerelease versions
30+
31+
The above versioning constraints will not match on pre-release versions.
32+
For example `version: ~1.2.3` will match `version: ~1.2.4` but not `version: ~1.2.3-1`.
33+
The following provides a pre-release as well as patch-level matching:
34+
35+
```yaml
36+
version: ~1.2.3-0
37+
```
38+
39+
### Repository URLs
40+
41+
Where possible, use `https://` repository URLs, followed by `http://` URLs.
42+
43+
If the repository has been added to the repository index file, the repository
44+
name can be used as an alias of URL. Use `alias:` or `@` followed by repository
45+
names.
46+
47+
File URLs (`file://...`) are considered a "special case" for charts that are
48+
assembled by a fixed deployment pipeline.
49+
50+
When using [downloader plugins](/topics/plugins.mdx#downloader-plugins)
51+
the URL scheme will be specific to the plugin. Note, a user of the chart will
52+
need to have a plugin supporting the scheme installed to update or build the
53+
dependency.
54+
55+
Helm cannot perform dependency management operations on the dependency when the
56+
`repository` field is left blank. In that case Helm will assume the dependency
57+
is in a sub-directory of the `charts` folder with the name being the same as the
58+
`name` property for the dependency.
59+
60+
## Conditions and Tags
61+
62+
Conditions or tags should be added to any dependencies that _are optional_. Note that by default a `condition` is `true`.
63+
64+
The preferred form of a condition is:
65+
66+
```yaml
67+
condition: somechart.enabled
68+
```
69+
70+
Where `somechart` is the chart name of the dependency.
71+
72+
When multiple subcharts (dependencies) together provide an optional or swappable
73+
feature, those charts should share the same tags.
74+
75+
For example, if both `nginx` and `memcached` together provide performance
76+
optimizations for the main app in the chart, and are required to both be present
77+
when that feature is enabled, then they should both have a tags section like
78+
this:
79+
80+
```yaml
81+
tags:
82+
- webaccelerator
83+
```
84+
85+
This allows a user to turn that feature on and off with one tag.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Best Practices
3+
sidebar: true
4+
sidebar_position: 4
5+
---
6+
7+
# The Chart Best Practices Guide
8+
9+
This guide covers the Helm Team's considered best practices for creating charts.
10+
It focuses on how charts should be structured.
11+
12+
We focus primarily on best practices for charts that may be publicly deployed.
13+
We know that many charts are for internal-use only, and authors of such charts
14+
may find that their internal interests override our suggestions here.
15+
16+
17+
import DocCardList from '@theme/DocCardList';
18+
19+
<DocCardList />
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Labels and Annotations
3+
description: Covers best practices for using labels and annotations in your Chart.
4+
sidebar_position: 5
5+
---
6+
7+
This part of the Best Practices Guide discusses the best practices for using
8+
labels and annotations in your chart.
9+
10+
## Is it a Label or an Annotation?
11+
12+
An item of metadata should be a label under the following conditions:
13+
14+
- It is used by Kubernetes to identify this resource
15+
- It is useful to expose to operators for the purpose of querying the system.
16+
17+
For example, we suggest using `helm.sh/chart: NAME-VERSION` as a label so that
18+
operators can conveniently find all of the instances of a particular chart to
19+
use.
20+
21+
If an item of metadata is not used for querying, it should be set as an
22+
annotation instead.
23+
24+
Helm hooks are always annotations.
25+
26+
## Standard Labels
27+
28+
The following table defines common labels that Helm charts use. Helm itself
29+
never requires that a particular label be present. Labels that are marked REC
30+
are recommended, and _should_ be placed onto a chart for global consistency.
31+
Those marked OPT are optional. These are idiomatic or commonly in use, but are
32+
not relied upon frequently for operational purposes.
33+
34+
Name|Status|Description
35+
-----|------|----------
36+
`app.kubernetes.io/name` | REC | This should be the app name, reflecting the entire app. Usually `{{ template "name" . }}` is used for this. This is used by many Kubernetes manifests, and is not Helm-specific.
37+
`helm.sh/chart` | REC | This should be the chart name and version: `{{ .Chart.Name }}-{{ .Chart.Version \| replace "+" "_" }}`.
38+
`app.kubernetes.io/managed-by` | REC | This should always be set to `{{ .Release.Service }}`. It is for finding all things managed by Helm.
39+
`app.kubernetes.io/instance` | REC | This should be the `{{ .Release.Name }}`. It aids in differentiating between different instances of the same application.
40+
`app.kubernetes.io/version` | OPT | The version of the app and can be set to `{{ .Chart.AppVersion }}`.
41+
`app.kubernetes.io/component` | OPT | This is a common label for marking the different roles that pieces may play in an application. For example, `app.kubernetes.io/component: frontend`.
42+
`app.kubernetes.io/part-of` | OPT | When multiple charts or pieces of software are used together to make one application. For example, application software and a database to produce a website. This can be set to the top level application being supported.
43+
44+
You can find more information on the Kubernetes labels, prefixed with
45+
`app.kubernetes.io`, in the [Kubernetes
46+
documentation](https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/).

docs/chart_best_practices/pods.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: Pods and PodTemplates
3+
description: Discusses formatting the Pod and PodTemplate portions in Chart manifests.
4+
sidebar_position: 6
5+
---
6+
7+
This part of the Best Practices Guide discusses formatting the Pod and
8+
PodTemplate portions in chart manifests.
9+
10+
The following (non-exhaustive) list of resources use PodTemplates:
11+
12+
- Deployment
13+
- ReplicationController
14+
- ReplicaSet
15+
- DaemonSet
16+
- StatefulSet
17+
18+
## Images
19+
20+
A container image should use a fixed tag or the SHA of the image. It should not
21+
use the tags `latest`, `head`, `canary`, or other tags that are designed to be
22+
"floating".
23+
24+
25+
Images _may_ be defined in the `values.yaml` file to make it easy to swap out
26+
images.
27+
28+
```yaml
29+
image: {{ .Values.redisImage | quote }}
30+
```
31+
32+
An image and a tag _may_ be defined in `values.yaml` as two separate fields:
33+
34+
```yaml
35+
image: "{{ .Values.redisImage }}:{{ .Values.redisTag }}"
36+
```
37+
38+
## ImagePullPolicy
39+
40+
`helm create` sets the `imagePullPolicy` to `IfNotPresent` by default by doing
41+
the following in your `deployment.yaml`:
42+
43+
```yaml
44+
imagePullPolicy: {{ .Values.image.pullPolicy }}
45+
```
46+
47+
And `values.yaml`:
48+
49+
```yaml
50+
image:
51+
pullPolicy: IfNotPresent
52+
```
53+
54+
Similarly, Kubernetes defaults the `imagePullPolicy` to `IfNotPresent` if it is
55+
not defined at all. If you want a value other than `IfNotPresent`, simply update
56+
the value in `values.yaml` to your desired value.
57+
58+
59+
## PodTemplates Should Declare Selectors
60+
61+
All PodTemplate sections should specify a selector. For example:
62+
63+
```yaml
64+
selector:
65+
matchLabels:
66+
app.kubernetes.io/name: MyName
67+
template:
68+
metadata:
69+
labels:
70+
app.kubernetes.io/name: MyName
71+
```
72+
73+
This is a good practice because it makes the relationship between the set and
74+
the pod.
75+
76+
But this is even more important for sets like Deployment. Without this, the
77+
_entire_ set of labels is used to select matching pods, and this will break if
78+
you use labels that change, like version or release date.

0 commit comments

Comments
 (0)