-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathREADME.md.gotmpl
166 lines (122 loc) · 4.47 KB
/
README.md.gotmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# Application
Generic helm chart for applications which:
- are stateless
- creates only namespace scoped resources (e.g. it doesn't need CRB - Cluster Role Bindings)
- don't need privileged containers
- don't call the underlying Kubernetes API or use the underlying etcd as a database by defining custom resources
- run either as deployment, job or cronjob
## Installing the Chart
To install the chart with the release name `my-application` in namespace `test`:
```shell
helm repo add stakater https://stakater.github.io/stakater-charts
helm repo update
helm install my-application stakater/application --namespace test
```
## Uninstall the Chart
To uninstall the chart:
```shell
helm delete --namespace test my-application
```
{{ template "chart.valuesSection" . }}
## Naming convention for ConfigMap, Secret, SealedSecret and ExternalSecret
Name format of ConfigMap, Secret, SealedSecret and ExternalSecret is `{{`{{ template "application.name" $ }}-{{ $nameSuffix }}`}}` then:
- `{{`{{ template "application.name" }}`}}` is a helper function that outputs `.Values.applicationName` if exist else return chart name as output
- `nameSuffix` is the each key in `secret.files`, `configMap.files`, `sealedSecret.files` and `externalSecret.files`
For example if we have following values file:
```yaml
applicationName: helloworld # {{`{{ template "application.name" $ }}`}}
configMap:
files:
config: # {{`{{ $nameSuffix }}`}}
key: value
```
then the configmap name will be named `helloworld-config`.
## Consuming environment variable in application chart
In order to use environment variable in deployment or cronjob, you will have to provide environment variable in *key/value* pair in `env` value. where key being environment variable key and value varies in different scenarios
- For simple key/value environment variable, just provide `value: <value>`
```yaml
env:
KEY:
value: MY_VALUE
```
- To get environement variable value from **ConfigMap**
Suppose we have a configmap created from application chart
```yaml
applicationName: my-application
configMap:
enabled: true
files:
application-config:
LOG: DEBUG
VERBOSE: v1
```
To get environment variable value from above created configmap, we will need to add following
```yaml
env:
APP_LOG_LEVEL:
valueFrom:
configMapKeyRef:
name: my-application-application-config
key: LOG
```
To get all environment variables key/values from **ConfigMap**, where configmap key being key of environment variable and value being value
```yaml
envFrom:
application-config-env:
type: configmap
nameSuffix: application-config
```
You can either provide `nameSuffix` which means name added after prefix `<applicationName>-` or static name with `name` of configmap.
- To get environment variable value from **Secret**
Suppose we have secret created from application chart
```yaml
applicationName: my-application
secret:
enabled: true
files:
db-credentials:
PASSWORD: skljd#2Qer!!
USER: postgres
```
To get environment variable value from above created secret, we will need to add following
```yaml
env:
KEY:
valueFrom:
secretKeyRef:
name: my-application-db-credentials
key: USER
```
To get environement variable value from **Secret**, where secret key being key of environment variable and value being value
```yaml
envFrom:
database-credentials:
type: secret
nameSuffix: db-credentials
```
you can either provide `nameSuffix` which means name added after prefix `<applicationName>-` or static name with `name` of secret
**Note:** first key after `envFrom` is just used to uniquely identify different objects in `envFrom` block. Make sure to keep it unique and relevant
## Configuring probes
To disable liveness or readiness probe, set value of `enabled` to `false`.
```yaml
livenessProbe:
enabled: false
```
By default probe handler type is `httpGet`. You just need to override `port` and `path` as per your need.
```yaml
livenessProbe:
enabled: true
httpGet:
path: '/path'
port: 8080
```
In order to use `exec` handler, you can define field `livenessProbe.exec` in your values.yaml.
```yaml
livenessProbe:
enabled: true
exec:
command:
- cat
- /tmp/healthy
```