podman-desktop / podman-desktop

Podman Desktop is the best free and open source tool to work with Containers and Kubernetes for developers. Get an intuitive and user-friendly interface to effortlessly build, manage, and deploy containers and Kubernetes — all from your desktop.
https://podman-desktop.io
Apache License 2.0
4.9k stars 310 forks source link

feat: configured preferred namespace(s) for Kubernetes contexts #4990

Open axel7083 opened 11 months ago

axel7083 commented 11 months ago

Is your feature request related to a problem? Please describe

When using external cluster, we might want to use a specific namespace by default or we might not have access to the default namespace.

Describe the solution you'd like

In the Kubernetes settings, being able to set the preferred namespace.

This settings could be reflected when generating kube.

Describe alternatives you've considered

No response

Additional context

I do not know if podman-desktop have some kind of internal persistency system ?

afbjorklund commented 11 months ago

I think each context has a namespace

Usage:
  kubectl config set-context [NAME | --current] [--cluster=cluster_nickname] [--user=user_nickname]
[--namespace=namespace] [options]

You can view the current value in CLI:

$ kubectl config get-contexts
CURRENT   NAME        CLUSTER     AUTHINFO    NAMESPACE
*         kind-kind   kind-kind   kind-kind   
axel7083 commented 11 months ago

I think each context has a namespace

Usage:
  kubectl config set-context [NAME | --current] [--cluster=cluster_nickname] [--user=user_nickname]
[--namespace=namespace] [options]

You can view the current value in CLI:

$ kubectl config get-contexts
CURRENT   NAME        CLUSTER     AUTHINFO    NAMESPACE
*         kind-kind   kind-kind   kind-kind   

I don't know how the context would be used specifically in the use case I am seeing. I was thinking for instance, when I am downloading a kubeconfig from rancher for example, it looks like this

apiVersion: v1
kind: Config
clusters:
- name: "<name>"
  cluster:
    server: <server>
    certificate-authority-data: <cert>
users:
- name: "<name>"
  user:
    token:  <token>

contexts:
- name: "<name>"
  context:
    user: "<name>"
    cluster: "<name>"

current-context: "<name>"

There is no preferred namespace configured, but I do only have access to one namespace, thus, leading to error when importing the config in some Kubernetes dashboards. Some of those dashboard offer a way to configured the "Accessible namespaces"

afbjorklund commented 11 months ago

You should be able to add one with kubectl config set-context <name> --namespace=<name>

contexts:
- context:
    cluster: kind-kind
    namespace: kind-kind
    user: kind-kind
  name: kind-kind

The default is empty (and omitted)

https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#working-with-namespaces

afbjorklund commented 11 months ago

It's still a nice feature to show it it in the UI, and include it in the editable fields when available.

kube-config-kind-kind

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had activity in the last 6 months. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

axel7083 commented 5 months ago

Keep open