Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit ce0b03e

Browse files
committed
chore: add post-install-job to upgrade kubefedconfig
Signed-off-by: Hector Fernandez <[email protected]>
1 parent c1ee4df commit ce0b03e

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

charts/kubefed/charts/controllermanager/templates/kubefedconfig.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ spec:
3030
configuration: {{ .Values.featureGates.CrossClusterServiceDiscovery | default "Disabled" | quote }}
3131
- name: FederatedIngress
3232
configuration: {{ .Values.featureGates.FederatedIngress | default "Disabled" | quote }}
33+
# NOTE: Commented feature gate to fix https://github.com/kubernetes-sigs/kubefed/issues/1333
34+
#- name: RawResourceStatusCollection
35+
# configuration: {{ .Values.featureGates.RawResourceStatusCollection | default "Disabled" | quote }}
3336
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
kind: ConfigMap
3+
apiVersion: v1
4+
metadata:
5+
name: "{{ .Release.Name }}-kubefed-config-hook"
6+
namespace: "{{ .Release.Namespace }}"
7+
annotations:
8+
"helm.sh/hook": post-install, post-upgrade
9+
"helm.sh/hook-weight": "-5"
10+
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
11+
data:
12+
setup.sh: |-
13+
#!/bin/bash
14+
set -euo pipefail
15+
16+
kubectl patch kubefedconfig -n {{ .Release.Namespace }} kubefed --type='json' -p='[{"op": "add", "path": "/spec/featureGates", "value":[{"configuration": {{ .Values.featureGates.PushReconciler | default "Enabled" | quote }},"name":"PushReconciler"},{"configuration": {{ .Values.featureGates.CrossClusterServiceDiscovery | default "Disabled" | quote }},"name":"CrossClusterServiceDiscovery"},{"configuration": {{ .Values.featureGates.RawResourceStatusCollection | default "Disabled" | quote }},"name":"RawResourceStatusCollection"},{"configuration": {{ .Values.featureGates.FederatedIngress | default "Disabled" | quote }},"name":"FederatedIngress"},{"configuration": {{ .Values.featureGates.SchedulerPreferences | default "Enabled" | quote }},"name":"SchedulerPreferences"}]}]'
17+
18+
echo "Kubefedconfig patched successfully!"
19+
20+
kubectl rollout restart deployment/kubefed-controller-manager -n {{ .Release.Namespace }}
21+
---
22+
apiVersion: batch/v1
23+
kind: Job
24+
metadata:
25+
name: "{{ .Release.Name }}-{{ randAlphaNum 10 | lower }}"
26+
namespace: "{{ .Release.Namespace }}"
27+
labels:
28+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
29+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
30+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
31+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
32+
annotations:
33+
"helm.sh/hook": post-install,post-upgrade
34+
"helm.sh/hook-weight": "-4"
35+
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
36+
spec:
37+
template:
38+
metadata:
39+
name: "{{ .Release.Name }}"
40+
labels:
41+
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
42+
app.kubernetes.io/instance: {{ .Release.Name | quote }}
43+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
44+
spec:
45+
restartPolicy: Never
46+
serviceAccountName: kubefed-config-hook
47+
automountServiceAccountToken: true
48+
containers:
49+
- name: post-install-job
50+
image: "bitnami/kubectl:1.17.16"
51+
command: ["/bin/bash"]
52+
args: ["/opt/scripts/setup.sh"]
53+
volumeMounts:
54+
- name: "scripts"
55+
mountPath: "/opt/scripts"
56+
volumes:
57+
- name: "scripts"
58+
configMap:
59+
name: "{{ .Release.Name }}-kubefed-config-hook"
60+
---
61+
apiVersion: rbac.authorization.k8s.io/v1
62+
kind: Role
63+
metadata:
64+
name: kubefed-config-hook
65+
namespace: {{ .Release.Namespace }}
66+
annotations:
67+
"helm.sh/hook": post-install, post-upgrade
68+
"helm.sh/hook-weight": "-5"
69+
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
70+
rules:
71+
- apiGroups: ["apps"]
72+
resources: ["deployments"]
73+
verbs: ["patch","get"]
74+
- apiGroups: ["core.kubefed.io"]
75+
resources: ["kubefedconfigs"]
76+
verbs: ["patch","get"]
77+
---
78+
apiVersion: rbac.authorization.k8s.io/v1
79+
kind: RoleBinding
80+
metadata:
81+
name: kubefed-config-hook
82+
namespace: {{ .Release.Namespace }}
83+
annotations:
84+
"helm.sh/hook": post-install, post-upgrade
85+
"helm.sh/hook-weight": "-5"
86+
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
87+
roleRef:
88+
apiGroup: rbac.authorization.k8s.io
89+
kind: Role
90+
name: kubefed-config-hook
91+
subjects:
92+
- kind: ServiceAccount
93+
name: kubefed-config-hook
94+
---
95+
apiVersion: v1
96+
kind: ServiceAccount
97+
metadata:
98+
name: kubefed-config-hook
99+
namespace: {{ .Release.Namespace }}
100+
annotations:
101+
"helm.sh/hook": post-install, post-upgrade
102+
"helm.sh/hook-weight": "-5"
103+
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation

charts/kubefed/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ controllermanager:
2525
SchedulerPreferences:
2626
CrossClusterServiceDiscovery:
2727
FederatedIngress:
28+
RawResourceStatusCollection:
2829

2930
## common node selector
3031
commonNodeSelector: {}

0 commit comments

Comments
 (0)