kubeplus icon indicating copy to clipboard operation
kubeplus copied to clipboard

Use PV and PVC backed volumes to store application charts

Open devdattakulkarni opened this issue 1 year ago • 1 comments
trafficstars

Application charts are stored on local file system (on the path /) of helmer and kubeconfiggenerator. See below for a reference:

https://github.com/cloud-ark/kubeplus/blob/master/plugins/kubectl-upload-chart#L14-#L15

The corresponding volumes of helmer and kubeconfiggenerator are not persistent. If KubePlus Pod is recreated (for instance, when KubePlus is updated), the charts stored on this local volumes of the Pod are lost. We should use a PVC backed volume with helmer and kubeconfiggenerator for storing the chart.

devdattakulkarni avatar Sep 10 '24 18:09 devdattakulkarni

We should mark such a PVC with the following:

helm.sh/resource-policy: "keep"

devdattakulkarni avatar Sep 10 '24 18:09 devdattakulkarni

Let's mount the PVC on the path: /kubeplus

Following changes will be required after this:

  • In kubectl-upload-chart, we will need to specify "/kubeplus" as the target path when copying the local chart
  • In helmer, whereever we refer to chart location as ("./"), we will have to change it to ("./kubeplus/") (e.g.: https://github.com/cloud-ark/kubeplus/blob/master/platform-operator/helm-pod/main.go#L945) (lines: 945, 951, 962, 1099)
  • In ./deploy/kubeconfiggenerator.py, check all the places where "chartName" is referenced. All such places will most likely be pointing to ("./<chartName>"). These will need to be changed to ("./kubeplus/<chartName>"). For example:
  • in method download_and_untar_chart (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L543)
  • in method get_chart_yaml (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L578)
  • in method check_and_install_crds (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L598)
  • in method delete_chart_crds (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L610)
  • in method check_chart (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L798)

devdattakulkarni avatar Nov 27 '24 20:11 devdattakulkarni

@SuyogShinde942 ^^

devdattakulkarni avatar Nov 27 '24 20:11 devdattakulkarni

Carefully go through the code in kubeconfiggenerator.py and helmer/main.go to see if we are not missing any place where we will need to update the chart location.

devdattakulkarni avatar Nov 27 '24 20:11 devdattakulkarni

Thank you, I'll be working on this issue. Will let you know if any doubts.

SuyogShinde942 avatar Nov 28 '24 16:11 SuyogShinde942

For testing whether PV works as expected, here are the steps:

  1. Deploy KubePlus with a version (say, 4.0.0)
  2. Register HelloWorldService CRD. Use the localchart option. This will require uploading the hello-world chart to KubePlus
  3. Create an instance of HelloWorldService
  4. Use helm upgrade command to upgrade KubePlus release to version 4.0.1
  5. Once new KubePlus Pod is RUNNING, exec into the helmer container and check "/chart" folders. Inside "/chart", there should be expanded hello-world chart
  6. Create another instance of HelloWorldService

If steps 5 and 6 are successful then it will mean that PV and PVC worked as expected. This is because, even though KubePlus Pod is newely created, its file system is not affected.

devdattakulkarni avatar Dec 03 '24 16:12 devdattakulkarni

https://github.com/cloud-ark/kubeplus/pull/1378

I have created a PR for the above request, Please let me know if any changes are needed

SuyogShinde942 avatar Dec 04 '24 00:12 SuyogShinde942