A Helm Operator is used to deploy a Helm Chart based on a CRD. In our case we will create an Operator that installs the new Helm Chart of BMC Control-M Agent.
For more information please refer to https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/
agent-docker-manifests --> container manifests (dockerfile and entrypoint) used to build the UBI-based Agent.
bundle --> Operator Bundle resources
config --> SDK-generated configurations. also contains a running Custom Resource for testing, under /samples.
helm-charts --> the up to date chart. This is newer than the one inside the "automation community" repo. contains a fix for SCC on Openshift.
First checkout the existing Helm chart present in https://github.com/controlm/automation-api-community-solutions/pull/105/files
And then executed
operator-sdk init \
--plugins helm \
--domain bmc.com \
--group controlm \
--version v1alpha1 \
--kind Agent \
----helm-chart ../automation-api-community-solutions/3-infrastructure-as-code-examples/kubernetes-agent-using-helm/control-m-agent
The result is an initial repository similar to this one.
Next, verified to match the roles and permissions under config/rbac/role.yaml
with the contents of the Helm chart.
Since the chart creates a role, a statefulset, a pvc and a secret - all are required to be given as permissions to the roles of the Operator.
cd agent-docker-manifests
docker build \
--build-arg AAPI_END_POINT=<API ENDPOINT>/automation-api \
--build-arg AAPI_USER=<CTRLM_USER> \
--build-arg AAPI_PASS=<CTRLM_PASS> \
--build-arg AGENT_IMAGE_NAME=Agent_Image.Linux \
--build-arg SUB_USER=<RH_SUBSCRIPTION_USER> \
--build-arg SUB_PWD=<RH_SUBSCRIPTION_PASS> \
. -t <bmc-repository>/controlmagent:<tag>
cd ..
Inspect IMG
inside Makefile
and then run make docker-build && make docker-push
See Bundle and OperatorHub integration
below
Deploy the Operator's Controller Manager make deploy
And then
kubectl apply -f
the example CR config/samples/controlm_v1alpha1_agent.yaml
The Controller Manager will reconcile installation of the Helm Chart, and create/update Agents.
Remove the installed agent by oc delete -f config/samples/controlm_v1alpha1_agent.yaml
Run make undeploy
to remove the CRD and the Operator.
The Operator can be installed to a cluster with OLM integration, using the following command -
operator-sdk run bundle quay.io/itroyano/controlmagent-helm-bundle:0.0.2
and then
oc apply -f
the example CR config/samples/controlm_v1alpha1_agent.yaml
The Controller Manager will reconcile installation of the Helm Chart, and create/update Agents.
Check the makefile for the following targets
make bundle
And then
make bundle-build
make bundle-push
- Create an official, certified image of the Agent by moving dockerFile and Entrypoints from the above PR into a CI inside BMC and and official image repo.
- Bundle this repo with OLM, move to an official CI inside BMC, and certify.
- Finally, upload to OperatorHub.