Klusterlet addon controller supports some installation and termination of add-ons on ManagedCluster for ACM.
Check the CONTRIBUTING Doc for how to contribute to the repo.
This is a guide on how to build and deploy klusterlet addon controller from code.
Kubernetes controller for the KlusterletAddonConfig custom resource that manages the Create/Update/Delete of klusterlet addon operator and klusterlet addons on the managed cluster via ManifestWork.
# can be installed with the following command
> make deps
make utils-crds-install
make run
deploy
to create the ServiceAccount, ClusterRole, ClusterRoleBinding and Deployment for the operatormake deploy
NOTE:
To create a klusterlet addon operator deployment with the klusterlet addon controller you need to create the KlusterletAddonConfig CR
Example of KlusterletAddonConfig CR https://github.com/stolostron/klusterlet-addon-controller/blob/main/deploy/crds/agent.open-cluster-management.io_v1_klusterletaddonconfig_cr.yaml
Any modifications to files pkg/apis/agent/v1/*types.go will require you to run the following:
operator-sdk generate k8s
to regenerate the zz_generated.deepcopy.go file.
Kind
export KUBECONFIG=<cluster kube config>
make test-e2e
Make sure you have ginkgo excutable ready in your env. If not, do the following:
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega/...
Run functional test locally with KinD, you will need to install Kind https://kind.sigs.k8s.io/docs/user/quick-start/#installation
export COMPONENT_TAG_EXTENSION=-SNAPSHOT-2020-04-01-20-49-00
export DOCKER_USER=<Docker username>
export DOCKER_PASS=<Docker password>
make functional-test-full
make component/test/functional
export KUBECONFIG=...
make functional-test
To patch the addons, you need to first stop reconcile of the KlusterletAddonConfig on hub:
oc annotate klusterletaddonconfig -n ${CLUSTER_NAME} ${CLUSTER_NAME} klusterletaddonconfig-pause=true --overwrite=true
After running the command, klusterlet-addon-controller will not update and sync the addons, so you can modify.
If you only want to update images of an addon, you can directly modify the manifestwork for that addon on hub. Here is an example of updating application manager. Execute this command on hub:
oc edit manifestwork -n ${CLUSTER_NAME} ${CLUSTER_NAME}-klusterlet-addon-appmgr
Other addons are:
If you want to patch deployments directly on the managed cluster.
You can scale down the klusterlet-addon-operator on the managed cluster.
To do so, on hub, edit the manifestwork of ${CLUSTER_NAME}-klusterlet-addon-operator
on hub, and search for Deployment
. Set spec.replicas to 0:
oc edit manifestwork -n ${CLUSTER_NAME} ${CLUSTER_NAME}-klusterlet-addon-operator
Please remember to restore the replicas when you finishing the devs. Otherwise you will not able to cleanup the managed cluster properly when detach.