sbstp / kubie

A more powerful alternative to kubectx and kubens
https://blog.sbstp.ca/introducing-kubie/
zlib License
1.93k stars 100 forks source link

Feature request: config files with contexts only #124

Open reinoud opened 1 year ago

reinoud commented 1 year ago

Hi,

we use a cluster with a lot of namespace, and I would like to use a separate context for each.

I have a config file downloaded from Rancher, that defines the cluster, user and a single context. This file obviously contains my private token

I would like to use a separate config with only additional contexts defined. We would like to maintain this file centrally, so all Kubernetes admins can git pull this file to have all context definitions updated.

When I try this now, kubie complains:

contexts.yml: missing fieldclustersat line 4 column 9

since it is not a complete config file.

The contexts.yml file looks like this:

---
# list of all cluster-namespace combinations for cluster production

contexts:
- name: "production-namespace1"
  context:
    user: "myuser"
    cluster: "production"
    namespace: "namespace1"

- name: "production-namespace2"
  context:
    user: "myuser"
    cluster: "production"
    namespace: "namespace2"

- name: "production-namespace3"
  context:
    user: "myuser"
    cluster: "production"
    namespace: "namespace3"

The use-case here is that we do not have rights on the cluster to get all namespaces, so selecting a context with a set namespace makes our life much easier.

jedvardsson commented 1 month ago

I stumbled upon this and have a similar problem. Some clusters that I access doesn't allow listing namespaces. One thing that you can do is to merge your config with the pulled config using e.q. yq as part of the pulling. Or commit your config to the git managed config but not push it. It will get automatically merged when you pull.

One other way would be if Kubie could support getting namespaces from file (or script available on the path) rather than using kubectl get namespaces.