2to3 does not respect kubecontext flag
digeler opened this issue · 14 comments
plugin version : 2to3 0.6.0 migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
helm version : version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
os:windows
issue :
running kubectl get-contexts i see the following context :
PolyDgeUseGcKs PolyDgeUseGcKs clusterAdmin_PolyDgeUseGc_PolyDgeUseGcKs
trying to use helm convert i get the following error :
helm3 2to3 convert geneva --kube-context PolyDgeUseGcKs
2020/07/29 09:59:23 Release "geneva" will be converted from Helm v2 to Helm v3.
2020/07/29 09:59:23 [Helm 3] Release "geneva" will be created.
2020/07/29 09:59:23 context "PolyDgeUseGcKs" does not exist
Error: plugin "2to3" exited with error
any idea why is the plugin says that : PolyDgeUseGcKs not exist ?
@digeler I tested it using 2 different kind clusters as follows:
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* kind-kind-17 kind-kind-17 kind-kind-17
kind-kind-18 kind-kind-18 kind-kind-18
$ kubectl config current-context
kind-kind-17
$ helm2 ls
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
mychart-v2-k8s17 1 Thu Jul 30 09:38:45 2020 DEPLOYED mychart-0.1.0 1.0 default
$ helm2 ls --kube-context kind-kind-18
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
mychart-v2 1 Thu Jul 30 09:20:49 2020 DEPLOYED mychart-0.1.0 1.0 default
$ helm3 2to3 convert mychart-v2 --dry-run
2020/07/30 09:50:16 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/07/30 09:50:16 Run without --dry-run to take the actions described below:
2020/07/30 09:50:16
2020/07/30 09:50:16 Release "mychart-v2" will be converted from Helm v2 to Helm v3.
2020/07/30 09:50:16 [Helm 3] Release "mychart-v2" will be created.
Error: mychart-v2 has no deployed releases
Error: plugin "2to3" exited with error
$ helm3 2to3 convert mychart-v2 --dry-run --kube-context kind-kind-18
2020/07/30 09:50:27 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/07/30 09:50:27 Run without --dry-run to take the actions described below:
2020/07/30 09:50:27
2020/07/30 09:50:27 Release "mychart-v2" will be converted from Helm v2 to Helm v3.
2020/07/30 09:50:27 [Helm 3] Release "mychart-v2" will be created.
2020/07/30 09:50:27 [Helm 3] ReleaseVersion "mychart-v2.v1" will be created.
It is working as expected. Can you troubleshoot it further and see if you can identify the issue? I wonder, would you have different kube config files and are you access the correct one?
it could be a windows issue ,we are using this from powershell
geneva 1 Wed Jul 29 11:58:48 2020 DEPLOYED geneva-0.1.0 default
image-cleaner 1 Sat Aug 1 16:25:59 2020 DEPLOYED image-cleaner-0.1.0 monitor
prom-mdm-converter 1 Sat Aug 1 11:30:05 2020 DEPLOYED prom-mdm-converter-0.1.5 monitor
prometheus 1 Wed Jul 29 11:59:22 2020 DEPLOYED prometheus-10.4.0 2.15.2 monitor
PS C:\repos\cleanerv1\Aorato-Poly\artifacts\bin\Debug\Tools [Eng-PolyDgeUseGcKs]> helm3 2to3 convert image-cleaner --kube-context PolyDgeUseGcKs --dry-run
2020/08/01 16:59:20 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/08/01 16:59:20 Run without --dry-run to take the actions described below:
2020/08/01 16:59:20
2020/08/01 16:59:20 Release "image-cleaner" will be converted from Helm v2 to Helm v3.
2020/08/01 16:59:20 [Helm 3] Release "image-cleaner" will be created.
2020/08/01 16:59:20 context "PolyDgeUseGcKs" does not exist
Error: plugin "2to3" exited with error
same from command prompt :
c:\temp>helm3 2to3 convert image-cleaner --kube-context PolyDgeUseGcKs --dry-run
2020/08/01 17:01:16 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/08/01 17:01:16 Run without --dry-run to take the actions described below:
2020/08/01 17:01:16
2020/08/01 17:01:16 Release "image-cleaner" will be converted from Helm v2 to Helm v3.
2020/08/01 17:01:16 [Helm 3] Release "image-cleaner" will be created.
2020/08/01 17:01:16 context "PolyDgeUseGcKs" does not exist
Error: plugin "2to3" exited with error
on linux machine it is working as expected :
root@MININT-5ESIQ4L:/c/temp/helm/linux-amd64# ./helm 2to3 convert image-cleaner --kube-context PolyDgeUseGcKs --dry-run
2020/08/01 17:12:34 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/08/01 17:12:34 Run without --dry-run to take the actions described below:
2020/08/01 17:12:34
2020/08/01 17:12:34 Release "image-cleaner" will be converted from Helm v2 to Helm v3.
2020/08/01 17:12:34 [Helm 3] Release "image-cleaner" will be created.
2020/08/01 17:12:39 [Helm 3] ReleaseVersion "image-cleaner.v1" will be created.
seems like windows is the issue :
helm 2to3 convert image-cleaner --kube-context PolyDgeUseGcKs --dry-run
2020/08/01 19:04:25 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/08/01 19:04:25 Run without --dry-run to take the actions described below:
2020/08/01 19:04:25
2020/08/01 19:04:25 Release "image-cleaner" will be converted from Helm v2 to Helm v3.
2020/08/01 19:04:25 [Helm 3] Release "image-cleaner" will be created.
2020/08/01 19:04:25 invalid configuration: no configuration has been provided
Error: plugin "2to3" exited with error
can you try the same on windows machine ?
thanks
Flags like --kube-context
are read by the Helm CLI, then scrubbed from the argument list. They are not passed along to the plugin. Once the kubernetes client has been created, there is no need for the plugin to read those flags.
I'm curious how you got helm-2to3
installed natively on Windows, @digeler. The README does not provide instructions for users on Windows. You need to be running Helm via WSL2 to use helm 2to3
. Did you compile this yourself?
Otherwise, you are met with the following error.
PS C:\Users\me> helm version
version.BuildInfo{Version:"v3.3.1", GitCommit:"249e5215cde0c3fa72e27eb7a30e8d55c9696144", GitTreeState:"clean", GoVersion:"go1.14.7"}
PS C:\Users\me> helm plugin install https://github.com/helm/helm-2to3
Error: exec: "sh": executable file not found in %PATH%
Okay... I managed to get it working by manually installing the plugin.
Seems to work just fine on Windows. Tried using both WSL2 and with Powershell. Notice how the context cannot be found in the error output, which indicates that it was able to retrieve that information.
><> helm.exe 2to3 convert image-cleaner --kube-context PolyDgeUseGcKs --dry-run
2020/09/01 12:34:53 NOTE: This is in dry-run mode, the following actions will not be executed.
2020/09/01 12:34:53 Run without --dry-run to take the actions described below:
2020/09/01 12:34:53
2020/09/01 12:34:53 Release "image-cleaner" will be converted from Helm v2 to Helm v3.
2020/09/01 12:34:53 [Helm 3] Release "image-cleaner" will be created.
2020/09/01 12:34:53 context "PolyDgeUseGcKs" does not exist
Error: plugin "2to3" exited with error
I would check and confirm whether your kubernetes config file is correct. Your error message seems to indicate that the kubeconfig could not be loaded because it contains invalid configuration. #156 appears to point to a similar issue, though I'm not sure there was any solid evidence to suggest how to resolve that issue.
Flags like --kube-context are read by the Helm CLI, then scrubbed from the argument list. They are not passed along to the plugin. Once the kubernetes client has been created, there is no need for the plugin to read those flags.
The plugin is parsing the following flags from the Helm CLI: --kube-context
and --kubeconfig
Thanks @bacongobbler for testing this on a Windows system and providing the feedback.
The plugin is parsing the following flags from the Helm CLI:
--kube-context
and--kubeconfig
This is half right I believe.
When calling, for example:
helm 2to3 <CMD> --kube-context ...
then helm removes the global flags and passes them to the plugin through environment variables (HELM_ KUBECONTEXT in this case).
However, when calling the plugin binary directly like so:
./2to3 <CMD> --kube-context ...
then the plugin parses the flag itself.
I've corrected my previous comment which had many typos (sorry, it's my phone 😇)
Sorry. Yeah, that was Helm 2's old behaviour when useTiller: true
was present in plugin.yaml, but now it's passed down to the plugin. @marckhouzam and @hickeyma are correct here.
This is half right I believe.
@marckhouzam I decided to leave out all the deep implementation details and just said the flags work! 🤣
@digeler The plugin is installable on Windows as tested by @bacongobbler above and documented in https://github.com/helm/helm-2to3#for-windows-using-wsl. Do you have any further information to help reproduce the issue?
Closing this as no response since August. Can re-open if more details are provided.