62

I would like to install kubectl version 1.2.4 on a machine. The Kubernetes documentation recommends using snap for installation on Ubuntu.

snap install --help is not very useful, the one promising parameter --revision= doesn't work:

$ sudo snap install --revision=1.2.4 kubectl
error: cannot decode request body into snap instruction: invalid snap revision: "\"1.2.4\""

I suspect that --revision expects a SHA rather than a semver.

The apt-get convention of using package=1.2.3 also doesn't work:

$ sudo snap install kubectl=1.2.4
error: snap "kubectl=1.2.4" not found

The usage documentation seems silent on the question.

Anybody know?

RichVel
  • 189
  • 2
  • 11
Cory Klein
  • 18,391
  • 26
  • 81
  • 93

2 Answers2

74
  1. you can run snap info kubectl which gives you a list of kubectl versions.
  2. Then you can install your preferred version with --channel like this sudo snap install kubectl --channel=1.6/stable --classic or if you want to upgrade / downgrade to specific version: sudo snap refresh kubectl --channel=1.6/stable --classic

It seems that version 1.2.4 Is not available in snap, in that case you can download the executable https://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl

Kayvan
  • 103
  • 3
Tow
  • 841
  • 6
  • 4
  • 6
    why do we need `--classic`? – lucidbrot May 03 '20 at 10:06
  • Same question as @lucidbrot - I often see the `--classic` flag but with no explanation as why that option would be used. – Guy Jun 10 '20 at 17:17
  • 2
    `--classic` means the snap is not built with specific permissions (i.e. strict mode), so adding `--classic` means it will run like a traditional binary with most permissions. – Sarke Jun 27 '20 at 04:16
  • How do we prevent the snap from being updated after installing a specific version? – fIwJlxSzApHEZIl Jul 29 '20 at 16:35
  • 1
    Preventing snap package upgrades: not impossible, but not elegant either (and for my team, this is a major shortcoming of `snap`): https://askubuntu.com/questions/1131182/how-can-i-disable-automatic-update-for-a-single-snap-in-ubuntu – Johnny Utahh Aug 19 '20 at 18:26
  • I was able to install Ruby 3.0 dev version by `snap refresh ruby --channel=latest/edge` without the `sudo` but it asked for the password in a dialog window – nonopolarity Dec 19 '20 at 18:47
1
  1. Run this
    snap refresh --edge sublime-text
    
    to update sublime text to the version you want or
    snap install --edge sublime-text
    
    to install sublime text.
  2. The --edge represent the channel
AdminBee
  • 21,637
  • 21
  • 47
  • 71