Skip to content

Commit 6dc0412

Browse files
mikhail-klimkoshirtabachii
authored andcommitted
feat: multi runtime install
1 parent b08d29a commit 6dc0412

File tree

10 files changed

+42
-16
lines changed

10 files changed

+42
-16
lines changed

charts/gitops-runtime/Chart.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies:
3232
- name: sealed-secrets
3333
repository: https://bitnami-labs.github.io/sealed-secrets/
3434
version: 2.17.2
35+
condition: sealed-secrets.enabled
3536
- name: codefresh-tunnel-client
3637
repository: oci://quay.io/codefresh/charts
3738
version: 0.1.21

charts/gitops-runtime/templates/_components/cf-argocd-extras/event-reporter/_rbac.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
{{/* Workaround to NOT change label selectors from previous runtime release when event-reporter was part of cf-argocd-extras Subchart */}}
1212
{{- $_ := set $context.Values "nameOverride" "cf-argocd-extras" }}
1313

14+
{{/* Remove nonResourceURLs when RBAC is namespaced */}}
15+
{{- $rules := $context.Values.rbac.rules }}
16+
{{- if $context.Values.rbac.namespaced }}
17+
{{- $rules = list }}
18+
{{- range $context.Values.rbac.rules }}
19+
{{- if not .nonResourceURLs }}
20+
{{- $rules = append $rules . }}
21+
{{- end }}
22+
{{- end }}
23+
{{- end }}
24+
{{- $_ := set $context.Values.rbac "rules" $rules }}
25+
1426
{{- $templateName := printf "cf-common-%s.rbac" (index .Subcharts "cf-common").Chart.Version }}
1527
{{- include $templateName $context }}
1628

charts/gitops-runtime/templates/_components/gitops-operator/_default_values.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ global:
1414

1515
replicaCount: 1
1616

17+
# -- Restrict the gitops operator to a single namespace (by the namespace of Helm release)
18+
singleNamespace: false
19+
1720
# -- Codefresh gitops operator crds
1821
crds:
1922
# -- Whether or not to install CRDs

charts/gitops-runtime/templates/_components/gitops-operator/promotion-template/_rbac.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{- define "gitops-operator.resources.promotion-template-rbac" }}
33
apiVersion: rbac.authorization.k8s.io/v1
4-
kind: ClusterRole
4+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
55
metadata:
66
labels:
77
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
@@ -45,14 +45,14 @@ rules:
4545

4646
---
4747
apiVersion: rbac.authorization.k8s.io/v1
48-
kind: ClusterRoleBinding
48+
kind: {{ .Values.singleNamespace | ternary "RoleBinding" "ClusterRoleBinding" }}
4949
metadata:
5050
labels:
5151
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
5252
name: promotion-template
5353
roleRef:
5454
apiGroup: rbac.authorization.k8s.io
55-
kind: ClusterRole
55+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
5656
name: promotion-template
5757
subjects:
5858
- kind: ServiceAccount

charts/gitops-runtime/templates/_components/gitops-operator/rbac/_auth_proxy_rbac.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{- define "gitops-operator.resources.auth-proxy-rbac" }}
33
apiVersion: rbac.authorization.k8s.io/v1
4-
kind: ClusterRole
4+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
55
metadata:
66
labels:
77
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
@@ -22,14 +22,14 @@ rules:
2222

2323
---
2424
apiVersion: rbac.authorization.k8s.io/v1
25-
kind: ClusterRoleBinding
25+
kind: {{ .Values.singleNamespace | ternary "RoleBinding" "ClusterRoleBinding" }}
2626
metadata:
2727
labels:
2828
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
2929
name: codefresh-gitops-operator-proxy
3030
roleRef:
3131
apiGroup: rbac.authorization.k8s.io
32-
kind: ClusterRole
32+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
3333
name: codefresh-gitops-operator-proxy
3434
subjects:
3535
- kind: ServiceAccount

charts/gitops-runtime/templates/_components/gitops-operator/rbac/_rbac_operator.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{- define "gitops-operator.resources.rbac-operator" }}
33
apiVersion: rbac.authorization.k8s.io/v1
4-
kind: ClusterRole
4+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
55
metadata:
66
labels:
77
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
@@ -26,6 +26,7 @@ rules:
2626
- patch
2727
- update
2828
- watch
29+
{{- if not .Values.singleNamespace }}
2930
- apiGroups:
3031
- codefresh.io
3132
resources:
@@ -52,6 +53,7 @@ rules:
5253
- get
5354
- patch
5455
- update
56+
{{- end }}
5557
- apiGroups:
5658
- ""
5759
resources:
@@ -72,29 +74,29 @@ rules:
7274

7375
---
7476
apiVersion: rbac.authorization.k8s.io/v1
75-
kind: ClusterRoleBinding
77+
kind: {{ .Values.singleNamespace | ternary "RoleBinding" "ClusterRoleBinding" }}
7678
metadata:
7779
labels:
7880
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
7981
name: codefresh-gitops-operator
8082
roleRef:
8183
apiGroup: rbac.authorization.k8s.io
82-
kind: ClusterRole
84+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
8385
name: codefresh-gitops-operator
8486
subjects:
8587
- kind: ServiceAccount
8688
name: {{ include "gitops-operator.serviceAccountName" . }}
8789
namespace: {{ .Release.Namespace }}
8890
---
8991
apiVersion: rbac.authorization.k8s.io/v1
90-
kind: ClusterRoleBinding
92+
kind: {{ .Values.singleNamespace | ternary "RoleBinding" "ClusterRoleBinding" }}
9193
metadata:
9294
labels:
9395
{{- include "gitops-operator.selectorLabels" . | nindent 4 }}
9496
name: codefresh-gitops-operator-workflows
9597
roleRef:
9698
apiGroup: rbac.authorization.k8s.io
97-
kind: ClusterRole
99+
kind: {{ .Values.singleNamespace | ternary "Role" "ClusterRole" }}
98100
name: argo-edit
99101
subjects:
100102
- kind: ServiceAccount

charts/gitops-runtime/templates/_components/gitops-operator/rbac/_restricted_git_source.rbac.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
{{- define "gitops-operator.resources.restricted-git-source-rbac" }}
3+
{{- if not .Values.singleNamespace }}
34
apiVersion: rbac.authorization.k8s.io/v1
45
kind: ClusterRole
56
metadata:
@@ -80,4 +81,5 @@ subjects:
8081
- kind: ServiceAccount
8182
name: {{ include "gitops-operator.serviceAccountName" . }}
8283
namespace: {{ .Release.Namespace }}
84+
{{- end }}
8385
{{- end }}

charts/gitops-runtime/templates/_helpers.tpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,14 @@ Output comma separated list of installed runtime components
431431
*/}}
432432
{{- define "codefresh-gitops-runtime.component-list"}}
433433
{{- $argoEvents := dict "name" "argo-events" "version" (get .Subcharts "argo-events").Chart.AppVersion }}
434-
{{- $sealedSecrets := dict "name" "sealed-secrets" "version" (get .Subcharts "sealed-secrets").Chart.AppVersion }}
435434
{{- $internalRouter := dict "name" "internal-router" "version" .Chart.AppVersion }}
436435
{{- $appProxy := dict "name" "app-proxy" "version" (index (get .Values "app-proxy") "image" "tag") }}
437436
{{- $sourcesServer := dict "name" "sources-server" "version" (get .Values "cf-argocd-extras").sourcesServer.container.image.tag }}
438-
{{- $comptList := list $argoEvents $appProxy $sealedSecrets $internalRouter $sourcesServer }}
437+
{{- $comptList := list $argoEvents $appProxy $internalRouter $sourcesServer }}
438+
{{- if and (index .Values "sealed-secrets" "enabled") }}
439+
{{- $sealedSecrets := dict "name" "sealed-secrets" "version" (get .Subcharts "sealed-secrets").Chart.AppVersion }}
440+
{{- $comptList = append $comptList $sealedSecrets }}
441+
{{- end }}
439442
{{- if and (index .Values "argo-cd" "enabled") }}
440443
{{- $argoCD := dict "name" "argocd" "version" (get .Subcharts "argo-cd").Chart.AppVersion }}
441444
{{- $comptList = append $comptList $argoCD }}

charts/gitops-runtime/templates/app-proxy/workflows-crb.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
{{- $_ := set $appProxyContext "Values" (deepCopy (get .Values "app-proxy")) }}
55
{{- $_ := set $appProxyContext.Values "global" (deepCopy (get .Values "global")) }}
66
apiVersion: rbac.authorization.k8s.io/v1
7-
kind: ClusterRoleBinding
7+
kind: {{ $appProxyContext.Values.singleNamespace | ternary "RoleBinding" "ClusterRoleBinding" }}
88
metadata:
99
name: cap-app-proxy-argo-workflows
1010
roleRef:
1111
apiGroup: rbac.authorization.k8s.io
12-
kind: ClusterRole
12+
kind: {{ $appProxyContext.Values.singleNamespace | ternary "Role" "ClusterRole" }}
1313
name: {{ include "codefresh-gitops-runtime.argo-workflows.server.name" . }}
1414
subjects:
1515
- kind: ServiceAccount

charts/gitops-runtime/values.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,9 @@ gitops-operator:
713713
annotations: {}
714714
# -- Additional labels for gitops operator CRDs
715715
additionalLabels: {}
716+
# -- Restrict the gitops operator to a single namespace (by the namespace of Helm release)
717+
singleNamespace: false
718+
# -- GitOps operator configuration
716719
config:
717720
# -- Task polling interval
718721
taskPollingInterval: 10s
@@ -724,8 +727,8 @@ gitops-operator:
724727
maxConcurrentReleases: 100
725728
# -- An optional template for the promotion wrapper (empty default will use the embedded one)
726729
promotionWrapperTemplate: ''
730+
# -- GitOps operator image
727731
image:
728-
# -- defaults
729732
registry: quay.io
730733
repository: codefresh/codefresh-gitops-operator
731734
tag: v0.11.1

0 commit comments

Comments
 (0)