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

[BOP-643] Installation script #19

Merged
merged 9 commits into from
May 31, 2024

Conversation

sakshisharma84
Copy link
Collaborator

Description

This PR introduces an installation script that will install the following dependencies. The docs have also been updated on how to use the script.

  • mkectl
  • k0sctl
  • kubectl

The script detects the underlying OS and ARCH and installs the correct binaries on the system.

Reviewers P.S. : Currently, this script installs the default versions until specified explicitly.

  • mkectl (default version: v4.0.0-alpha.0.3)
  • k0sctl (default version: 0.17.8)
  • kubectl (default version: v1.30.0)

When the docs go public, we can add a file that updates the latest version for mkectl.. something like k0s do. https://docs.k0sproject.io/stable.txt

Manual testing

Centos 7.9

[docker@ssharma-centos7-centos-0 ~]$ sudo ./install.sh
Download wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: download.cf.centos.org
 * extras: download.cf.centos.org
 * updates: download.cf.centos.org
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================
 Package              Arch                   Version                           Repository            Size
==========================================================================================================
Installing:
 wget                 x86_64                 1.14-18.el7_6.1                   base                 547 k

Transaction Summary
==========================================================================================================
Install  1 Package

Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm                                                    | 547 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                                            1/1
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                                            1/1

Installed:
  wget.x86_64 0:1.14-18.el7_6.1

Complete!


Step 1/3 : Install k0sctl
#########################
Using default k0sctl version 0.17.8
Downloading k0sctl from URL: https://github.com/k0sproject/k0sctl/releases/download/v0.17.8/k0sctl-linux-x64
k0sctl is now executable in /usr/local/bin


Step 2/3 : Install kubectl
#########################
Using default kubectl version v1.30.0
Downloading kubectl from URL: https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl
kubectl is now executable in /usr/local/bin


Step 3/3 : Install mkectl
#########################
Using default mkectl version v4.0.0-alpha.0.3

Downloading mkectl
mkectl
mkectl is now executable in /usr/local/bin
[docker@ssharma-centos7-centos-0 ~]$
[docker@ssharma-centos7-centos-0 ~]$ mkectl version
Version: v4.0.0-alpha.0.3
[docker@ssharma-centos7-centos-0 ~]$ kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[docker@ssharma-centos7-centos-0 ~]$ k0sctl version
version: v0.17.8
commit: b061291
[docker@ssharma-centos7-centos-0 ~]$

UBUNTU 18

docker@ssharma-ubuntu-18-ubuntu-0:~$ sudo ./install.sh
Download wget
wget is already installed.


Step 1/3 : Install k0sctl
#########################
Using default k0sctl version 0.17.8
Downloading k0sctl from URL: https://github.com/k0sproject/k0sctl/releases/download/v0.17.8/k0sctl-linux-x64
k0sctl is now executable in /usr/local/bin


Step 2/3 : Install kubectl
#########################
Using default kubectl version v1.30.0
Downloading kubectl from URL: https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl
kubectl is now executable in /usr/local/bin


Step 3/3 : Install mkectl
#########################
Using default mkectl version v4.0.0-alpha.0.3

Downloading mkectl
mkectl
mkectl is now executable in /usr/local/bin
docker@ssharma-ubuntu-18-ubuntu-0:~$ mkectl version
Version: v4.0.0-alpha.0.3
docker@ssharma-ubuntu-18-ubuntu-0:~$ kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
The connection to the server localhost:8080 was refused - did you specify the right host or port?
docker@ssharma-ubuntu-18-ubuntu-0:~$ k0sctl version
version: v0.17.8
commit: b061291
docker@ssharma-ubuntu-18-ubuntu-0:~$

MAC

ssharma@ssharma-MBP14-1973 install % sudo ./install.sh
Password:
Download wget
wget cmd is already installed.


Step 1/3 : Install k0sctl
#########################
Using default k0sctl version 0.17.8
Downloading k0sctl from URL: https://github.com/k0sproject/k0sctl/releases/download/v0.17.8/k0sctl-darwin-arm64
k0sctl is now executable in /usr/local/bin


Step 2/3 : Install kubectl
#########################
Using default kubectl version v1.30.0
Downloading kubectl from URL: https://dl.k8s.io/release/v1.30.0/bin/darwin/arm64/kubectl
kubectl is now executable in /usr/local/bin


Step 3/3 : Install mkectl
#########################
Using default mkectl version v4.0.0-alpha.0.3

Downloading mkectl
x mkectl
mkectl is now executable in /usr/local/bin
ssharma@ssharma-MBP14-1973 install % mkectl version
Version: v4.0.0-alpha.0.3
ssharma@ssharma-MBP14-1973 install % kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.3+k0s
ssharma@ssharma-MBP14-1973 install %

With k0sctl custom version

docker@ssharma-ubuntu-18-ubuntu-0:~$ sudo K0SCTL_VERSION=0.17.4 ./install.sh
Download wget
wget is already installed.


Step 1/3 : Install k0sctl
#########################
Downloading k0sctl from URL: https://github.com/k0sproject/k0sctl/releases/download/v0.17.4/k0sctl-linux-x64
k0sctl is now executable in /usr/local/bin


Step 2/3 : Install kubectl
#########################
Using default kubectl version v1.30.0
Downloading kubectl from URL: https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl
kubectl is now executable in /usr/local/bin


Step 3/3 : Install mkectl
#########################
Using default mkectl version v4.0.0-alpha.0.3

Downloading mkectl
mkectl
mkectl is now executable in /usr/local/bin
docker@ssharma-ubuntu-18-ubuntu-0:~$ k0sctl version
version: v0.17.4
commit: 372a589
docker@ssharma-ubuntu-18-ubuntu-0:~$

@sakshisharma84 sakshisharma84 requested review from nwneisen and a team May 30, 2024 18:25
@sakshisharma84
Copy link
Collaborator Author

@nwneisen Thanks for your review on PR-18. I had to re-fork and thus close the previous PR. Most of your comments are addressed.

@sakshisharma84
Copy link
Collaborator Author

sakshisharma84 commented May 30, 2024

@nwneisen Adding the unresolved conversations.
#18 (comment)

The curl command should be added to the docs so it's is a one command install process. The same as what's done for boundless https://github.com/MirantisContainers/blueprint/blob/main/website/content/docs/install/_index.md#latest

@nwneisen That is the eventual plan. The only difference wrt boundless was that this repo was not public until yesterday. We will switch to a single command once the script gets merged.

@sakshisharma84
Copy link
Collaborator Author

We should detect the latest instead of hard coding it in this script. No one is going to remember to update this.

Member
Author

@sakshisharma84 sakshisharma84 1 hour ago
I thought about it. The idea behind using the specific versions is that sometimes fetching the latest versions might possibly break things. So, I think it is better to aware and update the versions when we are sure everything works as expected.

Member

@nwneisen nwneisen 36 minutes ago
Using latest is pretty standard practice.

What's actually going to happen is these versions are never going to be updated and create a headache whenever the release is created

I understand your concern for mkectl. Let me see if I can get the latest version for it.

@nwneisen
Copy link
Collaborator

@nwneisen That is the eventual plan. The only difference wrt boundless was that this repo was not public until yesterday. We will switch to a single command once the script gets merged.

I'd say it can go in with this. I don't see a reason for two PRs. This script will be available when the PR is merged

@ranyodh
Copy link
Collaborator

ranyodh commented May 30, 2024

I understand your concern for mkectl. Let me see if I can get the latest version for it.

@sakshisharma84 The bctl install script installs the latest version. You can use that as a reference: https://github.com/MirantisContainers/blueprint/blob/main/scripts/install.sh

@sakshisharma84
Copy link
Collaborator Author

@sakshisharma84 The bctl install script installs the latest version. You can use that as a reference: https://github.com/MirantisContainers/blueprint/blob/main/scripts/install.sh

@ranyodh The bctl works because it is a public repository. For Mke, the link https://api.github.com/repos/mirantiscontainers/mke/releases gives 404.

@sakshisharma84
Copy link
Collaborator Author

sakshisharma84 commented May 30, 2024

@nwneisen That is the eventual plan. The only difference wrt boundless was that this repo was not public until yesterday. We will switch to a single command once the script gets merged.

I'd say it can go in with this. I don't see a reason for two PRs. This script will be available when the PR is merged

@nwneisen I would still prefer to test it before I put in the change.

Done!

@sakshisharma84
Copy link
Collaborator Author

@ranyodh @nwneisen I have tried to retrieve the latest MKE-4 version. But since, the repo is private, I couldn't find any straightforward way to do it. Please let me know if you have any suggestions.

@nwneisen
Copy link
Collaborator

@sakshisharma84 I would say the docs releases are going to be synced with the private mke repo's releases so you can go off of them

@sakshisharma84
Copy link
Collaborator Author

sakshisharma84 commented May 30, 2024

@sakshisharma84 I would say the docs releases are going to be synced with the private mke repo's releases so you can go off of them

Thanks @nwneisen. That sounds good. I have created (BOP-724) to track this. Until then, we can keep mkectl version as is.

@nwneisen
Copy link
Collaborator

@sakshisharma84 That sounds fine to me. Thanks for creating the ticket

@sakshisharma84
Copy link
Collaborator Author

@ranyodh @nwneisen all comments addressed/incorporated. Could you please take another look?

@ranyodh
Copy link
Collaborator

ranyodh commented May 31, 2024

@sakshisharma84 I get following error when running the script on my Mac:

sudo /bin/bash -c ./install.sh
Password:
Download wget
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

Running without sudo installs wget, but then fails in the next step.
Then, running with sudo again:

sudo /bin/bash -c ./install.sh
Password:
Download wget


Step 1/3 : Install k0sctl
#########################
Using default k0sctl version 0.17.8
Downloading k0sctl from URL: https://github.com/k0sproject/k0sctl/releases/download/v0.17.8/k0sctl-darwin-arm64
k0sctl is now executable in /usr/local/bin


Step 2/3 : Install kubectl
#########################
Using default kubectl version v1.30.0
Downloading kubectl from URL: https://dl.k8s.io/release/v1.30.0/bin/darwin/arm64/kubectl
./install.sh: line 126: /usr/local/bin/kubectl: Operation not permitted

I guess Mac is preventing to copy the file there (may be because kubectl already exists).

Finally, if the user already have any version of kubectl installed, the script should not try to install it. We should not update a core tool such as kubectl. Our usage of kubectl should work with almost any kubectl version.

@ranyodh
Copy link
Collaborator

ranyodh commented May 31, 2024

@sakshisharma84

I am thinking the script should not try to install wget. This will simplify the script alot. What do you think?

Also, any particular reason to choose wget instead of curl? The OSs that you tested on, did they bundle wget or curl (or neither)?

@sakshisharma84
Copy link
Collaborator Author

sakshisharma84 commented May 31, 2024

@ranyodh thanks for giving it a try.

  1. for mac, we don't need to run with sudo. --> will update the docs.
  2. The second error is indeed because you already have kubectl binary in /usr/local/bin with write protection.

Finally, if the user already have any version of kubectl installed, the script should not try to install it. We should not update a core tool such as kubectl. Our usage of kubectl should work with almost any kubectl version.

The reason I overwrite kubectl because we mention in our docs that we require a minimum version 1.29.0. (mkectl setup)

I can add a check if kubectl is already installed in the system.
3)

Also, any particular reason to choose wget instead of curl? The OSs that you tested on, did they bundle wget or curl (or neither)?

I chose wget over curl keeping in mind that we only need to perform downloads which makes the perfect case.

I am thinking the script should not try to install wget. This will simplify the script alot. What do you think?

If we choose to go with curl, we would still need this piece of code to make sure that curl is present on the machine. So, this won't simplify the script.

@sakshisharma84
Copy link
Collaborator Author

@ranyodh I understand your point and think it does make sense to use curl as wget is not available by default on mac.

@ranyodh
Copy link
Collaborator

ranyodh commented May 31, 2024

@sakshisharma84

The reason I overwrite kubectl because we mention in our docs that we require a minimum version 1.29.0. (mkectl setup)

I can add a check if kubectl is already installed in the system.

Yes, lets just add a check. @byDimasik Is there a particular feature in kubectl 1.29.0 which we need?

If we choose to go with curl, we would still need this piece of code to make sure that curl is present on the machine. So, this won't simplify the script.

I say we let the script fail in that case. No need to check if curl exists or not.

@byDimasik
Copy link
Collaborator

byDimasik commented May 31, 2024

@ranyodh

Yes, lets just add a check. @byDimasik Is there a particular feature in kubectl 1.29.0 which we need?

No specific feature, it just should match the k0s version. Or maybe not match but be not too much lower or too much higher.

@sakshisharma84
Copy link
Collaborator Author

@ranyodh comment incorporated!! Please take a last(hopefully) look.

Copy link
Collaborator

@ranyodh ranyodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sakshisharma84 sakshisharma84 merged commit 3318182 into Mirantis:main May 31, 2024
1 check passed
MagdaDziadosz pushed a commit that referenced this pull request Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants