-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add a controller to support addon template #187
Merged
openshift-merge-robot
merged 15 commits into
open-cluster-management-io:main
from
zhujian7:addon-template-prototype
Jun 21, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ec19ba4
Add addon template api
zhujian7 00fede6
Add addon template controller
zhujian7 b4b0cad
Add e2e for addon template
zhujian7 139fb86
Refactor addon template controller to start manager per cma
zhujian7 81ece45
Add unit tests for addon templates
zhujian7 a0e34e3
expose informrs when run addon manager
zhujian7 c7d996c
remove unnecessary permissions
zhujian7 5e8ba21
get addon template from cache
zhujian7 064639a
move template agent files to a seperate packate
zhujian7 9408b54
add indexers before informers start
zhujian7 5de1f8f
change template registration functions to methods
zhujian7 1d90325
add unit tests for addon template controller
zhujian7 168f409
fix e2e issues
zhujian7 6a1a57a
add list watch rolebinding permission for addon manager
zhujian7 133f697
update config spec hash by addon framework for template type addon
zhujian7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the annotation deletion-orphan still can work in addonTemplate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it can work since the template controller just start a go routine to run the framework code.