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

Minikube Preferences value is not respected #215

Closed
odockal opened this issue Nov 8, 2024 · 15 comments
Closed

Minikube Preferences value is not respected #215

odockal opened this issue Nov 8, 2024 · 15 comments
Assignees
Labels
kind/bug 🐞 Something isn't working sprint/unplanned

Comments

@odockal
Copy link

odockal commented Nov 8, 2024

I was playing around with minikube, I have set Preferences minikube property (minikube binary path) to a non-existing binary and tried to create a cluster (expecting it would fail), but it did not. So I assume that the property was not respected.

Image

There is also no button to open file manager. Although I appreciate the possibility to type the path into an input. There is also no validation present which would be great.

@odockal odockal added the kind/bug 🐞 Something isn't working label Nov 8, 2024
@axel7083
Copy link
Contributor

Hummm, this might have been addressed by #224 (not included in 0.4.0)

@tony-sol
Copy link
Contributor

tony-sol commented Nov 19, 2024

So sad it's not working now :c

UPD:
i believe, something wrong with

import * as extensionApi from '@podman-desktop/api';
...
const minikubeConfiguration = extensionApi.configuration.getConfiguration('minikube');
const minikubeHome = minikubeConfiguration.get<string>('home');

cause #224 looks fine

@axel7083
Copy link
Contributor

axel7083 commented Nov 20, 2024

i believe, something wrong with

@tony-sol could you retry with the nightly version of the minikube extension ghcr.io/podman-desktop/podman-desktop-extension-minikube:nightly ? This latest version contain the fix #224

See https://podman-desktop.io/docs/extensions/install for installing custom extension

@tony-sol
Copy link
Contributor

@axel7083

nightly version of extension not working with v1.14.1 of podman desktop

Error: require() of ES Module /Users/tony/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/dist/extension.js from /Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs not supported. extension.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead either rename extension.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/tony/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Stack trace:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/tony/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/dist/extension.js from /Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs not supported.
extension.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename extension.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/tony/.local/share/containers/podman-desktop/plugins/ghcriopodmandesktoppodmandesktopextensionminikube/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at c._load (node:electron/js2c/node_init:2:16955)
    at _module._load (/Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs:151:38636)
    at Xde.doRequire (/Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs:151:65620)
    at Xde.loadRuntime (/Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs:151:66331)
    at Xde.loadExtension (/Applications/Podman Desktop.app/Contents/Resources/app.asar/packages/main/dist/index.cjs:151:55697)

@axel7083
Copy link
Contributor

Thanks @tony-sol you were right, we had a problem with the latest build of minikube, this has just been fixed by #238

Could you retry with ghcr.io/podman-desktop/podman-desktop-extension-minikube:253bb4ccf231547357c6ba432925eabf8fa2474b ?

@tony-sol
Copy link
Contributor

@axel7083 sure, it installed well, see no error, but the main issue is still there - it created ~/.minikube while calling minikube binary like without MINIKUBE_HOME

Also, my ${XDG_DATA_HOME:~/.local/share}/containers/podman-desktop/configuration/settings.json:

{
  "welcome.version": "initial",
  "telemetry.check": true,
  "telemetry.enabled": false,
  "kubernetes.Kubeconfig": "/Users/tony/.local/share/kube/config",
  "extensions.disabled": [],
  "kubectl.binary.installKubectlSystemWide": true,
  "lima.type": "docker",
  "compose.binary.installComposeSystemWide": true,
  "terminal.integrated.fontSize": 13,
  "editor.integrated.fontSize": 14,
  "lima.socket": "/Users/tony/.local/share/lima/default/sock/docker.sock",
  "extensions.ignoreRecommendations": true,
  "preferences.login.minimize": true,
  "docker.context": "limactl",
  "window.bounds": {
    "x": 366,
    "y": 137,
    "width": 1084,
    "height": 827
  },
  "podman.system.connections.remote": true,
  "releaseNotesBanner.show": "1.14.1",
  "dockerCompatibility.enabled": true,
  "tasks.StatusBar": true,
  "minikube.home": "/Users/tony/.local/share/minikube/",
  "layers-explorer.cacheSize": 100,
  "lima.name": "default",
  "tasks.Toast": true
}

@axel7083
Copy link
Contributor

@axel7083 sure, it installed well, see no error, but the main issue is still there - it created ~/.minikube while calling minikube binary like without MINIKUBE_HOME

@tony-sol I am not sure exactly to understand the problem 🤔 . From my understanding you would like to be able to use minikube executable from the terminal with MINIKUBE_HOME value set as the preference in podman desktop ? This is not a feature provided by podman desktop :/

Podman Desktop is using the value provided in the preference when starting a cluster deleting etc.

Image

In the background, Podman Desktop run the same command you would in the terminal, but provide the MINIKUBE_HOME if the user provided a value in the preference.

@tony-sol
Copy link
Contributor

tony-sol commented Nov 20, 2024

@axel7083 the problem is - minikube extension should respect "minikube.home" configuration, due to podman desktop cannot fetch $MINIKUBE_HOME env variable from user's shell
(because it may be set up in *rc, *env or *profile files (.zshrc, .bashrc, .zshenv, .profile, etc.) and accessible only after user login (or even on interactive session))

It was made here and the idea was to let user define it's own desired MINIKUBE_HOME value, which would be accessible for podman desktop regardless user's shell and mix it's value as MINIKUBE_HOME env to minikube binary calls.

Now, looks like it either not read from settings.json via extensionApi.configuration.getConfiguration() or not applied in binary calls via extensionApi.process.exec()

@axel7083
Copy link
Contributor

Now, looks like it either not read from settings.json via extensionApi.configuration.getConfiguration() or not applied in binary calls via extensionApi.process.exec()

@tony-sol could you provide a reproducer of the problem you are encountering ? I am doing the following steps, and I am able to use the custom home directory :/

  1. install minikube extension ghcr.io/podman-desktop/podman-desktop-extension-minikube:253bb4ccf231547357c6ba432925eabf8fa2474b

  2. assert version (0.5.0-next)
    Image

  3. change the minikube home directory preference
    Image

  4. assert custom directory empty

$: ls /home/axel7083/.local/share/minikube
<nothing>
  1. Create a minikube cluster from podman desktop

Image

  1. assert minikube container running

Image

  1. assert minikube cluster listed in Resource page

Image

  1. stop the cluster from the Resource page

Image

  1. assert cluster is stopped

  2. check status from CLI

$: export MINIKUBE_HOME=/home/axel7083/.local/share/minikube && export MINIKUBE_ROOTLESS=true && minikube status
minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stopped

@tony-sol
Copy link
Contributor

tony-sol commented Nov 20, 2024

@axel7083 here is a few steps to see the problem:

  • configure podman desktop minikube extension to use any directory except in home
  • completely quit from podman desktop (like, kill process)
  • remove or rename your ~/.minikube directory
  • launch podman desktop
  • see a new ~/.minikube directory

Also: extension doesn't see already existed - see, there are no play/stop buttons until i start minikube manually from cli

Image

Also: starting minikube via interface, not passing KUBECONFIG env (which is "kubernetes.Kubeconfig" in settings.json)

Image

you may see that this E1120 17:53:32.745267 45820 status.go:417] kubeconfig endpoint: get endpoint: "minikube" does not appear in /Users/antsolovyev/.local/share/kube/config is indicates that minikube start and minikube status were called with different KUBECONFIGs

@tony-sol
Copy link
Contributor

For me, the whole point of "minikube.home" and "kubernetes.Kubeconfig" in settings.json is to keep my home directory as clean as possible by letting me to configure minikube and kubectl environment, which is not accessible outside of shell (those MINIKUBE_HOME, KUBECONFIG, etc.)

And it's really important to keep consistency between every tool around minikube and kubectl; if one tool uses e.g. MINIKUBE_HOME while other don't - everything become messed up

@axel7083
Copy link
Contributor

Okey I figure it out, the problem is not the same as the one explained in this issue. I opened #242.

@tony-sol
Copy link
Contributor

@axel7083 sorry, another question - there also should be KUBECONFIG added into getMinikubeAdditionalEnvs with value from settings, like

export function getKubeConfig(): string | undefined {
  const kubernetesConfiguration = extensionApi.configuration.getConfiguration('kubernetes');
  const kubeConfig = minikubeConfiguration.get<string>('Kubeconfig');
  // Check env if configuration is not applied in UI
  if (!kubeConfig) {
    const env = process.env;
    return env.KUBECONFIG;
  } else {
    return kubeConfig;
  }
}

export function getMinikubeAdditionalEnvs(): Record<string, string> {
  const env: Record<string, string> = {
    PATH: getMinikubePath(),
  };
  const minikubeHome = getMinikubeHome();
  if (minikubeHome) {
    env['MINIKUBE_HOME'] = minikubeHome;
  }
  const kubeConfig = getKubeConfig();
  if (kubeConfig) {
    env['KUBECONFIG'] = kubeConfig;
  }
  return env;
}

To prevent problem with E1120 17:53:32.745267 45820 status.go:417] kubeconfig endpoint: get endpoint: "minikube" does not appear in $KUBECONFIG

@axel7083
Copy link
Contributor

@tony-sol it makes sense 👍 , since you find the potential solution, you should open a PR !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug 🐞 Something isn't working sprint/unplanned
Projects
None yet
Development

No branches or pull requests

3 participants