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

Set the namespace in generated kubeconfig #22083

Closed
l0rd opened this issue Mar 21, 2023 · 6 comments
Closed

Set the namespace in generated kubeconfig #22083

l0rd opened this issue Mar 21, 2023 · 6 comments
Assignees
Labels
area/dashboard kind/enhancement A feature request - must adhere to the feature request template. new&noteworthy For new and/or noteworthy issues that deserve a blog post, new docs, or emphasis in release notes severity/P1 Has a major impact to usage or development of the system. sprint/next status/validated The issue resolution has been validated
Milestone

Comments

@l0rd
Copy link
Contributor

l0rd commented Mar 21, 2023

Is your enhancement related to a problem? Please describe

The Dashboards generates a ~/.kube/config at workspace startup. But the context in the generated kubeconfig is missing the namespace:

{
  "apiVersion": "v1",
  "kind": "Config",
   (...)
  "contexts": [
    {
      "name": "logged-user",
      "context": {
        "user": "developer",
        "cluster": "inCluster",
        "name": "logged-user"
      }
    }
  ],
  "preferences": {},
  "current-context": "logged-user"
}

This can have some side effects because clients rely on kubeconfig to find the current namespace:

$ oc project
No project has been set. Pass a project name to make that the default.

Note that workspace Pod namespace is available at /var/run/secret/kubernetes.io/serviceaccount/namespace.

Describe the solution you'd like

The namespace should be set in the context

@l0rd l0rd added kind/enhancement A feature request - must adhere to the feature request template. area/dashboard severity/P1 Has a major impact to usage or development of the system. labels Mar 21, 2023
@ibuziuk ibuziuk mentioned this issue Mar 22, 2023
50 tasks
@ibuziuk ibuziuk moved this to 📋 Backlog in Eclipse Che Team A Backlog Mar 31, 2023
@ibuziuk ibuziuk moved this from 📋 Backlog to 📅 Planned in Eclipse Che Team A Backlog Mar 31, 2023
@ibuziuk ibuziuk added this to the 7.65 milestone Apr 5, 2023
@tolusha tolusha self-assigned this Apr 7, 2023
@tolusha tolusha moved this from 📅 Planned to 🚧 In Progress in Eclipse Che Team A Backlog Apr 7, 2023
@ibuziuk ibuziuk moved this from 🚧 In Progress to ✅ Done in Eclipse Che Team A Backlog Apr 7, 2023
@tolusha tolusha modified the milestones: 7.65, 7.64 Apr 7, 2023
@ibuziuk
Copy link
Member

ibuziuk commented Apr 12, 2023

PR has been merged. Closing

@ibuziuk ibuziuk closed this as completed Apr 12, 2023
@dmytro-ndp
Copy link
Contributor

There was "namespace": "admin-devspaces" in ~/.kube/config of workspace started using Eclipse Che Next:

quarkus-api-example (main) $ cat ~/.kube/config
{
  "apiVersion": "v1",
  "kind": "Config",
  "clusters": [
    {
      "name": "inCluster",
      "cluster": {
        "server": "https://172.30.0.1:443",
        "certificate-authority": "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt",
        "insecure-skip-tls-verify": false
      }
    }
  ],
  "users": [
    {
      "name": "developer",
      "user": {
        "token": "sha256~jN9zZr"
      }
    }
  ],
  "contexts": [
    {
      "name": "logged-user",
      "context": {
        "user": "developer",
        "cluster": "inCluster",
        "name": "logged-user",
        "namespace": "admin-devspaces"
      }
    }
  ],
  "preferences": {},
  "current-context": "logged-user"
}
quarkus-api-example (main) $ oc project
Using project "admin-devspaces" from context named "logged-user" on server "https://172.30.0.1:443".

As a result, oc project command was using user namespace.
Screenshot from 2023-04-19 15-32-37

Issue looks fixed as expected.

@dmytro-ndp dmytro-ndp added the status/validated The issue resolution has been validated label Apr 19, 2023
@dmytro-ndp dmytro-ndp moved this from ✅ Done to Verified & Closed in Eclipse Che Team A Backlog Apr 19, 2023
@max-cx
Copy link

max-cx commented May 3, 2023

sync'd to Red Hat JIRA https://issues.redhat.com/browse/CRW-4344

@nickboldt nickboldt added the new&noteworthy For new and/or noteworthy issues that deserve a blog post, new docs, or emphasis in release notes label May 3, 2023
@nickboldt
Copy link
Contributor

Given this is for .kube and not openshift... is this a Che only N&N item? @l0rd

@devstudio-release
Copy link

@l0rd
Copy link
Contributor Author

l0rd commented May 3, 2023

Given this is for .kube and not openshift... is this a Che only N&N item? @l0rd

No this issue if for Dev Spaces too. kubeconfig is used by oc too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard kind/enhancement A feature request - must adhere to the feature request template. new&noteworthy For new and/or noteworthy issues that deserve a blog post, new docs, or emphasis in release notes severity/P1 Has a major impact to usage or development of the system. sprint/next status/validated The issue resolution has been validated
Projects
None yet
Development

No branches or pull requests

7 participants