Skip to content

Commit 5063756

Browse files
authored
Merge pull request #230 from projectsyn/feat/customize-operator-env
Support configuring arbitrary argocd-operator environment variables
2 parents 9c71122 + c288fa4 commit 5063756

File tree

5 files changed

+61
-7
lines changed

5 files changed

+61
-7
lines changed

class/defaults.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ parameters:
121121
manifests_version: ${argocd:images:argocd_operator:tag}
122122
cluster_scope_namespaces:
123123
- "${argocd:namespace}"
124+
env: {}
124125
kustomization_url: https://github.com/argoproj-labs/argocd-operator//config/default/
125126
kustomize_input:
126127
namePrefix: syn-

component/operator.jsonnet

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,33 @@ local params = inv.parameters.argocd.operator;
77
local image = params.images.argocd_operator;
88
local rbac = params.images.kube_rbac_proxy;
99

10+
local skip(var) =
11+
var == 'ARGOCD_CLUSTER_CONFIG_NAMESPACES';
12+
1013
local kustomize_patch_scopens = if std.length(params.cluster_scope_namespaces) > 0 then {
1114
patches+: [
1215
{
13-
patch: std.format(|||
14-
- op: add
15-
path: "/spec/template/spec/containers/1/env/-"
16-
value:
17-
name: "ARGOCD_CLUSTER_CONFIG_NAMESPACES"
18-
value: "%s"
19-
|||, std.join(',', params.cluster_scope_namespaces)),
16+
patch: std.manifestYamlDoc([
17+
{
18+
op: 'add',
19+
path: '/spec/template/spec/containers/1/env/-',
20+
value: {
21+
name: 'ARGOCD_CLUSTER_CONFIG_NAMESPACES',
22+
value: std.join(',', params.cluster_scope_namespaces),
23+
},
24+
},
25+
] + [
26+
{
27+
op: 'add',
28+
path: '/spec/template/spec/containers/1/env/-',
29+
value: {
30+
name: envvar,
31+
value: params.env[envvar],
32+
},
33+
}
34+
for envvar in std.objectFields(params.env)
35+
if !skip(envvar)
36+
]),
2037
target: {
2138
kind: 'Deployment',
2239
name: 'argocd-operator-controller-manager',

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,50 @@ Configuration for the ArgoCD operator which is deployed as part of this componen
302302

303303

304304
=== `operator.namespace`
305+
306+
[horizontal]
305307
type:: string
306308
default:: `syn-argocd-operator`
307309

308310
The namespace in which to deploy the argocd operator
309311

310312
=== `operator.cluster_scope_namespaces`
313+
314+
[horizontal]
311315
type:: array
312316
default:: `["${argocd:namespace}"]`
313317

314318
List of namespaces in which argocd is allowed to be installed at the cluster scope.
315319

320+
=== `operator.env`
321+
322+
[horizontal]
323+
type:: dictionary
324+
default:: `{}`
325+
326+
Entries in this dictionary are configured as environment variables for the argocd operator container.
327+
328+
[NOTE]
329+
====
330+
The environment variable `ARGOCD_CLUSTER_CONFIG_NAMESPACES` can't be set through this parameter.
331+
332+
This variable is configured through component parameter `operator.cluster_scope_namespaces`.
333+
====
334+
335+
[IMPORTANT]
336+
====
337+
ArgoCD may fail to update the argocd-operator deployment after you remove an entry from this config parameter.
338+
If you get an error like the one shown below, you need to edit the argocd-operator deployment by hand and delete the environment variable(s) which you've removed from this parameter.
339+
340+
[source]
341+
----
342+
Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error removing non config mutations for resource Deployment/syn-argocd-operator-controller-manager: error reverting webhook removed fields in predicted live resource: .spec.template.spec.containers: element 0: associative list with keys has an element that omits key field "name" (and doesn't have default value)
343+
----
344+
====
345+
316346
=== `operator.migrate`
347+
348+
[horizontal]
317349
type:: string
318350
default:: `false`
319351

tests/golden/params/argocd/argocd/10_operator/apps_v1_deployment_syn-argocd-operator-controller-manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ spec:
4949
fieldPath: metadata.annotations['olm.targetNamespaces']
5050
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
5151
value: syn
52+
- name: FOO
53+
value: bar
5254
image: quay.io/argoprojlabs/argocd-operator:v0.12.2
5355
livenessProbe:
5456
httpGet:

tests/params.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ parameters:
4040
server: null
4141
operator:
4242
migrate: true
43+
env:
44+
FOO: bar
4345

4446
instances:
4547
another-ns/nulled: null

0 commit comments

Comments
 (0)