Skip to content

Commit a424aa1

Browse files
committed
Avoid environment variable for default setting on k8s
Using environment variable make it harder to override the settings, since only replacing the environment variable will work, configuration files have less priority. Only account_id and registration_key are still environment variables to avoid breaking compatibility (some user already override the bleemeo-credentials with their own value for those environment variables, converting them to configuration file won't be transparent for them).
1 parent 291bdf5 commit a424aa1

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

k8s.yaml

+40-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,24 @@ metadata:
77
name: glouton-credentials
88
type:
99
stringData:
10+
# ${VARIABLE} are expected to be replaced by envsubt before the YAML is used by kubectl.
11+
# For example doing "curl -s https://packages.bleemeo.com/bleemeo-agent/kubernetes/k8s.yaml | envsubst | kubectl apply -f -"
1012
GLOUTON_BLEEMEO_ACCOUNT_ID: ${GLOUTON_BLEEMEO_ACCOUNT_ID}
1113
GLOUTON_BLEEMEO_REGISTRATION_KEY: ${GLOUTON_BLEEMEO_REGISTRATION_KEY}
1214
---
1315
apiVersion: v1
1416
kind: ConfigMap
17+
metadata:
18+
name: glouton-default-config
19+
data:
20+
10-default.conf: |
21+
# Avoid modifying this config. Modify the glouton-config present below, and we recommend using
22+
# another YAML file (see comment below).
23+
kubernetes:
24+
clustername: "${GLOUTON_KUBERNETES_CLUSTERNAME}"
25+
---
26+
apiVersion: v1
27+
kind: ConfigMap
1528
metadata:
1629
name: glouton-config
1730
data:
@@ -25,6 +38,25 @@ data:
2538
# Note: it's not a typo. The "-,./glouton-custom.yaml" is correct: we read from stdin ("-") then from the file.
2639
---
2740
apiVersion: v1
41+
kind: ConfigMap
42+
metadata:
43+
name: glouton-environment
44+
data:
45+
# This configmap allow to set environment variable to configure Glouton,
46+
# to use Glouton configuration files, see glouton-config above.
47+
#
48+
# We recommend using another Kubernetes YAML file to make change of glouton-environment.
49+
# This will allow to use latest version of this k8s.yaml file without needs to merge your
50+
# local change in the newer version.
51+
# Example: have another file "glouton-custom.yaml" which only contains a glouton-environment ConfigMap
52+
# then apply with:
53+
# curl -s https://packages.bleemeo.com/bleemeo-agent/kubernetes/k8s.yaml | envsubst | kubectl apply -f -,./glouton-custom.yaml
54+
# Note: it's not a typo. The "-,./glouton-custom.yaml" is correct: we read from stdin ("-") then from the file.
55+
#
56+
# Example of settings:
57+
# GLOUTON_BLEEMEO_INITIAL_AGENT_NAME: my_name
58+
---
59+
apiVersion: v1
2860
kind: ServiceAccount
2961
metadata:
3062
name: glouton
@@ -125,15 +157,15 @@ spec:
125157
value: "/etc/glouton/glouton.conf,/etc/glouton/glouton-k8s-default.conf,/etc/glouton/conf.d,/etc/glouton/conf-k8s.d"
126158
- name: GLOUTON_KUBERNETES_ENABLE
127159
value: "True"
128-
- name: GLOUTON_KUBERNETES_CLUSTERNAME
129-
value: "${GLOUTON_KUBERNETES_CLUSTERNAME}"
130160
- name: GLOUTON_KUBERNETES_NODENAME
131161
valueFrom:
132162
fieldRef:
133163
fieldPath: spec.nodeName
134164
envFrom:
135165
- secretRef:
136166
name: glouton-credentials
167+
- configMapRef:
168+
name: glouton-environment
137169
resources:
138170
requests:
139171
cpu: 0.05
@@ -147,5 +179,9 @@ spec:
147179
hostPath:
148180
path: /
149181
- name: glouton-config
150-
configMap:
151-
name: glouton-config
182+
projected:
183+
sources:
184+
- configMap:
185+
name: glouton-default-config
186+
- configMap:
187+
name: glouton-config

0 commit comments

Comments
 (0)