Skip to content

Commit

Permalink
Create initContainer to wait for clustermanagementaddons
Browse files Browse the repository at this point in the history
Signed-off-by: francostellari <[email protected]>

rebase
  • Loading branch information
francostellari committed Apr 9, 2024
1 parent 73d8e3a commit 97d4d91
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 29 deletions.
40 changes: 27 additions & 13 deletions chart/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,33 @@ spec:
labels:
app: status-controller
spec:
initContainers:
- name: create-crd
image: quay.io/kubestellar/kubectl:1.29.3
command: ['sh', '-c']
args:
- |
echo -n "Waiting for managedclusteraddons CRD"
while [ "$(kubectl get crd clustermanagementaddons.addon.open-cluster-management.io 2> /dev/null)" == "" ] ; do
echo -n "."
sleep 1
done
echo -e "\033[0;32m\xE2\x9C\x94\033[0m"
echo "Creating addon-status CR:"
kubectl apply -f - <<EOF
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: addon-status
namespace: open-cluster-management
spec:
addOnMeta:
description: status addon provides full status on applied resources
displayName: addon-status
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
EOF
containers:
- args:
- controller
Expand All @@ -239,16 +266,3 @@ spec:
securityContext:
runAsNonRoot: true
serviceAccountName: addon-status-sa
---
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: addon-status
namespace: open-cluster-management
spec:
addOnMeta:
description: status addon provides full status on applied resources
displayName: addon-status
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
11 changes: 0 additions & 11 deletions config/manager/clustermanagementaddon.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
resources:
- manager.yaml
- clustermanagementaddon.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ko.local/ocm-status-addon
newTag: to_be_replaced
newTag: ce5c42d

replacements:
- source:
Expand Down
29 changes: 28 additions & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ spec:
securityContext:
runAsNonRoot: true
serviceAccountName: status-sa
initContainers:
- name: create-crd
image: quay.io/kubestellar/kubectl:1.29.3
command: ['sh', '-c']
args:
- |
echo -n "Waiting for managedclusteraddons CRD"
while [ "$(kubectl get crd clustermanagementaddons.addon.open-cluster-management.io 2> /dev/null)" == "" ] ; do
echo -n "."
sleep 1
done
echo -e "\033[0;32m\xE2\x9C\x94\033[0m"
echo "Creating addon-status CR:"
kubectl apply -f - <<EOF
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ClusterManagementAddOn
metadata:
name: addon-status
namespace: open-cluster-management
spec:
addOnMeta:
description: status addon provides full status on applied resources
displayName: addon-status
supportedConfigs:
- group: addon.open-cluster-management.io
resource: addondeploymentconfigs
EOF
containers:
- name: status-controller
image: controller
Expand All @@ -39,7 +66,7 @@ spec:
memory: 512Mi
requests:
cpu: 10m
memory: 64Mi
memory: 64Mi
env:
- name: STATUS_ADDDON_IMAGE_NAME
value: STATUS_ADDDON_IMAGE_NAME_PLACEHOLDER
Expand Down
12 changes: 10 additions & 2 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: manager-role
name: addon-manager-role
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -31,8 +30,11 @@ rules:
resources:
- clustermanagementaddons
verbs:
- create
- get
- list
- patch
- update
- watch
- apiGroups:
- addon.open-cluster-management.io
Expand Down Expand Up @@ -158,3 +160,9 @@ rules:
- patch
- update
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get

0 comments on commit 97d4d91

Please sign in to comment.