Unable to install some kubectl plugins via Krew
ishantanu opened this issue · 2 comments
Hi,
I am facing some issues while installing deprecations
plugin via Krew. Here is the error:
❯ kubectl krew install deprecations
Updated the local copy of plugin index.
F0225 10:46:46.055669 76831 root.go:52] failed to load plugin "deprecations" from the index: platform ({Head: URI:https://github.com/rikatz/kubepug/releases/download/v0.2.5/kubepug_darwin_amd64.tar.gz Sha256:3397ac60d41d9469d36939a6de95703e1cc407df9f28ce0ca2a62c7aad61c338 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubepug}) is badly constructed: can't have a plugin without specifying file operations
I am not sure if this is the right place to open this issue but as per the error description, it looks like something's missing in https://github.com/kubernetes-sigs/krew-index/blob/master/plugins/deprecations.yaml.
I tried installing other plugins (for example, whoami
) and there was no error in validation of krew config. From the initial inspection, the error might be coming from krew/internal/index/validation/validate.go
:
for _, pl := range p.Spec.Platforms {
if err := validatePlatform(pl); err != nil {
return errors.Wrapf(err, "platform (%+v) is badly constructed", pl)
}
}
So, I think, the krew config for this plugin needs to be updated in this repository to pass this validation.
UPDATE:
This issue pertains with not just one plugin (as seen above), but with many other plugins:
❯ kubectl krew search
E0225 11:38:03.426536 87968 scanner.go:57] failed to load file "advise-psp", err: platform ({Head: URI:https://github.com/sysdiglabs/kube-psp-advisor/releases/download/v1.7.0/kube-psp-advisor_v1.7.0_darwin_amd64.tar.gz Sha256:1e63927a6d78f4aa1d6e2840c9734a322dbc1262c0290a081ae4a639df65e01f Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-advise-psp}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.429841 87968 scanner.go:57] failed to load file "capture", err: platform ({Head: URI:https://github.com/sysdiglabs/kubectl-capture/releases/download/v0.1.0/kubectl-capture.v0.1.0.tar.gz Sha256:86c947a9fa9acb73eeb179e29ede20755a426a4fb96aa82375246a356f3a804f Selector:&LabelSelector{MatchLabels:map[string]string{},MatchExpressions:[{os In [darwin linux]}],} Files:[] Bin:kubectl-capture}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.432868 87968 scanner.go:57] failed to load file "debug", err: platform ({Head: URI:https://github.com/verb/kubectl-debug/releases/download/v0.1.2/kubectl-debug_darwin_amd64.tar.gz Sha256:e8c6ce28b0eaec9aff17dc3b4c569ef3e731cad00673423d82524bd4d5c829ab Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:./kubectl-debug}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.433386 87968 scanner.go:57] failed to load file "deprecations", err: platform ({Head: URI:https://github.com/rikatz/kubepug/releases/download/v0.2.5/kubepug_darwin_amd64.tar.gz Sha256:3397ac60d41d9469d36939a6de95703e1cc407df9f28ce0ca2a62c7aad61c338 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubepug}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.434543 87968 scanner.go:57] failed to load file "duck", err: platform ({Head: URI:https://github.com/n3wscott/kubectl-duck/releases/download/v0.0.1/kubectl-duck_v0.0.1_darwin_amd64.tar.gz Sha256:86294517e15b77297eeeafcb515ed7dd5f1c0ea13f6bfa4e1ecdc9d8096ab009 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-duck}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.435222 87968 scanner.go:57] failed to load file "evict-pod", err: platform ({Head: URI:https://github.com/rajatjindal/kubectl-evict-pod/releases/download/v0.0.7/kubectl-evict-pod_v0.0.7_darwin_amd64.tar.gz Sha256:d0cf3253d89f6b394e002b364a70b653c8855c844ccef6815590fe77fdaa737f Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-evict-pod}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.438282 87968 scanner.go:57] failed to load file "iexec", err: platform ({Head: URI:https://github.com/gabeduke/kubectl-iexec/releases/download/1.4.0/kubectl-iexec_1.4.0_Darwin_x86_64.tar.gz Sha256:f61186638d7b9fb413dbe415a7c7e541dc719089bdb7ae49581a5a1793821398 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-iexec}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.438662 87968 scanner.go:57] failed to load file "images", err: platform ({Head: URI:https://github.com/chenjiandongx/kubectl-images/releases/download/v0.1.0/kubectl-images_darwin_amd64.tar.gz Sha256:885bfd428a8cb09189f7c3da1b9bff2a0f8dc13a47707ec98b4071ce6f7a92d1 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-images}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.442039 87968 scanner.go:57] failed to load file "net-forward", err: platform ({Head: URI:https://github.com/antitree/krew-net-forward/releases/download/v1.0.3/net-forward_v1.0.3.tar.gz Sha256:645adb05d9ad68ecc91d9034cb80b1e2fe4762864323c12de0f2bc5afe20baa0 Selector:&LabelSelector{MatchLabels:map[string]string{os: linux,},MatchExpressions:[],} Files:[] Bin:net-forward}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.445800 87968 scanner.go:57] failed to load file "passman", err: failed to read the plugin manifest: json: cannot unmarshal number into Go struct field LabelSelector.matchLabels of type string
E0225 11:38:03.450191 87968 scanner.go:57] failed to load file "resource-snapshot", err: failed to read the plugin manifest: json: cannot unmarshal number into Go struct field LabelSelector.matchLabels of type string
E0225 11:38:03.453025 87968 scanner.go:57] failed to load file "ssm-secret", err: platform ({Head: URI:https://github.com/pr8kerl/kubectl-ssm-secret/releases/download/v1.2.2/kubectl-ssm-secret_1.2.2_darwin_x86_64.tar.gz Sha256:9b381c9d456a4036c72520a94905605c278f869071b3924517d026d0f281cc6c Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:kubectl-ssm_secret}) is badly constructed: can't have a plugin without specifying file operations
E0225 11:38:03.455299 87968 scanner.go:57] failed to load file "view-allocations", err: platform ({Head: URI:https://github.com/davidB/kubectl-view-allocations/releases/download/0.7.0/kubectl-view-allocations_0.7.0-x86_64-apple-darwin.tar.gz Sha256:df637899f41b4fbe2adfd7330057b729538759f69a9753da2db5cc5a9fbcfd79 Selector:&LabelSelector{MatchLabels:map[string]string{arch: amd64,os: darwin,},MatchExpressions:[],} Files:[] Bin:./kubectl-view-allocations}) is badly constructed: can't have a plugin without specifying file operations
NVM, figured out. Had to upgrade krew because it was having incorrect index URI:
IndexURI https://github.com/GoogleContainerTools/krew-index.git
Upgraded krew and the IndexURI
was changed to https://github.com/kubernetes-sigs/krew-index.git
. I know https://github.com/GoogleContainerTools/krew-index.git gets redirected to https://github.com/kubernetes-sigs/krew-index.git but maybe krew was getting old cached version of some plugins with old version.
The issue was resolved by upgrading krew.
Hey @ishantanu, we made a field optional in the plugin manifest which was required in old manifests. That's what caused the error.
In general, it's a good idea to run krew upgrade
from time to time. Otherwise you will miss out on the latest and greatest features of your plugins -- not just krew
;)