Kubernetes Participant performs the helm chart installation and LCM for k8s microservices that take part in Control loop. It implements Participant-Intermediary API to receive events from DMaap and interact with Helm CLI.
It acts as a wrapper around Helm Cli to manage helm charts and K8s pods deployed in the cluster.
Helm 3 overview:
In Helm3, helm cli acts as a interface to connect with Kubernetes cluster to deploy and manage helm charts. It also supports configuring multiple chart repositories to the helm client and access those charts for installation. The repositories can be a local chart server running on the same machine as well a third party chart server running elsewhere. The URL of the chart server is configured to the helm repo list to access the hosted charts. User can add a repository and push helm charts under the repository to be accessed during installation.
Example: configured chart repos and the available charts are listed via helm cli:
Kubernetes Participant Architecture in Istanbul:
Prerequisites for kubernetes participant:
- Kubernetes cluster running.
- Helm cli running.
Note: Incase of containerization of kubernetes participant in upcoming release, the kubeconfig file of required kubernetes cluster should be copied to the k8s-participant's docker container in order to make helm cli work with the cluster outside.
In Istanbul release, Kubernetes participant in control loop supports installation of helm charts in below ways:
- Installing a helm chart that is present in the local file system where the kubernetes participant is hosted.
- Installing any charts from the repositories that are configured on the helm client.
The K8s participant exposes rest end points through which below operations can be performed.
- Onboard a helm chart to the local directory. (A helm chart can be passed to the rest end point of k8s participant, it then stores the chart under the path /<pre-configured directory>/<chart name>/<version>/
- Delete a helm chart from the local storage.
- Install a helm chart in to the k8s cluster.
- Uninstall a helm chart in to the k8s cluster.
- Get all the charts available in the local chart storage directory.
It also implements participant-Intermediary APIs to interact with DMaap topic for control loop. When the Control loop element update event is received from DMaap, it invokes the helm client to install the corresponding chart based on the name and version of the chart.
When the k8s-participant receives event update from DMaap , it gets the parameters (chart name, version, release name, namespace). If the repository is not passed in the TOSCA, it does a lookup of the specified chart in all the configured repositories in the helm client as well as on the local directory where the helm charts are onboarded visa REST. It fetches the appropriate repository info and installs the chart via helm cli.
Sample TOSCA template passed during commissioning of control loops. (Note: Repository name is an optional parameter in control loop TOSCA template.)
org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement: # Chart from any chart repository configured on helm client. version: 1.2.3 type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement type_version: 1.0.0 description: Control loop element for the K8S microservice for Hello World properties: provider: ONAP participant_id: name: org.onap.k8s.controlloop.K8SControlLoopParticipant version: 2.3.4 chart: release_name: helloworld chart_name: hello version: 0.1.0 repository: chartMuseum namespace: onap org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: # Chart from local file system version: 1.2.3 type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement type_version: 1.0.0 description: Control loop element for the K8S microservice for PMSH properties: provider: ONAP participant_id: name: org.onap.k8s.controlloop.K8SControlLoopParticipant version: 2.3.4 chart: release_name: pmshmicroservice chart_name: pmsh version: 0.1.0 repository: /home/oom/helm-charts/PMSH namespace: onap org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: # Chart installation without passing repository name version: 1.2.3 type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement type_version: 1.0.0 description: Control loop element for the K8S microservice for any chart properties: provider: ONAP participant_id: name: org.onap.k8s.controlloop.K8SControlLoopParticipant version: 2.3.4 chart: release_name: nginxms chart_name: nginx-ingress version: 0.9.1 namespace: onap