Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ace-ocm-addons chart multicluster ready #339

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions charts/ace-ocm-addons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,34 @@ The command removes all the Kubernetes components associated with the chart and

The following table lists the configurable parameters of the `ace-ocm-addons` chart and their default values.

| Parameter | Description | Default |
|-------------------------------------------|-------------------------|--------------------------------------------|
| nameOverride | | <code>""</code> |
| fullnameOverride | | <code>""</code> |
| offlineInstaller | | <code>false</code> |
| image.proxies.appscode | r.appscode.com | <code>r.appscode.com</code> |
| image.proxies.dockerHub | company/bin:tag | <code>""</code> |
| image.proxies.dockerLibrary | alpine, nginx etc. | <code>""</code> |
| image.proxies.ghcr | ghcr.io/company/bin:tag | <code>ghcr.io</code> |
| image.proxies.quay | quay.io/company/bin:tag | <code>quay.io</code> |
| image.proxies.kubernetes | registry.k8s.io/bin:tag | <code>registry.k8s.io</code> |
| registry.credentials | | <code>{}</code> |
| helm.repositories.appscode-charts-oci.url | | <code>oci://ghcr.io/appscode-charts</code> |
| helm.releases.kube-ui-server.enabled | | <code>true</code> |
| helm.releases.kube-ui-server.version | | <code>"v2023.12.18"</code> |
| helm.releases.license-proxyserver.enabled | | <code>true</code> |
| helm.releases.license-proxyserver.version | | <code>"v2023.11.14"</code> |
| helm.releases.opscenter-features.enabled | | <code>true</code> |
| helm.releases.opscenter-features.version | | <code>"v2024.2.13"</code> |
| Parameter | Description | Default |
|-------------------------------------------|-------------------------|----------------------------------------------------|
| nameOverride | | <code>""</code> |
| fullnameOverride | | <code>""</code> |
| kubeconfigSecretName | | <code>""</code> |
| addonManagerNamespace | | <code>open-cluster-management-addon</code> |
| placement.create | | <code>true</code> |
| placement.name | | <code>global</code> |
| kubectl.image | | <code>ghcr.io/appscode/kubectl-nonroot:1.25</code> |
| offlineInstaller | | <code>false</code> |
| image.proxies.appscode | r.appscode.com | <code>r.appscode.com</code> |
| image.proxies.dockerHub | company/bin:tag | <code>""</code> |
| image.proxies.dockerLibrary | alpine, nginx etc. | <code>""</code> |
| image.proxies.ghcr | ghcr.io/company/bin:tag | <code>ghcr.io</code> |
| image.proxies.quay | quay.io/company/bin:tag | <code>quay.io</code> |
| image.proxies.kubernetes | registry.k8s.io/bin:tag | <code>registry.k8s.io</code> |
| registry.credentials | | <code>{}</code> |
| helm.repositories.appscode-charts-oci.url | | <code>oci://ghcr.io/appscode-charts</code> |
| helm.releases.kube-ui-server.enabled | | <code>true</code> |
| helm.releases.kube-ui-server.version | | <code>"v2023.12.20"</code> |
| helm.releases.opscenter-features.enabled | | <code>true</code> |
| helm.releases.opscenter-features.version | | <code>"v2024.2.13"</code> |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade -i`. For example:

```bash
$ helm upgrade -i ace-ocm-addons appscode/ace-ocm-addons -n open-cluster-management --create-namespace --version=v2024.2.13 --set image.proxies.appscode=r.appscode.com
$ helm upgrade -i ace-ocm-addons appscode/ace-ocm-addons -n open-cluster-management --create-namespace --version=v2024.2.13 --set addonManagerNamespace=open-cluster-management-addon
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{{- if .Values.placement.create }}

apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
name: global
namespace: global-kubeops
namespace: {{ include "ace-ocm-addons.namespace" . }}
spec:
clusterSet: global

{{- end }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: work.open-cluster-management.io/v1alpha1
kind: ManifestWorkReplicaSet
metadata:
name: opscenter-core-addons
namespace: global-kubeops
name: ace-addons
namespace: {{ include "ace-ocm-addons.namespace" $ }}
spec:
placementRefs:
- name: global
- name: {{ .Values.placement.name }}
manifestWorkTemplate:
# deleteOption:
# propagationPolicy: SelectivelyOrphan
Expand Down
12 changes: 12 additions & 0 deletions charts/ace-ocm-addons/common/addon/placement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.placement.create }}

apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: {{ .Values.placement.name }}
namespace: {{ include "ace-ocm-addons.namespace" . }}
spec:
clusterSets:
- global

{{- end }}
10 changes: 3 additions & 7 deletions charts/ace-ocm-addons/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
Addon manager namespace
*/}}
{{- define "ace-ocm-addons.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ace-ocm-addons.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- define "ace-ocm-addons.namespace" -}}
{{ ternary .Release.Namespace (required "A valid .Values.addonManagerNamespace is required!" .Values.addonManagerNamespace) (empty .Values.kubeconfigSecretName) }}
{{- end }}

{{/*
Expand Down
12 changes: 12 additions & 0 deletions charts/ace-ocm-addons/templates/k8s/addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if not .Values.kubeconfigSecretName }}

{{- $restpl := $.Files.Get "common/addon/clustersetbinding.yaml" }}
{{ tpl $restpl $ }}
---
{{- $restpl := $.Files.Get "common/addon/placement.yaml" }}
{{ tpl $restpl $ }}
---
{{- $restpl := $.Files.Get "common/addon/manifestrelicaset.yaml" }}
{{ tpl $restpl $ }}

{{- end }}
4 changes: 0 additions & 4 deletions charts/ace-ocm-addons/templates/namespace.yaml

This file was deleted.

49 changes: 49 additions & 0 deletions charts/ace-ocm-addons/templates/ocm-mc/addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if .Values.kubeconfigSecretName }}

apiVersion: batch/v1
kind: Job
metadata:
name: ace-configure-addon
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook-weight": "2"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
ttlSecondsAfterFinished: 0
backoffLimit: 3
template:
spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ .Values.kubectl.image }}
workingDir: /var/run/secrets/ocm
command:
- sh
- -c
- |
sleep 2; \
kubectl --kubeconfig=auth/kubeconfig create ns {{ include "ace-ocm-addons.namespace" $ }} || true; \
kubectl --kubeconfig=auth/kubeconfig apply -f - <<EOF
{{- $restpl := $.Files.Get "common/addon/clustersetbinding.yaml" -}}
{{- tpl $restpl $ | nindent 14 }}
---
{{- $restpl := $.Files.Get "common/addon/placement.yaml" -}}
{{- tpl $restpl $ | nindent 14 }}
---
{{- $restpl := $.Files.Get "common/addon/manifestrelicaset.yaml" -}}
{{- tpl $restpl $ | nindent 14 }}
EOF
imagePullPolicy: {{ .Values.imagePullPolicy }}
volumeMounts:
- mountPath: /var/run/secrets/ocm/auth
name: ocm-auth
volumes:
- name: ocm-auth
secret:
defaultMode: 420
secretName: {{ .Values.kubeconfigSecretName }}
restartPolicy: Never

{{- end }}
62 changes: 62 additions & 0 deletions charts/ace-ocm-addons/templates/ocm-mc/crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{- if .Values.kubeconfigSecretName }}
{{ range $path, $data := .Files.Glob "crds/**.yaml" }}

{{ $content := toString $data }}
{{ $crd := dig "spec" "names" "plural" "" ($content | fromYaml) }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ace-regcrd-{{ $crd }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook-weight": "0"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
data:
crd.yaml: |
{{- $content | nindent 4 }}

---
apiVersion: batch/v1
kind: Job
metadata:
name: ace-regcrd-{{ $crd }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook-weight": "1"
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed
spec:
ttlSecondsAfterFinished: 0
backoffLimit: 3
template:
spec:
automountServiceAccountToken: false
containers:
- name: kubectl
image: {{ $.Values.kubectl.image }}
workingDir: /var/run/secrets/ocm
command:
- sh
- -c
- "sleep 2; \
kubectl --kubeconfig=auth/kubeconfig apply -f /etc/crds/crd.yaml; \
"
imagePullPolicy: {{ $.Values.imagePullPolicy }}
volumeMounts:
- mountPath: /var/run/secrets/ocm/auth
name: ocm-auth
- name: crd-volume
mountPath: /etc/crds
volumes:
- name: ocm-auth
secret:
defaultMode: 420
secretName: {{ $.Values.kubeconfigSecretName }}
- name: crd-volume
configMap:
name: ace-regcrd-{{ $crd }}
restartPolicy: Never
{{- end }}
{{- end }}
8 changes: 0 additions & 8 deletions charts/ace-ocm-addons/templates/placement.yaml

This file was deleted.

15 changes: 11 additions & 4 deletions charts/ace-ocm-addons/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
nameOverride: ""
fullnameOverride: ""

kubeconfigSecretName: ""
addonManagerNamespace: open-cluster-management-addon

placement:
create: true
name: global

kubectl:
image: ghcr.io/appscode/kubectl-nonroot:1.25

offlineInstaller: false

image:
Expand Down Expand Up @@ -36,10 +46,7 @@ helm:
releases:
kube-ui-server:
enabled: true
version: "v2023.12.18"
license-proxyserver:
enabled: true
version: "v2023.11.14"
version: "v2023.12.20"
opscenter-features:
enabled: true
version: "v2024.2.13"
2 changes: 0 additions & 2 deletions charts/license-proxyserver-manager/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- if .Values.kubeconfigSecretName }}
- name: NAMESPACE
value: {{ include "license-proxyserver-manager.namespace" . }}
{{- end }}
volumeMounts:
- mountPath: /tmp/licenses
name: cache-dir
Expand Down
Loading