magda-io / magda

A federated, open-source data catalog for all your big data and small data
https://magda.io
Apache License 2.0
510 stars 93 forks source link

Spike: Make configuration able to be changed without a helm deploy #2907

Open AlexGilleran opened 4 years ago

AlexGilleran commented 4 years ago

Description

Right now, most configuration that will be changeable in the new control panel is specified via values passed to helm. This means that when you want to change these values, you change the Helm values.yaml file and helm upgrade to make the changes to the installation.

However, the control panel wants to expose this to a user via a web UI with controls like this:

image

Obviously this is quite a ways from a command line. We need to figure out how to let a user make these changes from the UI and have them propagated across the whole system.

Things to address

Acceptance Criteria

sajidanower23 commented 4 years ago

The official Kubernetes client for Javascript/Typescript has plenty of utility functions to interface with the Kubernetes Cluster.

Let's look at the scenario where we need to turn a deployment off and then on.

To delete a deployment, do this:

const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const k8sBatchApi = kc.makeApiClient(k8s.BatchV1Api);
const k8sCoreApi = kc.makeApiClient(k8s.CoreV1Api);
const k8sAppsApi = kc.makeApiClient(k8s.AppsV1Api);

const NAMESPACE = 'default';

k8sCoreApi.listNamespacedPod(NAMESPACE).then((res) => {
    console.log("Pods: ");
    const pods = res.body.items;
    pods.forEach((pod, index) => {
        console.log(index + ': ' + pod.metadata.name);
    })
    k8sAppsApi.deleteNamespacedDeployment('storage-api', NAMESPACE).then((res) => {
        console.log('Deleted pod');
        console.log(res.body);
    })
    return res.body;
});

To create the deployment again, you can use the function createNamespacedDeployment, defined here.

You would need to create a V1Deployment object. The model is defined here.

I could not find any helm API that could change Kubernetes deployments. Here is an article that I looked at though.

AlexGilleran commented 4 years ago

Result of refinement discussion: Helm Operators still warrant further investigation (https://docs.fluxcd.io/projects/helm-operator/en/stable/helmrelease-guide/chart-sources/), because that might get us a solution that gets us everything we want. Next step is to dive deeper into helm operators and see if they'll do what we need and how complex that will make deployments.

t83714 commented 4 years ago

Helm operator looks quite promising even without helm's three-way merge.

Our chart based fit this solution well if we make sure the following:

In this way, we can have two layers of configuration:

The later actually works like helm's values file and can overwrite the former.

We still can upgrade to the newer version without losing a runtime setting.

AlexGilleran commented 4 years ago

Just saw this, might help: https://github.com/opskumu/helm-wrapper

t83714 commented 4 years ago

@AlexGilleran That's really cool~ it probaly allow us to have a mini version tiller running with HTTP API easily. I also think about picking up some GO lately 😄