Merge branch 'develop'
This commit is contained in:
@ -21,5 +21,9 @@
|
|||||||
.idea/
|
.idea/
|
||||||
*.tmproj
|
*.tmproj
|
||||||
.vscode/
|
.vscode/
|
||||||
# Secrets
|
# Others
|
||||||
|
starter/
|
||||||
|
.github/
|
||||||
gcloud_auth_key.json
|
gcloud_auth_key.json
|
||||||
|
create.sh
|
||||||
|
README.md
|
||||||
|
@ -14,4 +14,4 @@ type: library
|
|||||||
|
|
||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
version: 0.3.0
|
version: 0.4.0
|
||||||
|
126
README.md
126
README.md
@ -8,7 +8,10 @@ It provides utilities that reflect best practices of Kubernetes chart developmen
|
|||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
- [Installation](#installation)
|
- [Getting Started](#getting-started)
|
||||||
|
* [Adding Repository](#adding-repository)
|
||||||
|
* [Adding Dependency](#adding-dependency)
|
||||||
|
* [Using Starter](#using-starter)
|
||||||
- [Resource Kinds](#resource-kinds)
|
- [Resource Kinds](#resource-kinds)
|
||||||
* [`common.configMap`](#commonconfigmap)
|
* [`common.configMap`](#commonconfigmap)
|
||||||
* [`common.cronJob`](#commoncronjob)
|
* [`common.cronJob`](#commoncronjob)
|
||||||
@ -34,23 +37,53 @@ It provides utilities that reflect best practices of Kubernetes chart developmen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Getting Started
|
||||||
|
|
||||||
|
### Adding Repository
|
||||||
|
|
||||||
|
The following command allows you to download and install all the charts from our repository:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ helm repo add hahow https://hahow-helm-charts.storage.googleapis.com/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding Dependency
|
||||||
|
|
||||||
To use the library chart, `common` should be listed in `dependencies` field in your `Chart.yaml`:
|
To use the library chart, `common` should be listed in `dependencies` field in your `Chart.yaml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
version: 0.3.0
|
version: 0.4.0
|
||||||
repository: https://hahow-helm-charts.storage.googleapis.com/
|
repository: https://hahow-helm-charts.storage.googleapis.com/
|
||||||
```
|
```
|
||||||
|
|
||||||
Once you have defined dependencies, you should run the following command to download this chart into your `charts/` directory:
|
Once you have defined dependencies, you should run the following command to download this chart into your `charts/` directory:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ helm dependency update
|
$ helm dep build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using Starter
|
||||||
|
|
||||||
|
The best way to get started is to use the [`create` script](create.sh) to generate a new chart.
|
||||||
|
|
||||||
|
You can fetch that script, and then execute it locally:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ curl -fsSL -o create.sh https://raw.githubusercontent.com/hahow/common-chart/master/create.sh
|
||||||
|
$ chmod 700 create.sh
|
||||||
|
$ ./create.sh mychart
|
||||||
|
```
|
||||||
|
|
||||||
|
or simply
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ curl https://raw.githubusercontent.com/hahow/common-chart/master/create.sh | bash -s -- mychart
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, there is a chart in `./mychart`. You can edit it and create your own templates.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Resource Kinds
|
## Resource Kinds
|
||||||
@ -62,7 +95,7 @@ The resource kind templates are designed to make it much faster for you to defin
|
|||||||
To make use of these templates you must define a template that will extend the base template (though it can be empty). The name of this template is then passed to the base template, for example:
|
To make use of these templates you must define a template that will extend the base template (though it can be empty). The name of this template is then passed to the base template, for example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.service" (list . .Values.service "mychart.service") -}}
|
{{- include "common.service" (list . .Values.service "mychart.service") }}
|
||||||
{{- define "mychart.service" -}}
|
{{- define "mychart.service" -}}
|
||||||
## Define overrides for your Service resource here, e.g.
|
## Define overrides for your Service resource here, e.g.
|
||||||
# metadata:
|
# metadata:
|
||||||
@ -74,7 +107,7 @@ To make use of these templates you must define a template that will extend the b
|
|||||||
# targetPort: http
|
# targetPort: http
|
||||||
# protocol: TCP
|
# protocol: TCP
|
||||||
# name: http
|
# name: http
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the [`common.service`](#commonservice) template defines three parameters:
|
Note that the [`common.service`](#commonservice) template defines three parameters:
|
||||||
@ -103,7 +136,7 @@ It creates an empty `ConfigMap` resource that you can override with your configu
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.configMap" (list . "mychart.configMap") -}}
|
{{- include "common.configMap" (list . "mychart.configMap") }}
|
||||||
{{- define "mychart.configMap" -}}
|
{{- define "mychart.configMap" -}}
|
||||||
data:
|
data:
|
||||||
zeus: cat
|
zeus: cat
|
||||||
@ -111,7 +144,7 @@ data:
|
|||||||
julius: cat
|
julius: cat
|
||||||
one: |-
|
one: |-
|
||||||
{{ .Files.Get "file1.txt" }}
|
{{ .Files.Get "file1.txt" }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -165,12 +198,12 @@ Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) temp
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount) -}}
|
{{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount "mychart.cronJob") -}}
|
# {{- include "common.cronJob" (list . .Values.cronJob .Values .Values.serviceAccount "mychart.cronJob") }}
|
||||||
# {{- define "mychart.cronJob" -}}
|
# {{- define "mychart.cronJob" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -203,12 +236,12 @@ Underneath the hood, it invokes [`common.pod.template`](#commonpodtemplate) temp
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount) -}}
|
{{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "mychart.deployment") -}}
|
# {{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "mychart.deployment") }}
|
||||||
# {{- define "mychart.deployment" -}}
|
# {{- define "mychart.deployment" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -239,12 +272,12 @@ autoscaling:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.hpa" (list . .Values.autoscaling) -}}
|
{{- include "common.hpa" (list . .Values.autoscaling) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.hpa" (list . .Values.autoscaling "mychart.hpa") -}}
|
# {{- include "common.hpa" (list . .Values.autoscaling "mychart.hpa") }}
|
||||||
# {{- define "mychart.hpa" -}}
|
# {{- define "mychart.hpa" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -317,12 +350,12 @@ service:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.ingress" (list . .Values.ingress .Values.service) -}}
|
{{- include "common.ingress" (list . .Values.ingress .Values.service) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.ingress" (list . .Values.ingress .Values.service "mychart.ingress") -}}
|
# {{- include "common.ingress" (list . .Values.ingress .Values.service "mychart.ingress") }}
|
||||||
# {{- define "mychart.ingress" -}}
|
# {{- define "mychart.ingress" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -384,12 +417,12 @@ podDisruptionBudget:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling) -}}
|
{{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling "mychart.pdb") -}}
|
# {{- include "common.pdb" (list . .Values.podDisruptionBudget .Values .Values.autoscaling "mychart.pdb") }}
|
||||||
# {{- define "mychart.pdb" -}}
|
# {{- define "mychart.pdb" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -427,7 +460,7 @@ It creates an empty `Secret` resource that you can override with your secrets.
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.secret" (list . "mychart.secret") -}}
|
{{- include "common.secret" (list . "mychart.secret") }}
|
||||||
{{- define "mychart.secret" -}}
|
{{- define "mychart.secret" -}}
|
||||||
data:
|
data:
|
||||||
zeus: {{ print "cat" | b64enc }}
|
zeus: {{ print "cat" | b64enc }}
|
||||||
@ -435,7 +468,7 @@ data:
|
|||||||
julius: {{ print "cat" | b64enc }}
|
julius: {{ print "cat" | b64enc }}
|
||||||
one: |-
|
one: |-
|
||||||
{{ .Files.Get "file1.txt" | b64enc }}
|
{{ .Files.Get "file1.txt" | b64enc }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -478,9 +511,9 @@ It creates a basic `Service` resource with the following defaults:
|
|||||||
Example template:
|
Example template:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.service" (list . .Values.service "mychart.mail.service") -}}
|
{{- include "common.service" (list . .Values.service "mychart.mail.service") }}
|
||||||
{{- define "mychart.mail.service" -}}
|
{{- define "mychart.mail.service" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "common.fullname" $top }}-mail # overrides the default name to add a suffix
|
name: {{ include "common.fullname" $top }}-mail # overrides the default name to add a suffix
|
||||||
labels: # appended to the labels section
|
labels: # appended to the labels section
|
||||||
@ -497,9 +530,9 @@ spec:
|
|||||||
protocol: mail
|
protocol: mail
|
||||||
{{- end }}
|
{{- end }}
|
||||||
---
|
---
|
||||||
{{ include "common.service" (list . .Values.service "mychart.web.service") -}}
|
{{ include "common.service" (list . .Values.service "mychart.web.service") }}
|
||||||
{{- define "mychart.web.service" -}}
|
{{- define "mychart.web.service" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "common.fullname" $top }}-www # overrides the default name to add a suffix
|
name: {{ include "common.fullname" $top }}-www # overrides the default name to add a suffix
|
||||||
labels: # appended to the labels section
|
labels: # appended to the labels section
|
||||||
@ -509,7 +542,7 @@ spec:
|
|||||||
- name: www
|
- name: www
|
||||||
port: 80
|
port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
The above template defines _two_ services: a web service and a mail service.
|
The above template defines _two_ services: a web service and a mail service.
|
||||||
@ -593,12 +626,12 @@ serviceAccount:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.serviceAccount" (list . .Values.serviceAccount) -}}
|
{{- include "common.serviceAccount" (list . .Values.serviceAccount) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.serviceAccount" (list . .Values.serviceAccount "mychart.serviceAccount") -}}
|
# {{- include "common.serviceAccount" (list . .Values.serviceAccount "mychart.serviceAccount") }}
|
||||||
# {{- define "mychart.serviceAccount" -}}
|
# {{- define "mychart.serviceAccount" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -650,12 +683,12 @@ serviceMonitor:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.serviceMonitor" (list . .Values.serviceMonitor) -}}
|
{{- include "common.serviceMonitor" (list . .Values.serviceMonitor) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.serviceMonitor" (list . .Values.serviceMonitor "mychart.serviceMonitor") -}}
|
# {{- include "common.serviceMonitor" (list . .Values.serviceMonitor "mychart.serviceMonitor") }}
|
||||||
# {{- define "mychart.serviceMonitor" -}}
|
# {{- define "mychart.serviceMonitor" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -704,7 +737,7 @@ The `common.serviceMonitor.secret` template accepts a list of three values:
|
|||||||
- `$serviceMonitor`, a dictionary of values used in the service account template
|
- `$serviceMonitor`, a dictionary of values used in the service account template
|
||||||
- [optional] the template name of the overrides
|
- [optional] the template name of the overrides
|
||||||
|
|
||||||
It creates a `Secret` resource contains the BasicAuth information for the `SecretMonitor`.
|
It creates a `Secret` resource contains the BasicAuth information for the `ServiceMonitor`.
|
||||||
|
|
||||||
An example `values.yaml` for your `ServiceMonitor` could look like:
|
An example `values.yaml` for your `ServiceMonitor` could look like:
|
||||||
|
|
||||||
@ -719,12 +752,12 @@ serviceMonitor:
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor) -}}
|
{{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor) }}
|
||||||
|
|
||||||
## The following is the same as above:
|
## The following is the same as above:
|
||||||
# {{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor "mychart.serviceMonitor.secret") -}}
|
# {{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor "mychart.serviceMonitor.secret") }}
|
||||||
# {{- define "mychart.serviceMonitor.secret" -}}
|
# {{- define "mychart.serviceMonitor.secret" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
@ -799,15 +832,17 @@ It creates a basic `Container` spec to be used within a `Deployment` or `CronJob
|
|||||||
Example use:
|
Example use:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
{{- include "common.deployment" (list . .Values .Values.autoscaling "mychart.deployment") -}}
|
{{- include "common.deployment" (list . .Values .Values.autoscaling "mychart.deployment") }}
|
||||||
{{- define "mychart.deployment" -}}
|
{{- define "mychart.deployment" -}}
|
||||||
## Define overrides for your Deployment resource here, e.g.
|
## Define overrides for your Deployment resource here, e.g.
|
||||||
|
{{- $top := first . }}
|
||||||
|
{{- $deployment := index . 1 }}
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- {{- include "common.container" (append . "mychart.deployment.container") | nindent 8 }}
|
- {{- include "common.container" (list $top $deployment "mychart.deployment.container") | nindent 8 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- define "mychart.deployment.container" -}}
|
{{- define "mychart.deployment.container" -}}
|
||||||
## Define overrides for your Container here, e.g.
|
## Define overrides for your Container here, e.g.
|
||||||
ports:
|
ports:
|
||||||
@ -822,7 +857,7 @@ readinessProbe:
|
|||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
port: http
|
port: http
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
The above example creates a `Deployment` resource which makes use of the `common.container` template to populate the `PodSpec`'s container list. The usage of this template is similar to the other resources, you must define and reference a template that contains overrides for the container object.
|
The above example creates a `Deployment` resource which makes use of the `common.container` template to populate the `PodSpec`'s container list. The usage of this template is similar to the other resources, you must define and reference a template that contains overrides for the container object.
|
||||||
@ -984,7 +1019,7 @@ metadata:
|
|||||||
# metadata:
|
# metadata:
|
||||||
# {{- include "common.metadata" (list . "mychart.metadata") | nindent 2 }}
|
# {{- include "common.metadata" (list . "mychart.metadata") | nindent 2 }}
|
||||||
# {{- define "mychart.metadata" -}}
|
# {{- define "mychart.metadata" -}}
|
||||||
# {{- end -}}
|
# {{- end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Example output:
|
Example output:
|
||||||
@ -1052,6 +1087,7 @@ It also uses the following configuration from the `$pod`:
|
|||||||
| Value | Description |
|
| Value | Description |
|
||||||
| ----- | ----------- |
|
| ----- | ----------- |
|
||||||
| `$pod.imagePullSecrets` | Names of secrets containing private registry credentials |
|
| `$pod.imagePullSecrets` | Names of secrets containing private registry credentials |
|
||||||
|
| `$pod.podAnnotations` | Pod annotations |
|
||||||
| `$pod.podSecurityContext` | Security options |
|
| `$pod.podSecurityContext` | Security options |
|
||||||
| `$pod.nodeSelector ` | Node labels for pod assignment |
|
| `$pod.nodeSelector ` | Node labels for pod assignment |
|
||||||
| `$pod.affinity ` | Expressions for affinity |
|
| `$pod.affinity ` | Expressions for affinity |
|
||||||
|
16
create.sh
Executable file
16
create.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -exu
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]
|
||||||
|
then
|
||||||
|
echo "No argument supplied"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir "$1"
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://codeload.github.com/hahow/common-chart/tar.gz/master | \
|
||||||
|
tar -xz -C "$1" --strip=2 common-chart-master/starter
|
||||||
|
find "$1" -type f | xargs sed -i "" "s/<CHARTNAME>/$1/g"
|
||||||
|
|
||||||
|
helm dep build "$1"
|
23
starter/.helmignore
Normal file
23
starter/.helmignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.orig
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
28
starter/Chart.yaml
Normal file
28
starter/Chart.yaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: <CHARTNAME>
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
|
||||||
|
# A chart can be either an 'application' or a 'library' chart.
|
||||||
|
#
|
||||||
|
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||||
|
# to be deployed.
|
||||||
|
#
|
||||||
|
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||||
|
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||||
|
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||||
|
type: application
|
||||||
|
|
||||||
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
|
# to the chart and its templates, including the app version.
|
||||||
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# This is the version number of the application being deployed. This version number should be
|
||||||
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
appVersion: 1.16.0
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
version: "0.4.0"
|
||||||
|
repository: "https://hahow-helm-charts.storage.googleapis.com/"
|
21
starter/templates/NOTES.txt
Normal file
21
starter/templates/NOTES.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
1. Get the application URL by running these commands:
|
||||||
|
{{- if .Values.ingress.enabled }}
|
||||||
|
{{- range $host := .Values.ingress.hosts }}
|
||||||
|
{{- range .paths }}
|
||||||
|
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if contains "NodePort" .Values.service.type }}
|
||||||
|
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.fullname" . }})
|
||||||
|
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||||
|
echo http://$NODE_IP:$NODE_PORT
|
||||||
|
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||||
|
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||||
|
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "common.fullname" . }}'
|
||||||
|
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||||
|
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||||
|
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||||
|
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||||
|
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||||
|
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
|
||||||
|
{{- end }}
|
26
starter/templates/deployment.yaml
Normal file
26
starter/templates/deployment.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- include "common.deployment" (list . .Values .Values.autoscaling .Values.serviceAccount "<CHARTNAME>.deployment") }}
|
||||||
|
|
||||||
|
{{- define "<CHARTNAME>.deployment" -}}
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- {{- include "common.container" (append . "<CHARTNAME>.container") | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- define "<CHARTNAME>.container" -}}
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
{{- end }}
|
3
starter/templates/ingress.yaml
Normal file
3
starter/templates/ingress.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- include "common.ingress" (list . .Values.ingress .Values.service) }}
|
3
starter/templates/service.yaml
Normal file
3
starter/templates/service.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- include "common.service" (list . .Values.service) }}
|
3
starter/templates/serviceaccount.yaml
Normal file
3
starter/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{- include "common.serviceAccount" (list . .Values.serviceAccount) }}
|
15
starter/templates/tests/test-connection.yaml
Normal file
15
starter/templates/tests/test-connection.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: "{{ include "common.fullname" . }}-test-connection"
|
||||||
|
labels:
|
||||||
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
|
annotations:
|
||||||
|
"helm.sh/hook": test-success
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: wget
|
||||||
|
image: busybox
|
||||||
|
command: ['wget']
|
||||||
|
args: ['{{ include "common.fullname" . }}:{{ .Values.service.port }}']
|
||||||
|
restartPolicy: Never
|
79
starter/values.yaml
Normal file
79
starter/values.yaml
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# Default values for <CHARTNAME>.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare variables to be passed into your templates.
|
||||||
|
|
||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: nginx
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
|
tag: ""
|
||||||
|
|
||||||
|
imagePullSecrets: []
|
||||||
|
nameOverride: ""
|
||||||
|
fullnameOverride: ""
|
||||||
|
|
||||||
|
serviceAccount:
|
||||||
|
# Specifies whether a service account should be created
|
||||||
|
create: true
|
||||||
|
# Annotations to add to the service account
|
||||||
|
annotations: {}
|
||||||
|
# The name of the service account to use.
|
||||||
|
# If not set and create is true, a name is generated using the fullname template
|
||||||
|
name: ""
|
||||||
|
|
||||||
|
podAnnotations: {}
|
||||||
|
|
||||||
|
podSecurityContext: {}
|
||||||
|
# fsGroup: 2000
|
||||||
|
|
||||||
|
securityContext: {}
|
||||||
|
# capabilities:
|
||||||
|
# drop:
|
||||||
|
# - ALL
|
||||||
|
# readOnlyRootFilesystem: true
|
||||||
|
# runAsNonRoot: true
|
||||||
|
# runAsUser: 1000
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: false
|
||||||
|
annotations: {}
|
||||||
|
# kubernetes.io/ingress.class: nginx
|
||||||
|
# kubernetes.io/tls-acme: "true"
|
||||||
|
hosts:
|
||||||
|
- host: chart-example.local
|
||||||
|
paths: []
|
||||||
|
tls: []
|
||||||
|
# - secretName: chart-example-tls
|
||||||
|
# hosts:
|
||||||
|
# - chart-example.local
|
||||||
|
|
||||||
|
resources: {}
|
||||||
|
# We usually recommend not to specify default resources and to leave this as a conscious
|
||||||
|
# choice for the user. This also increases chances charts run on environments with little
|
||||||
|
# resources, such as Minikube. If you do want to specify resources, uncomment the following
|
||||||
|
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
|
||||||
|
# limits:
|
||||||
|
# cpu: 100m
|
||||||
|
# memory: 128Mi
|
||||||
|
# requests:
|
||||||
|
# cpu: 100m
|
||||||
|
# memory: 128Mi
|
||||||
|
|
||||||
|
autoscaling:
|
||||||
|
enabled: false
|
||||||
|
minReplicas: 1
|
||||||
|
maxReplicas: 100
|
||||||
|
targetCPUUtilizationPercentage: 80
|
||||||
|
# targetMemoryUtilizationPercentage: 80
|
||||||
|
|
||||||
|
nodeSelector: {}
|
||||||
|
|
||||||
|
tolerations: []
|
||||||
|
|
||||||
|
affinity: {}
|
@ -1,14 +1,14 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.configMap.tpl" -}}
|
{{- define "common.configMap.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
{{- include "common.metadata" (list $top) | nindent 2 }}
|
{{- include "common.metadata" (list $top) | nindent 2 }}
|
||||||
data: {}
|
data: {}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.configMap" -}}
|
{{- define "common.configMap" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.configMap.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.configMap.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.container.tpl" -}}
|
{{- define "common.container.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $container := index . 1 -}}
|
{{- $container := index . 1 }}
|
||||||
{{- $image := $container.image | default (dict) -}}
|
{{- $image := $container.image | default (dict) }}
|
||||||
name: {{ $top.Chart.Name }}
|
name: {{ $top.Chart.Name }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml $container.securityContext | nindent 2 }}
|
{{- toYaml $container.securityContext | nindent 2 }}
|
||||||
@ -11,8 +11,8 @@ image: "{{ $image.repository }}:{{ $image.tag | default $top.Chart.AppVersion }}
|
|||||||
imagePullPolicy: {{ $container.image.pullPolicy }}
|
imagePullPolicy: {{ $container.image.pullPolicy }}
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml $container.resources | nindent 2 }}
|
{{- toYaml $container.resources | nindent 2 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.container" -}}
|
{{- define "common.container" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.container.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.container.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
{{- define "common.cronJob.pod" -}}
|
{{- define "common.cronJob.pod" -}}
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: OnFailure
|
restartPolicy: OnFailure
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.cronJob.tpl" -}}
|
{{- define "common.cronJob.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $cronJob := index . 1 -}}
|
{{- $cronJob := index . 1 }}
|
||||||
{{- $pod := index . 2 -}}
|
{{- $pod := index . 2 }}
|
||||||
{{- $serviceAccount := index . 3 -}}
|
{{- $serviceAccount := index . 3 }}
|
||||||
apiVersion: batch/v1beta1
|
apiVersion: batch/v1beta1
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
metadata:
|
metadata:
|
||||||
@ -32,8 +32,8 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
{{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
|
{{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.cronJob" -}}
|
{{- define "common.cronJob" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.cronJob.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.cronJob.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.deployment.tpl" -}}
|
{{- define "common.deployment.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $deployment := index . 1 -}}
|
{{- $deployment := index . 1 }}
|
||||||
{{- $autoscaling := index . 2 -}}
|
{{- $autoscaling := index . 2 }}
|
||||||
{{- $serviceAccount := index . 3 -}}
|
{{- $serviceAccount := index . 3 }}
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@ -18,8 +18,8 @@ spec:
|
|||||||
{{- include "common.selectorLabels" $top | nindent 6 }}
|
{{- include "common.selectorLabels" $top | nindent 6 }}
|
||||||
template:
|
template:
|
||||||
{{- include "common.pod.template" (list $top $deployment $serviceAccount) | nindent 4 }}
|
{{- include "common.pod.template" (list $top $deployment $serviceAccount) | nindent 4 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.deployment" -}}
|
{{- define "common.deployment" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.deployment.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.deployment.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.hpa.tpl" -}}
|
{{- define "common.hpa.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $autoscaling := index . 1 -}}
|
{{- $autoscaling := index . 1 }}
|
||||||
apiVersion: autoscaling/v2beta2
|
apiVersion: autoscaling/v2beta2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
@ -16,26 +16,26 @@ spec:
|
|||||||
maxReplicas: {{ $autoscaling.maxReplicas }}
|
maxReplicas: {{ $autoscaling.maxReplicas }}
|
||||||
metrics:
|
metrics:
|
||||||
{{- with $autoscaling.cpuUtilizationPercentage }}
|
{{- with $autoscaling.cpuUtilizationPercentage }}
|
||||||
- type: Resource
|
- type: Resource
|
||||||
resource:
|
resource:
|
||||||
name: cpu
|
name: cpu
|
||||||
target:
|
target:
|
||||||
type: Utilization
|
type: Utilization
|
||||||
averageUtilization: {{ . }}
|
averageUtilization: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with $autoscaling.memoryUtilizationPercentage }}
|
{{- with $autoscaling.memoryUtilizationPercentage }}
|
||||||
- type: Resource
|
- type: Resource
|
||||||
resource:
|
resource:
|
||||||
name: memory
|
name: memory
|
||||||
target:
|
target:
|
||||||
type: Utilization
|
type: Utilization
|
||||||
averageUtilization: {{ . }}
|
averageUtilization: {{ . }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.hpa" -}}
|
{{- define "common.hpa" -}}
|
||||||
{{- $autoscaling := index . 1 -}}
|
{{- $autoscaling := index . 1 }}
|
||||||
{{- if $autoscaling.enabled -}}
|
{{- if $autoscaling.enabled }}
|
||||||
{{- include "common.utils.merge" (append . "common.hpa.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.hpa.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.ingress.metadata" -}}
|
{{- define "common.ingress.metadata" -}}
|
||||||
{{- $ingress := index . 1 -}}
|
{{- $ingress := index . 1 }}
|
||||||
{{- with $ingress.annotations }}
|
{{- with $ingress.annotations }}
|
||||||
annotations:
|
annotations:
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.ingress.tpl" -}}
|
{{- define "common.ingress.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $ingress := index . 1 -}}
|
{{- $ingress := index . 1 }}
|
||||||
{{- $service := index . 2 -}}
|
{{- $service := index . 2 }}
|
||||||
{{- $fullName := include "common.fullname" $top -}}
|
{{- $fullName := include "common.fullname" $top }}
|
||||||
{{- $svcPort := $service.port -}}
|
{{- $svcPort := $service.port }}
|
||||||
{{- if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion -}}
|
{{- if semverCompare ">=1.14-0" $top.Capabilities.KubeVersion.GitVersion }}
|
||||||
apiVersion: networking.k8s.io/v1beta1
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
apiVersion: extensions/v1beta1
|
apiVersion: extensions/v1beta1
|
||||||
{{- end }}
|
{{- end }}
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
@ -26,30 +26,30 @@ spec:
|
|||||||
{{- if $ingress.tls }}
|
{{- if $ingress.tls }}
|
||||||
tls:
|
tls:
|
||||||
{{- range $ingress.tls }}
|
{{- range $ingress.tls }}
|
||||||
- hosts:
|
- hosts:
|
||||||
{{- range .hosts }}
|
{{- range .hosts }}
|
||||||
- {{ . | quote }}
|
- {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
secretName: {{ .secretName }}
|
secretName: {{ .secretName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
rules:
|
rules:
|
||||||
{{- range $ingress.hosts }}
|
{{- range $ingress.hosts }}
|
||||||
- host: {{ .host | quote }}
|
- host: {{ .host | quote }}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
{{- range .paths }}
|
{{- range .paths }}
|
||||||
- path: {{ . }}
|
- path: {{ . }}
|
||||||
backend:
|
backend:
|
||||||
serviceName: {{ $fullName }}
|
serviceName: {{ $fullName }}
|
||||||
servicePort: {{ $svcPort }}
|
servicePort: {{ $svcPort }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.ingress" -}}
|
{{- define "common.ingress" -}}
|
||||||
{{- $ingress := index . 1 -}}
|
{{- $ingress := index . 1 }}
|
||||||
{{- if $ingress.enabled -}}
|
{{- if $ingress.enabled }}
|
||||||
{{- include "common.utils.merge" (append . "common.ingress.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.ingress.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -10,7 +10,7 @@ helm.sh/chart: {{ include "common.chart" . }}
|
|||||||
app.kubernetes.io/version: {{ . | quote }}
|
app.kubernetes.io/version: {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Selector labels
|
Selector labels
|
||||||
@ -18,18 +18,18 @@ Selector labels
|
|||||||
{{- define "common.selectorLabels" -}}
|
{{- define "common.selectorLabels" -}}
|
||||||
app.kubernetes.io/name: {{ include "common.name" . }}
|
app.kubernetes.io/name: {{ include "common.name" . }}
|
||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.metadata.tpl" -}}
|
{{- define "common.metadata.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . -}}
|
||||||
name: {{ include "common.fullname" $top }}
|
name: {{ include "common.fullname" $top }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "common.labels" $top | nindent 2 -}}
|
{{- include "common.labels" $top | nindent 2 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- /*
|
{{/*
|
||||||
Create a standard metadata header
|
Create a standard metadata header
|
||||||
*/ -}}
|
*/}}
|
||||||
{{- define "common.metadata" -}}
|
{{- define "common.metadata" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.metadata.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.metadata.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Expand the name of the chart.
|
Expand the name of the chart.
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.name" -}}
|
{{- define "common.name" -}}
|
||||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Create a default fully qualified app name.
|
Create a default fully qualified app name.
|
||||||
@ -13,34 +13,34 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
|
|||||||
If release name contains chart name it will be used as a full name.
|
If release name contains chart name it will be used as a full name.
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.fullname" -}}
|
{{- define "common.fullname" -}}
|
||||||
{{- if .Values.fullnameOverride -}}
|
{{- if .Values.fullnameOverride }}
|
||||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||||
{{- if contains $name .Release.Name -}}
|
{{- if contains $name .Release.Name }}
|
||||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Create chart name and version as used by the chart label.
|
Create chart name and version as used by the chart label.
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.chart" -}}
|
{{- define "common.chart" -}}
|
||||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Create the name of the service account to use.
|
Create the name of the service account to use.
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.serviceAccountName" -}}
|
{{- define "common.serviceAccountName" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceAccount := index . 1 -}}
|
{{- $serviceAccount := index . 1 }}
|
||||||
{{- if $serviceAccount.create -}}
|
{{- if $serviceAccount.create }}
|
||||||
{{ default (include "common.fullname" $top) $serviceAccount.name }}
|
{{- default (include "common.fullname" $top) $serviceAccount.name }}
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{ default "default" $serviceAccount.name }}
|
{{- default "default" $serviceAccount.name }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.pdb.tpl" -}}
|
{{- define "common.pdb.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $pdb := index . 1 -}}
|
{{- $pdb := index . 1 }}
|
||||||
apiVersion: policy/v1beta1
|
apiVersion: policy/v1beta1
|
||||||
kind: PodDisruptionBudget
|
kind: PodDisruptionBudget
|
||||||
metadata:
|
metadata:
|
||||||
@ -11,22 +11,22 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
{{- include "common.selectorLabels" $top | nindent 6 }}
|
{{- include "common.selectorLabels" $top | nindent 6 }}
|
||||||
{{- if not (or (empty $pdb.minAvailable) (empty $pdb.maxUnavailable)) -}}
|
{{- if not (or (empty $pdb.minAvailable) (empty $pdb.maxUnavailable)) }}
|
||||||
{{- fail "minAvailable and maxUnavailable can not be set together" }}
|
{{- fail "minAvailable and maxUnavailable can not be set together" }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- with $pdb.minAvailable }}
|
{{- with $pdb.minAvailable }}
|
||||||
minAvailable: {{ . }}
|
minAvailable: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with $pdb.maxUnavailable }}
|
{{- with $pdb.maxUnavailable }}
|
||||||
maxUnavailable: {{ . }}
|
maxUnavailable: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.pdb" -}}
|
{{- define "common.pdb" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $deployment := index . 2 -}}
|
{{- $deployment := index . 2 }}
|
||||||
{{- $autoscaling := index . 3 -}}
|
{{- $autoscaling := index . 3 }}
|
||||||
{{- if or (and $autoscaling.enabled (gt ($autoscaling.minReplicas | int) 1)) (and (not $autoscaling.enabled) (gt ($deployment.replicaCount | int) 1)) }}
|
{{- if or (and $autoscaling.enabled (gt ($autoscaling.minReplicas | int) 1)) (and (not $autoscaling.enabled) (gt ($deployment.replicaCount | int) 1)) }}
|
||||||
{{- include "common.utils.merge" (append . "common.pdb.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.pdb.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.pod.template.tpl" -}}
|
{{- define "common.pod.template.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $pod := index . 1 -}}
|
{{- $pod := index . 1 }}
|
||||||
{{- $serviceAccount := index . 2 -}}
|
{{- $serviceAccount := index . 2 }}
|
||||||
metadata:
|
metadata:
|
||||||
|
{{- with $pod.podAnnotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "common.selectorLabels" $top | nindent 4 }}
|
{{- include "common.selectorLabels" $top | nindent 4 }}
|
||||||
spec:
|
spec:
|
||||||
@ -16,7 +20,7 @@ spec:
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml $pod.podSecurityContext | nindent 4 }}
|
{{- toYaml $pod.podSecurityContext | nindent 4 }}
|
||||||
containers:
|
containers:
|
||||||
- {{- include "common.container" (list $top $pod) | nindent 6 }}
|
- {{- include "common.container" (list $top $pod) | nindent 4 }}
|
||||||
{{- with $pod.nodeSelector }}
|
{{- with $pod.nodeSelector }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
{{- toYaml . | nindent 4 }}
|
{{- toYaml . | nindent 4 }}
|
||||||
@ -29,8 +33,8 @@ spec:
|
|||||||
tolerations:
|
tolerations:
|
||||||
{{- toYaml . | nindent 4 }}
|
{{- toYaml . | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.pod.template" -}}
|
{{- define "common.pod.template" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.pod.template.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.pod.template.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.secret.tpl" -}}
|
{{- define "common.secret.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
{{- include "common.metadata" (list $top) | nindent 2 }}
|
{{- include "common.metadata" (list $top) | nindent 2 }}
|
||||||
type: Opaque
|
type: Opaque
|
||||||
data: {}
|
data: {}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.secret" -}}
|
{{- define "common.secret" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.secret.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.secret.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.service.tpl" -}}
|
{{- define "common.service.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $service := index . 1 -}}
|
{{- $service := index . 1 }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@ -10,14 +10,14 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
type: {{ $service.type }}
|
type: {{ $service.type }}
|
||||||
ports:
|
ports:
|
||||||
- port: {{ $service.port }}
|
- port: {{ $service.port }}
|
||||||
targetPort: http
|
targetPort: http
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
name: http
|
name: http
|
||||||
selector:
|
selector:
|
||||||
{{- include "common.selectorLabels" $top | nindent 4 }}
|
{{- include "common.selectorLabels" $top | nindent 4 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.service" -}}
|
{{- define "common.service" -}}
|
||||||
{{- include "common.utils.merge" (append . "common.service.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.service.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.serviceAccount.metadata" -}}
|
{{- define "common.serviceAccount.metadata" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceAccount := index . 1 -}}
|
{{- $serviceAccount := index . 1 }}
|
||||||
name: {{ include "common.serviceAccountName" . }}
|
name: {{ include "common.serviceAccountName" . }}
|
||||||
{{- with $serviceAccount.annotations }}
|
{{- with $serviceAccount.annotations }}
|
||||||
annotations:
|
annotations:
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.serviceAccount.tpl" -}}
|
{{- define "common.serviceAccount.tpl" -}}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ServiceAccount
|
kind: ServiceAccount
|
||||||
metadata:
|
metadata:
|
||||||
{{- include "common.metadata" (append . "common.serviceAccount.metadata") | nindent 2 }}
|
{{- include "common.metadata" (append . "common.serviceAccount.metadata") | nindent 2 }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.serviceAccount" -}}
|
{{- define "common.serviceAccount" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceAccount := index . 1 -}}
|
{{- $serviceAccount := index . 1 }}
|
||||||
{{- if $serviceAccount.create -}}
|
{{- if $serviceAccount.create }}
|
||||||
{{- include "common.utils.merge" (append . "common.serviceAccount.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.serviceAccount.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.serviceMonitor.secret.tpl" -}}
|
{{- define "common.serviceMonitor.secret.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceMonitor := index . 1 -}}
|
{{- $serviceMonitor := index . 1 }}
|
||||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) -}}
|
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) }}
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ $basicAuth.secretName | default (include "common.fullname" $top) }}
|
name: {{ $basicAuth.secretName | default (include "common.fullname" $top) }}
|
||||||
{{- with $serviceMonitor.namespace }}
|
{{- with $serviceMonitor.namespace }}
|
||||||
@ -14,12 +14,12 @@ data:
|
|||||||
{{ $basicAuth.usernameKey | default "username" }}: {{ $basicAuth.username | toString | b64enc | quote }}
|
{{ $basicAuth.usernameKey | default "username" }}: {{ $basicAuth.username | toString | b64enc | quote }}
|
||||||
{{ $basicAuth.passwordKey | default "password" }}: {{ $basicAuth.password | toString | b64enc | quote }}
|
{{ $basicAuth.passwordKey | default "password" }}: {{ $basicAuth.password | toString | b64enc | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.serviceMonitor.secret" -}}
|
{{- define "common.serviceMonitor.secret" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceMonitor := index . 1 -}}
|
{{- $serviceMonitor := index . 1 }}
|
||||||
{{- if $serviceMonitor.enabled -}}
|
{{- if $serviceMonitor.enabled }}
|
||||||
{{- include "common.secret" (append . "common.serviceMonitor.secret.tpl") -}}
|
{{- include "common.secret" (append . "common.serviceMonitor.secret.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- define "common.serviceMonitor.metadata" -}}
|
{{- define "common.serviceMonitor.metadata" -}}
|
||||||
{{- $serviceMonitor := index . 1 -}}
|
{{- $serviceMonitor := index . 1 }}
|
||||||
{{- with $serviceMonitor.namespace }}
|
{{- with $serviceMonitor.namespace }}
|
||||||
namespace: {{ . }}
|
namespace: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.serviceMonitor.tpl" -}}
|
{{- define "common.serviceMonitor.tpl" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceMonitor := index . 1 -}}
|
{{- $serviceMonitor := index . 1 }}
|
||||||
apiVersion: monitoring.coreos.com/v1
|
apiVersion: monitoring.coreos.com/v1
|
||||||
kind: ServiceMonitor
|
kind: ServiceMonitor
|
||||||
metadata:
|
metadata:
|
||||||
@ -32,8 +32,8 @@ spec:
|
|||||||
{{- with $serviceMonitor.scrapeTimeout }}
|
{{- with $serviceMonitor.scrapeTimeout }}
|
||||||
scrapeTimeout: {{ . }}
|
scrapeTimeout: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) -}}
|
{{- $basicAuth := $serviceMonitor.basicAuth | default (dict) }}
|
||||||
{{- $name := $basicAuth.secretName | default (include "common.fullname" $top) -}}
|
{{- $name := $basicAuth.secretName | default (include "common.fullname" $top) }}
|
||||||
{{- if $basicAuth.enabled }}
|
{{- if $basicAuth.enabled }}
|
||||||
basicAuth:
|
basicAuth:
|
||||||
username:
|
username:
|
||||||
@ -43,12 +43,12 @@ spec:
|
|||||||
name: {{ $name }}
|
name: {{ $name }}
|
||||||
key: {{ $basicAuth.passwordKey | default "password" }}
|
key: {{ $basicAuth.passwordKey | default "password" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "common.serviceMonitor" -}}
|
{{- define "common.serviceMonitor" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $serviceMonitor := index . 1 -}}
|
{{- $serviceMonitor := index . 1 }}
|
||||||
{{- if $serviceMonitor.enabled -}}
|
{{- if $serviceMonitor.enabled }}
|
||||||
{{- include "common.utils.merge" (append . "common.serviceMonitor.tpl") -}}
|
{{- include "common.utils.merge" (append . "common.serviceMonitor.tpl") }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
{{/* vim: set filetype=mustache: */}}
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
{{- /*
|
{{/*
|
||||||
Merge one or more YAML templates and output the result.
|
Merge one or more YAML templates and output the result.
|
||||||
This takes an list of values:
|
This takes an list of values:
|
||||||
- the top context
|
- the top context
|
||||||
- [optional] zero or more template args
|
- [optional] zero or more template args
|
||||||
- [optional] the template name of the overrides (destination)
|
- [optional] the template name of the overrides (destination)
|
||||||
- the template name of the base (source)
|
- the template name of the base (source)
|
||||||
*/ -}}
|
*/}}
|
||||||
{{- define "common.utils.merge" -}}
|
{{- define "common.utils.merge" -}}
|
||||||
{{- $top := first . -}}
|
{{- $top := first . }}
|
||||||
{{- $tplName := last . -}}
|
{{- $tplName := last . }}
|
||||||
{{- $args := initial . -}}
|
{{- $args := initial . }}
|
||||||
{{- if typeIs "string" (last $args) -}}
|
{{- if typeIs "string" (last $args) }}
|
||||||
{{- $overridesName := last $args -}}
|
{{- $overridesName := last $args }}
|
||||||
{{- $args = initial $args -}}
|
{{- $args = initial $args }}
|
||||||
{{- $tpl := fromYaml (include $tplName $args) | default (dict) -}}
|
{{- $tpl := fromYaml (include $tplName $args) | default (dict) }}
|
||||||
{{- $overrides := fromYaml (include $overridesName $args) | default (dict) -}}
|
{{- $overrides := fromYaml (include $overridesName $args) | default (dict) }}
|
||||||
{{- toYaml (merge $overrides $tpl) -}}
|
{{- toYaml (merge $overrides $tpl) }}
|
||||||
{{- else -}}
|
{{- else }}
|
||||||
{{- include $tplName $args -}}
|
{{- include $tplName $args }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end }}
|
||||||
|
Reference in New Issue
Block a user