astefanutti / kubebox

⎈❏ Terminal and Web console for Kubernetes
http://astefanutti.github.io/kubebox
MIT License
2.14k stars 142 forks source link

would like to configure the namespace cadvisor is found in #88

Open brennantaylor opened 4 years ago

brennantaylor commented 4 years ago

Right now it is hardcoded to cadvisor. It would be nice to be able to configure this.

Not sure how you like configuration to be extracted. If you provide some guidance I can open a PR.

astefanutti commented 4 years ago

Thanks a lot for the suggestion. That makes totally sense.

I see a couple of options:

Ideally, it should work also for the Web version. CLI can be emulated with arguments passed in the URL. A dot file could be emulated with a config map. Maybe even for the non-Web version, a config map could old the configuration and be looked up, but that's probably better to stick to the dot file convention.

WDYT?

brennantaylor commented 4 years ago

Yeah I've also struggled defining an isomorphic config that feels right in both the cli and web.

It's pretty standard to inject env vars or mount entire files into a container with configmaps. Env vars also let you use env or envFrom in podSpecs to define it. Changing the cli args is trivial too.

Env vars could be made to work ok in the browser with query params like you mentioned:

# using dotenv somewhere in index.js: require('dotenv').config()
echo "CADVISOR_NAMESPACE=default" > .env
npm index.js
# just on the command line
env "CADVISOR_NAMESPACE=default" npm index.js
# in the browser parse the query params as env vars?
http://kubebox.mydomain.com/?CADVISOR_NAMESPACE=default
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubebox
spec:
  selector:
    matchLabels:
      name: kubebox
  template:
    metadata:
      name: kubebox
    spec:
      serviceAccountName: kubebox
      containers:
      - image: astefanutti/kubebox:server
        name: kubebox
        env:
        - name: CADVISOR_NAMESPACE # EZ in k8s too
           value: default
        ports:
        - containerPort: 8080
          protocol: TCP
astefanutti commented 4 years ago

That looks great! I think your proposal would make a very good start!

593769290 commented 4 years ago

how about CADVISOR_NAMESPACE just use kubebox namespace ? not to maintain so many namespace.

astefanutti commented 4 years ago

@593769290 I've seen people used to create a namespace per application, other having inter-dependent applications into a single namespace. I'd be inclined to think cAdvisor is a rather cross-cutting kind of application, so it may be ok that it's installed in its own namespace.

Anyway I like the idea of leaving that decision to the user, and exposing CADVISOR_NAMESPACE so that it's configurable.