mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 09:59:54 +00:00
@@ -8,7 +8,7 @@ Using ARMO Platform, you will save valuable time and make spot-on hardening deci
|
||||
|
||||
1. Install Kubescape
|
||||
```
|
||||
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash
|
||||
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/docs/providers/install.sh | /bin/bash
|
||||
```
|
||||
> Alternatively, you can [install Kubescape using package managers](../installation.md#installation)
|
||||
|
||||
|
||||
40
docs/providers/install.ps1
Executable file
40
docs/providers/install.ps1
Executable file
@@ -0,0 +1,40 @@
|
||||
Write-Host "Installing Kubescape..." -ForegroundColor Cyan
|
||||
|
||||
$BASE_DIR=$env:USERPROFILE + "\.kubescape"
|
||||
$packageName = "/kubescape.exe"
|
||||
|
||||
# Get latest release url
|
||||
$config = Invoke-WebRequest "https://api.github.com/repos/kubescape/kubescape/releases/latest" | ConvertFrom-Json
|
||||
$url = $config.html_url.Replace("/tag/","/download/")
|
||||
$fullUrl = $url + $packageName
|
||||
|
||||
# Create a new directory if needed
|
||||
New-Item -Path $BASE_DIR -ItemType "directory" -ErrorAction SilentlyContinue
|
||||
|
||||
# Download the binary
|
||||
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
|
||||
if ($useBitTransfer)
|
||||
{
|
||||
Write-Information -MessageData 'Using a fallback BitTransfer method since you are running Windows PowerShell'
|
||||
Start-BitsTransfer -Source $fullUrl -Destination $BASE_DIR\kubescape.exe
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke-WebRequest -Uri $fullUrl -OutFile $BASE_DIR\kubescape.exe
|
||||
}
|
||||
|
||||
# Update user PATH if needed
|
||||
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if (-not $currentPath.Contains($BASE_DIR)) {
|
||||
$confirmation = Read-Host "Add kubescape to user path? (y/n)"
|
||||
if ($confirmation -eq 'y') {
|
||||
$env:Path=[Environment]::GetEnvironmentVariable("Path", "User") + ";$BASE_DIR;"
|
||||
[Environment]::SetEnvironmentVariable("Path", "${env:Path}", "User")
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Finished Installation.`n" -ForegroundColor Green
|
||||
Write-Host "Executing Kubescape.`n" -ForegroundColor Green
|
||||
|
||||
kubescape scan --create-account
|
||||
121
docs/providers/install.sh
Executable file
121
docs/providers/install.sh
Executable file
@@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
while getopts v: option
|
||||
do
|
||||
case ${option} in
|
||||
v) RELEASE="download/${OPTARG}";;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "${RELEASE}" ]; then
|
||||
RELEASE="latest/download"
|
||||
fi
|
||||
|
||||
echo -e "\033[0;36mInstalling Kubescape..."
|
||||
echo
|
||||
|
||||
BASE_DIR=~/.kubescape
|
||||
KUBESCAPE_EXEC=kubescape
|
||||
|
||||
osName=$(uname -s)
|
||||
if [[ $osName == *"MINGW"* ]]; then
|
||||
osName=windows
|
||||
elif [[ $osName == *"Darwin"* ]]; then
|
||||
osName=macos
|
||||
else
|
||||
osName=ubuntu
|
||||
fi
|
||||
|
||||
arch=$(uname -m)
|
||||
if [[ $arch == *"aarch64"* || $arch == *"arm64"* ]]; then
|
||||
arch="-arm64"
|
||||
else
|
||||
if [[ $arch != *"x86_64"* ]]; then
|
||||
echo -e "\033[33mArchitecture $arch may be unsupported, will try to install the amd64 one anyway."
|
||||
fi
|
||||
arch=""
|
||||
fi
|
||||
|
||||
mkdir -p $BASE_DIR
|
||||
|
||||
OUTPUT=$BASE_DIR/$KUBESCAPE_EXEC
|
||||
DOWNLOAD_URL="https://github.com/kubescape/kubescape/releases/${RELEASE}/kubescape${arch}-${osName}-latest"
|
||||
|
||||
curl --progress-bar -L $DOWNLOAD_URL -o $OUTPUT
|
||||
|
||||
# Find install dir
|
||||
install_dir=/usr/local/bin # default if running as root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
install_dir=$BASE_DIR/bin # if not running as root, install to user dir
|
||||
export PATH=$PATH:$BASE_DIR/bin
|
||||
fi
|
||||
|
||||
# Create install dir if it does not exist
|
||||
if [ ! -d "$install_dir" ]; then
|
||||
mkdir -p $install_dir
|
||||
fi
|
||||
|
||||
chmod +x $OUTPUT 2>/dev/null
|
||||
|
||||
# cleaning up old install
|
||||
SUDO=
|
||||
if [ "$(id -u)" -ne 0 ] && [ -n "$(which sudo)" ] && [ "$KUBESCAPE_EXEC" != "" ] && [ -f /usr/local/bin/$KUBESCAPE_EXEC ]; then
|
||||
SUDO=sudo
|
||||
echo -e "\n\033[33mOld installation as root found, do you want to remove it? [\033[0my\033[33m/n]:"
|
||||
read -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]] && [[ "$REPLY" != "" ]]; then
|
||||
echo -e "\n\033[0mSkipping old installation as root removal."
|
||||
else
|
||||
echo -e "\n\033[0mWe will need the root access to uninstall the old kubescape CLI."
|
||||
if $SUDO rm -f /usr/local/bin/$KUBESCAPE_EXEC 2>/dev/null; then
|
||||
echo -e "\033[32mRemoved old installation as root at /usr/local/bin/$KUBESCAPE_EXEC"
|
||||
else
|
||||
echo -e "\033[31mFailed to remove old installation as root at /usr/local/bin/$KUBESCAPE_EXEC, please remove it manually."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$KUBESCAPE_EXEC" != "" ]; then
|
||||
if [ "${SUDO_USER:-$USER}" != "" ]; then
|
||||
rm -f /home/"${SUDO_USER:-$USER}"/.kubescape/bin/$KUBESCAPE_EXEC 2>/dev/null || true
|
||||
fi
|
||||
if [ "$BASE_DIR" != "" ]; then
|
||||
rm -f $BASE_DIR/bin/$KUBESCAPE_EXEC 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Old install location, clean all those things up
|
||||
for pdir in ${PATH//:/ }; do
|
||||
edir="${pdir/#\~/$HOME}"
|
||||
if [[ $edir == $HOME/* ]] && [[ -f $edir/$KUBESCAPE_EXEC ]]; then
|
||||
echo -e "\n\033[33mOld installation found at $edir/$KUBESCAPE_EXEC, do you want to remove it? [\033[0my\033[33m/n]:"
|
||||
read -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]] && [[ "$REPLY" != "" ]]; then
|
||||
continue
|
||||
fi
|
||||
if rm -f "$edir"/$KUBESCAPE_EXEC 2>/dev/null; then
|
||||
echo -e "\n\033[32mRemoved old installation at $edir/$KUBESCAPE_EXEC"
|
||||
else
|
||||
echo -e "\n\033[31mFailed to remove old installation as root at $edir/$KUBESCAPE_EXEC, please remove it manually."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cp $OUTPUT $install_dir/$KUBESCAPE_EXEC
|
||||
rm -f $OUTPUT
|
||||
|
||||
echo
|
||||
echo -e "\033[32mFinished Installation."
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e "\nRemember to add the Kubescape CLI to your path with:"
|
||||
echo -e " export PATH=\$PATH:$BASE_DIR/bin"
|
||||
export PATH=\$PATH:$BASE_DIR/bin
|
||||
fi
|
||||
|
||||
echo -e "\033[0m"
|
||||
echo -e "\033[32mExecuting Kubescape."
|
||||
echo
|
||||
$KUBESCAPE_EXEC scan --create-account
|
||||
@@ -118,6 +118,7 @@ echo -e "\033[35mUsage: $ $KUBESCAPE_EXEC scan"
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e "\nRemember to add the Kubescape CLI to your path with:"
|
||||
echo -e " export PATH=\$PATH:$BASE_DIR/bin"
|
||||
export PATH=\$PATH:$BASE_DIR/bin
|
||||
fi
|
||||
|
||||
echo -e "\033[0m"
|
||||
|
||||
Reference in New Issue
Block a user