-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a controller to support addon template (#187)
* Add addon template api Signed-off-by: zhujian <jiazhu@redhat.com> * Add addon template controller Signed-off-by: zhujian <jiazhu@redhat.com> * Add e2e for addon template Signed-off-by: zhujian <jiazhu@redhat.com> * Refactor addon template controller to start manager per cma Signed-off-by: zhujian <jiazhu@redhat.com> * Add unit tests for addon templates Signed-off-by: zhujian <jiazhu@redhat.com> * expose informrs when run addon manager Signed-off-by: zhujian <jiazhu@redhat.com> * remove unnecessary permissions Signed-off-by: zhujian <jiazhu@redhat.com> * get addon template from cache Signed-off-by: zhujian <jiazhu@redhat.com> * move template agent files to a seperate packate Signed-off-by: zhujian <jiazhu@redhat.com> * add indexers before informers start Signed-off-by: zhujian <jiazhu@redhat.com> * change template registration functions to methods Signed-off-by: zhujian <jiazhu@redhat.com> * add unit tests for addon template controller Signed-off-by: zhujian <jiazhu@redhat.com> * fix e2e issues Signed-off-by: zhujian <jiazhu@redhat.com> * add list watch rolebinding permission for addon manager Signed-off-by: zhujian <jiazhu@redhat.com> * update config spec hash by addon framework for template type addon Signed-off-by: zhujian <jiazhu@redhat.com> --------- Signed-off-by: zhujian <jiazhu@redhat.com>
- Loading branch information
Showing
87 changed files
with
5,926 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
examples/deploy/addon/helloworld-template/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
namespace: hub | ||
|
||
resources: | ||
- resources/addon_deployment_config.yaml | ||
- resources/addon_template.yaml | ||
- resources/cluster_management_addon.yaml | ||
- resources/managed_cluster_addon.yaml | ||
- resources/cluster_role.yaml | ||
|
||
|
||
images: | ||
- name: quay.io/open-cluster-management/addon-examples | ||
newName: quay.io/open-cluster-management/addon-examples | ||
newTag: latest |
9 changes: 9 additions & 0 deletions
9
examples/deploy/addon/helloworld-template/resources/addon_deployment_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: addon.open-cluster-management.io/v1alpha1 | ||
kind: AddOnDeploymentConfig | ||
metadata: | ||
name: hello-template | ||
namespace: hub | ||
spec: | ||
customizedVariables: | ||
- name: LOG_LEVEL | ||
value: "4" |
102 changes: 102 additions & 0 deletions
102
examples/deploy/addon/helloworld-template/resources/addon_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
apiVersion: addon.open-cluster-management.io/v1alpha1 | ||
kind: AddOnTemplate | ||
metadata: | ||
name: hello-template | ||
spec: | ||
addonName: hello-template | ||
agentSpec: | ||
workload: | ||
manifests: | ||
- kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: hello-template-agent | ||
namespace: open-cluster-management-agent-addon | ||
annotations: | ||
"addon.open-cluster-management.io/deletion-orphan": "" | ||
labels: | ||
app: hello-template-agent | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: hello-template-agent | ||
template: | ||
metadata: | ||
labels: | ||
app: hello-template-agent | ||
spec: | ||
serviceAccountName: hello-template-agent-sa | ||
containers: | ||
- name: helloworld-agent | ||
image: quay.io/open-cluster-management/addon-examples | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "/helloworld_helm" | ||
- "agent" | ||
- "--cluster-name={{CLUSTER_NAME}}" | ||
- "--addon-namespace=open-cluster-management-agent-addon" | ||
- "--addon-name=hello-template" | ||
- "--hub-kubeconfig={{HUB_KUBECONFIG}}" | ||
env: | ||
- name: LOG_LEVEL | ||
value: "{{LOG_LEVEL}}" # addonDeploymentConfig variables | ||
- kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
name: hello-template-agent-sa | ||
namespace: open-cluster-management-agent-addon | ||
annotations: | ||
"addon.open-cluster-management.io/deletion-orphan": "" | ||
- kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: hello-template-agent | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: hello-template-agent-sa | ||
namespace: open-cluster-management-agent-addon | ||
- kind: Job | ||
apiVersion: batch/v1 | ||
metadata: | ||
name: hello-template-cleanup-configmap | ||
namespace: open-cluster-management-agent-addon | ||
annotations: | ||
"addon.open-cluster-management.io/addon-pre-delete": "" | ||
spec: | ||
manualSelector: true | ||
selector: | ||
matchLabels: | ||
job: hello-template-cleanup-configmap | ||
template: | ||
metadata: | ||
labels: | ||
job: hello-template-cleanup-configmap | ||
spec: | ||
serviceAccountName: hello-template-agent-sa | ||
restartPolicy: Never | ||
containers: | ||
- name: hello-template-agent | ||
image: quay.io/open-cluster-management/addon-examples | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "/helloworld_helm" | ||
- "cleanup" | ||
- "--addon-namespace=open-cluster-management-agent-addon" | ||
registration: | ||
# kubeClient or custom signer, if kubeClient, user and group is in a certain format. | ||
# user is "system:open-cluster-management:cluster:{clusterName}:addon:{addonName}:agent:{agentName}" | ||
# group is ["system:open-cluster-management:cluster:{clusterName}:addon:{addonName}", | ||
# "system:open-cluster-management:addon:{addonName}", "system:authenticated"] | ||
- type: KubeClient | ||
kubeClient: | ||
hubPermissions: | ||
- type: CurrentCluster | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cm-admin |
20 changes: 20 additions & 0 deletions
20
examples/deploy/addon/helloworld-template/resources/cluster_management_addon.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: addon.open-cluster-management.io/v1alpha1 | ||
kind: ClusterManagementAddOn | ||
metadata: | ||
name: hello-template | ||
annotations: | ||
addon.open-cluster-management.io/lifecycle: "addon-manager" | ||
spec: | ||
addOnMeta: | ||
description: hello-template | ||
displayName: hello-template | ||
supportedConfigs: | ||
- group: addon.open-cluster-management.io | ||
resource: addontemplates | ||
defaultConfig: | ||
name: hello-template | ||
- group: addon.open-cluster-management.io | ||
resource: addondeploymentconfigs | ||
defaultConfig: | ||
name: hello-template | ||
namespace: hub |
25 changes: 25 additions & 0 deletions
25
examples/deploy/addon/helloworld-template/resources/cluster_role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: cm-admin | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- update | ||
- patch | ||
- delete | ||
- apiGroups: | ||
- "addon.open-cluster-management.io" | ||
resources: | ||
- managedclusteraddons | ||
verbs: | ||
- get | ||
- list | ||
- watch |
7 changes: 7 additions & 0 deletions
7
examples/deploy/addon/helloworld-template/resources/managed_cluster_addon.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: addon.open-cluster-management.io/v1alpha1 | ||
kind: ManagedClusterAddOn | ||
metadata: | ||
name: hello-template | ||
namespace: hub | ||
spec: | ||
installNamespace: open-cluster-management-agent-addon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.