docs: markdown prettyprinting

Signed-off-by: Geoff Baskwill <me@geoffbaskwill.ca>
pull/4905/head
Geoff Baskwill 7 years ago
parent e91e961587
commit 73dc31b248

@ -90,6 +90,7 @@ use. They are all accessible with the same names as in the Go package, but
with a lowercase first letter. For example, `Base` becomes `base`, etc. with a lowercase first letter. For example, `Base` becomes `base`, etc.
The imported functions are: The imported functions are:
- Base - Base
- Dir - Dir
- Ext - Ext
@ -107,7 +108,7 @@ the returned object.
For example, imagine the directory structure: For example, imagine the directory structure:
``` ```txt
foo/: foo/:
foo.txt foo.yaml foo.txt foo.yaml
@ -117,7 +118,6 @@ bar/:
You have multiple options with Globs: You have multiple options with Globs:
```yaml ```yaml
{{ $root := . }} {{ $root := . }}
{{ range $path, $bytes := .Files.Glob "**.yaml" }} {{ range $path, $bytes := .Files.Glob "**.yaml" }}
@ -207,4 +207,3 @@ data:
Currently, there is no way to pass files external to the chart during `helm install`. So if you are asking users to supply data, it must be loaded using `helm install -f` or `helm install --set`. Currently, there is no way to pass files external to the chart during `helm install`. So if you are asking users to supply data, it must be loaded using `helm install -f` or `helm install --set`.
This discussion wraps up our dive into the tools and techniques for writing Helm templates. In the next section we will see how you can use one special file, `templates/NOTES.txt`, to send post-installation instructions to the users of your chart. This discussion wraps up our dive into the tools and techniques for writing Helm templates. In the next section we will see how you can use one special file, `templates/NOTES.txt`, to send post-installation instructions to the users of your chart.

@ -14,9 +14,9 @@ So far, we've used one file, and that one file has contained a single template.
Before we get to the nuts-and-bolts of writing those templates, there is file naming convention that deserves mention: Before we get to the nuts-and-bolts of writing those templates, there is file naming convention that deserves mention:
* Most files in `templates/` are treated as if they contain Kubernetes manifests - Most files in `templates/` are treated as if they contain Kubernetes manifests
* The `NOTES.txt` is one exception - The `NOTES.txt` is one exception
* But files whose name begins with an underscore (`_`) are assumed to _not_ have a manifest inside. These files are not rendered to Kubernetes object definitions, but are available everywhere within other chart templates for use. - But files whose name begins with an underscore (`_`) are assumed to _not_ have a manifest inside. These files are not rendered to Kubernetes object definitions, but are available everywhere within other chart templates for use.
These files are used to store partials and helpers. In fact, when we first created `mychart`, we saw a file called `_helpers.tpl`. That file is the default location for template partials. These files are used to store partials and helpers. In fact, when we first created `mychart`, we saw a file called `_helpers.tpl`. That file is the default location for template partials.
@ -139,7 +139,7 @@ metadata:
What happened to the name and version? They weren't in the scope for our defined template. When a named template (created with `define`) is rendered, it will receive the scope passed in by the `template` call. In our example, we included the template like this: What happened to the name and version? They weren't in the scope for our defined template. When a named template (created with `define`) is rendered, it will receive the scope passed in by the `template` call. In our example, we included the template like this:
```yaml ```gotpl
{{- template "mychart.labels" }} {{- template "mychart.labels" }}
``` ```

@ -41,20 +41,20 @@ value: {{required "A valid .Values.who entry required!" .Values.who }}
When you are working with string data, you are always safer quoting the When you are working with string data, you are always safer quoting the
strings than leaving them as bare words: strings than leaving them as bare words:
``` ```yaml
name: {{ .Values.MyName | quote }} name: {{ .Values.MyName | quote }}
``` ```
But when working with integers _do not quote the values._ That can, in But when working with integers _do not quote the values._ That can, in
many cases, cause parsing errors inside of Kubernetes. many cases, cause parsing errors inside of Kubernetes.
``` ```yaml
port: {{ .Values.Port }} port: {{ .Values.Port }}
``` ```
This remark does not apply to env variables values which are expected to be string, even if they represent integers: This remark does not apply to env variables values which are expected to be string, even if they represent integers:
``` ```yaml
env: env:
-name: HOST -name: HOST
value: "http://host" value: "http://host"
@ -99,7 +99,7 @@ developer.
For example: For example:
``` ```gotpl
{{ required "A valid foo is required!" .Values.foo }} {{ required "A valid foo is required!" .Values.foo }}
``` ```
@ -113,7 +113,8 @@ This is useful to pass a template string as a value to a chart or render externa
Syntax: `{{ tpl TEMPLATE_STRING VALUES }}` Syntax: `{{ tpl TEMPLATE_STRING VALUES }}`
Examples: Examples:
```
```yaml
# values # values
template: "{{ .Values.name }}" template: "{{ .Values.name }}"
name: "Tom" name: "Tom"
@ -126,7 +127,8 @@ Tom
``` ```
Rendering a external configuration file: Rendering a external configuration file:
```
```yaml
# external configuration file conf/app.conf # external configuration file conf/app.conf
firstName={{ .Values.firstName }} firstName={{ .Values.firstName }}
lastName={{ .Values.lastName }} lastName={{ .Values.lastName }}
@ -144,10 +146,12 @@ lastName=Parker
``` ```
## Creating Image Pull Secrets ## Creating Image Pull Secrets
Image pull secrets are essentially a combination of _registry_, _username_, and _password_. You may need them in an application you are deploying, but to create them requires running _base64_ a couple of times. We can write a helper template to compose the Docker configuration file for use as the Secret's payload. Here is an example: Image pull secrets are essentially a combination of _registry_, _username_, and _password_. You may need them in an application you are deploying, but to create them requires running _base64_ a couple of times. We can write a helper template to compose the Docker configuration file for use as the Secret's payload. Here is an example:
First, assume that the credentials are defined in the `values.yaml` file like so: First, assume that the credentials are defined in the `values.yaml` file like so:
```
```yaml
imageCredentials: imageCredentials:
registry: quay.io registry: quay.io
username: someone username: someone
@ -155,14 +159,16 @@ imageCredentials:
``` ```
We then define our helper template as follows: We then define our helper template as follows:
```
```gotpl
{{- define "imagePullSecret" }} {{- define "imagePullSecret" }}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }} {{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }}
{{- end }} {{- end }}
``` ```
Finally, we use the helper template in a larger template to create the Secret manifest: Finally, we use the helper template in a larger template to create the Secret manifest:
```
```yaml
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
@ -282,6 +288,7 @@ update of that resource.
## Upgrade a release idempotently ## Upgrade a release idempotently
In order to use the same command when installing and upgrading a release, use the following command: In order to use the same command when installing and upgrading a release, use the following command:
```shell ```shell
helm upgrade --install <release name> --values <values file> <chart directory> helm upgrade --install <release name> --values <values file> <chart directory>
``` ```

Loading…
Cancel
Save