Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load configuration from files instead of ConfigMaps #7575

Open
AndersBennedsgaard opened this issue May 6, 2024 · 0 comments
Open

Load configuration from files instead of ConfigMaps #7575

AndersBennedsgaard opened this issue May 6, 2024 · 0 comments

Comments

@AndersBennedsgaard
Copy link

/kind feature

Why you need this feature:

The actual centraldashboard-config ConfigMap is read every time a user interacts with the central dashboard. This puts unnecessary load on the Kubernetes API server, and increases latency for the dashboard.

Describe the solution you'd like:

I propose that the configuration is read from files mounted with the ConfigMap instead, using simple Pod volumes and volume mounts. The resulting Deployment would look something like:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: centraldashboard
  name: centraldashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: centraldashboard
  template:
    metadata:
      labels:
        app: centraldashboard
      annotations:
        sidecar.istio.io/inject: "true"
    spec:
      containers:
        - name: centraldashboard
          image: docker.io/kubeflownotebookswg/centraldashboard
          imagePullPolicy: IfNotPresent
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8082
            initialDelaySeconds: 30
            periodSeconds: 30
          ports:
            - containerPort: 8082
              protocol: TCP
          env:
            - name: USERID_HEADER
              value: CD_USERID_HEADER_PLACEHOLDER
            - name: USERID_PREFIX
              value: CD_USERID_PREFIX_PLACEHOLDER
            - name: PROFILES_KFAM_SERVICE_HOST
              value: profiles-kfam.kubeflow
            - name: REGISTRATION_FLOW
              value: CD_REGISTRATION_FLOW_PLACEHOLDER
            - name: LOGOUT_URL
              value: "/authservice/logout"
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: centraldashboard-config
              mountPath: /etc/centraldashboard # can be changed
      volumes:
        - name: centraldashboard-config
          configMap:
            name: centraldashboard-config
      serviceAccountName: centraldashboard

(adapted from https://github.com/kubeflow/kubeflow/blob/master/components/centraldashboard/manifests/base/deployment.yaml)

Instead of calling the KubeAPI server on every GET, the dashboard would just have to parse files mounted somewhere in the container.
It would also be possible to get dynamic updates to the dashboard, since files mounted in this way are dynamically updated in the container, so we don't need to restart the deployment on config change.

Related lines of code:

.get(
'/dashboard-links',
async (_: Request, res: Response) => {
const cm = await this.k8sService.getConfigMap();
let links = {};
try {
links=JSON.parse(cm.data["links"]);
}catch(e){
return apiError({
res, code: 500,
error: ERRORS.invalid_links_config,
});
}
res.json(links);
})
.get(
'/dashboard-settings',
async (_: Request, res: Response) => {
const cm = await this.k8sService.getConfigMap();
let settings = {};
try {
settings=JSON.parse(cm.data["settings"]);
}catch(e){
return apiError({
res, code: 500,
error: ERRORS.invalid_settings,
});
}
res.json(settings);
});

.get(
'/dashboard-links',
async (_: Request, res: Response) => {
const cm = await this.k8sService.getConfigMap();
let links = {};
try {
links=JSON.parse(cm.data["links"]);
}catch(e){
return apiError({
res, code: 500,
error: ERRORS.invalid_links_config,
});
}
res.json(links);
})
.get(
'/dashboard-settings',
async (_: Request, res: Response) => {
const cm = await this.k8sService.getConfigMap();
let settings = {};
try {
settings=JSON.parse(cm.data["settings"]);
}catch(e){
return apiError({
res, code: 500,
error: ERRORS.invalid_settings,
});
}
res.json(settings);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant