-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add Kubectl binary download script for all Linux distributions #819
Add Kubectl binary download script for all Linux distributions #819
Conversation
329a517
to
ee7921e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I do not know where other than the CI this script is being used, but having it more generic and supporting multiple Linux distributions is not a bad idea. However, I would opt for externalizing the logic. We should keep this brief and simple. If we were to start with the package manager switch, we could end up adding more and more cases that would need to be maintained.
For simplicity, I would suggest to adopt in the install kubectl with curl style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be my suggestion:
#!/bin/bash
# Copyright The Shipwright Contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# Installs "kubectl"
#
set -euo pipefail
# Find a suitable install location
if [[ -w /usr/local/bin ]]; then
TARGET_DIR=/usr/local/bin
elif [[ -w "${HOME}/bin" ]] && grep -q -e "${HOME}/bin" -e '\~/bin' <<<"$PATH"; then
TARGET_DIR="${HOME}/bin"
else
echo -e "Unable to determine a writable install location. Make sure that you have write access to either \\033[1m/usr/local/bin\\033[0m or \\033[1m${HOME}/bin\\033[0m and that is in your PATH."
exit 1
fi
# Look-up current stable version from their release site
STABLE_VERSION="$(curl --fail --silent --location https://dl.k8s.io/release/stable.txt)"
echo "# Downloading kubectl binary..."
curl --fail --progress-bar --location "https://dl.k8s.io/release/${STABLE_VERSION}/bin/linux/amd64/kubectl" --output "${TARGET_DIR}/kubectl" && \
chmod a+rx "${TARGET_DIR}/kubectl"
echo "# Validating kubectl binary..."
sha256sum --check <<<"$(curl --fail --silent --location "https://dl.k8s.io/${STABLE_VERSION}/bin/linux/amd64/kubectl.sha256") ${TARGET_DIR}/kubectl"
echo "# Kubectl version"
kubectl version --client
It is relatively short, requires no sudo
and should run on most distros just fine. I checked it on Ubuntu, Fedora and UBI.
@HeavyWombat, It looks clean. I have made the suggested changes. Observed the same on |
ee7921e
to
0f2d68f
Compare
@kevydotvinu Could you help me by rebasing this branch to get the latest updates? I think there was a commit that addresses the deployment for the test cases. |
0f2d68f
to
3905187
Compare
Yes, I have done that. Thanks, @HeavyWombat. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SaschaSchwarze0 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
Kubectl binary download script modification has been done to accommodate all Linux distributions.
Submitter Checklist
Release Notes