You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This is work in progress

Introduction

The helm manager is a service for managing helm charts.  The service provides a REST API for onboarding of charts as well as installation and uninstallation of applications based on these charts.

In addition to the helm manager, a chart repository is used to store the available. charts for onboarding and installation.

The Helm manager (and chart repo) can be executed in one of the following deployments:

  • As docker container on a local machine with kubernbetes
  • As kubernetes services/pods on a local machine with kubernetes
  • As kubernetes services/pods on a kubernetes cluster

Preparation

Clone the nonrtric repo from gerrit and change dir. Make sure to use the correct branch when cloning.

All needed scripts for start and run the helm manager, in docker or kubernetes are in this directory.

If the Helm Manager shall be installed in a kubernetes cluster the actions below shall be made on a node in cluster.

$ git clone "https://gerrit.o-ran-sc.org/r/nonrtric" -b <branch>

$ cd helm-manager

Build image

There is no need to build the image for the helm manager unless changes are made to the Dockerfile in the current dir.

Instruction to build the image:

$ mvn clean package

The  built image should be named: o-ran-sc/nonrtric-helm-manager:1.0.0-SNAPSHOT

$ docker images | grep helm
o-ran-sc/nonrtric-helm-manager                        1.0.0-SNAPSHOT  

Note: Note, replace the image name in the  docker-hm.sh and kube-hm.sh  if this image shall be used.

Note: Locally built images are not available to a kubernetes cluster unless the image is made available in an image repo accessible from within the cluster.

Create helm chart for test

$ helm create simple-app


Run in docker with local kubernetes

The helm-manger is possible to run as a docker container. However, a local kubernetes must be running where the application can be installed.

Create a private docker network for the containers to run in

$ docker network create nonrtric-docker-net

Start the chartmuseum container. Make note of the port, 8222, which will be available on local host. Charts uploaded to the chartmuseum container will be availed in the dir 'charts' on your host.ls

$ ./docker-cm.sh
docker-cm.sh
docker run --rm -it \
    -p 8222:8080 \
    --name chartmuseum \
    --network nonrtric-docker-net \
    -e DEBUG=1 \
    -e STORAGE=local \
    -e STORAGE_LOCAL_ROOTDIR=/charts \
    -v $(pwd)/charts:/charts \
    ghcr.io/helm/chartmuseum:v0.13.1

Add the chart, created in the section 'Create helm for test', to the repo

$ curl --data-binary "@simple-app-0.1.0.tgz" -X POST http://localhost:8222/api/charts


Start the helm manager. Make note of the port, 8112, which will be available on local host. This is the port to the Helm manager REST API.

$ ./docker-cm.sh
docker-hm.sh
docker run \
    --rm  \
    -it \
    -p 8112:8083  \
    --name helmmanagerservice \
    --network nonrtric-docker-net \
    -v $(pwd)/mnt/database:/var/helm-manager/database \
    -v ~/.kube:/root/.kube \
    -v ~/.helm:/root/.helm \
    -v ~/.config/helm:/root/.config/helm \
    -v ~/.cache/helm:/root/.cache/helm \
    -v $(pwd)/config/KubernetesParticipantConfig.json:/opt/app/helm-manager/src/main/resources/config/KubernetesParticipantConfig.json \
    -v $(pwd)/config/application.yaml:/opt/app/helm-manager/src/main/resources/config/application.yaml \
    o-ran-sc/nonrtric-helm-manager:1.0.0-SNAPSHOT

The chartmusem repo need to added to helm. This operation must be called with an url accessable from the container.

Go into the helm manager container and add the rep

$ docker exec -it helmmanagerservice sh
$ repo add cm http://chartmuseum:8080
$ exit


The helm manager is now running and configured with a chart repo.

Run the script test.sh to execute a the sequence:

  • Onboard chart
  • Install chart
  • Uninstall chart
  • Remove (the onboarded) chart

All operations should report "OK".

$ ./test.sh docker


Run in kubernetes

This instruction is valid for running both in a local kubernetes and in a kubernetes ccluster

Check if the nonrtric names space exists

kubectl get ns nonrtric

If the namespace does not exist, create it.

kubectl create ns nonrtric

Start the chartmuseum service and pod

kubectl apply f   cm/svc app.yaml

Find the nodeport of the service

kubectl get svc chartrepo -n nonrtric -o jsonpath='{...ports[?(@.name=="'http'")].nodePort}'

Add the chart to the repo

curl --data-binary "@simple-app-0.1.0.tgz" -X POST http://localhost:<port-to-chartrepo>/api/charts

If running in kubernetes cluster

Add the service account for the helm manager. Note that this uses the 'cluster-admin' role which has wide permission. This should only be used for test.

kubectrl apply f helm-manager-sa.yam

Edit the svc-app.yaml, set 'service-acccount-name' to helm-manager-sa

Start the helm manager

kubectl apply f   svc app.yaml

Go into the helm manger pod and add the chartrepo

kubectl exec -it helmmanagerservice n nonrtric -  sh

cmd prompt: helm repo add cm http://chartrepo.nonrtric:8080

cmd prompt: exit

Run the test script.

This script will onboard chart, install an application based on the chart, unstall the application and finally remove the chart.

./test.sh local-kluster





  • No labels