eclipse-che / che

Kubernetes based Cloud Development Environments for Enterprise Teams
http://eclipse.org/che
Eclipse Public License 2.0
6.99k stars 1.19k forks source link

Kubeconfig Format Corruption After Switching Clusters and Restarting Workspace #23238

Open eye0fra opened 2 weeks ago

eye0fra commented 2 weeks ago

Describe the bug

Hello, I've encountered an issue with Kubernetes context renewal/injection. Initially, the kubeconfig is in JSON format. However, when I use the oc command line to log into a different cluster for testing, the format switches to YAML. Upon restarting the workspace, the injection process disrupts the YAML file, causing it to become a single inline entry. Consequently, the kubeconfig becomes unusable, affecting all related dependencies, such as kubedock. The current workaround is to delete the kubeconfig and restart the workspace to restore the correct kubeconfig format.

Che version

7.94@latest

Steps to reproduce

  1. Initial Setup:

    • Ensure you have a kubeconfing in JSON format at the start of the workspaces
    • Verify that your workspace is configured to use this kubeconfig. (kubedock is working)
  2. Switch Cluster:

    • Use the oc command line tool to log into a different OpenShift cluster:
      oc login <cluster-url> --token=<your-token>
    • Note that the kubeconfig format changes to YAML.
    • I believe is not necessary to use a different cluster, but run oc login command to override the config.
  3. Restart Workspace:

    • Restart your development workspace.
  4. Observe the Issue:

    • Check the kubeconfig file. It should now be a single inline YAML entry.
    • Attempt to use Kubernetes-related commands or dependencies like kubedock and observe failures due to the malformed kubeconfig.
  5. Workaround:

    • Delete the kubeconfig.
    • Restart the workspace to restore the correct kubeconfig format.

Expected behavior

The kubeconfig should maintain its format and functionality after switching context.

Runtime

OpenShift

Screenshots

Screenshot 2024-11-07 at 11 36 35 Screenshot 2024-11-07 at 10 21 35 Screenshot 2024-11-06 at 17 01 43 Screenshot 2024-11-06 at 16 59 55

Installation method

OperatorHub

Environment

other (please specify in additional context)

Eclipse Che Logs

No response

Additional context

OpenShift DevSpaces 3.16.1

vinokurig commented 1 week ago

Hello @eye0fra, could you please elaborate more on:

eye0fra commented 3 days ago
  1. The workspace can be empty and is not dependent on the devfile definition.
  2. If the kubedock process is running without errors, it indicates that the kube config file is intact and not corrupted.
  3. What do you mean "my local machine," all the tests are on the workspace terminal. If you can execute the command afterwards, is the YAML formatted correctly? Based on the attached picture, I have doubts about its functionality.