kind-machine/install-kind-machine.sh

83 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
INSTALL_TERRAFORM="true"
INSTALL_HELM="true"
# If version is empty, and rpm latest is installed. If bin you need version.
TERRAFORM_VERSION=
TERRAFORM_SOURCE="rpm" #Value rpm|bin
CONTAINER_ENGINE="podman" # Value podman|docker
kind () {
# Install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
}
terraform_bin () {
# Install terraform
if [ "${TERRAFORM_SOURCE}" == bin ]; then
if [ ! -z "${TERRAFORM_VERSION}" ]; then
echo "You need to provide terraform version when to use bin source"
exit
fi
curl -Lo ./terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip ./terraform.zip
chmod +x ./terraform
sudo mv ./terraform /usr/local/bin/terraform
fi
}
terraform_rpm () {
# Install terraform
if [ "${TERRAFORM_SOURCE}" == bin ]; then
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
if [ ! -z "${TERRAFORM_VERSION}" ]; then
sudo sed -i 's/^enabled=1/enabled=0/g' /etc/yum.repos.d/hashicorp.repo
sudo dnf -y install terraform-${TERRAFORM_VERSION} --enablerepo hashicorp
else
sudo sed -i 's/^enabled=0/enabled=1/g' /etc/yum.repos.d/hashicorp.repo
sudo dnf -y install terraform
fi
fi
}
helm () {
# Install helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
}
kubectl () {
# Install kubectl
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y kubectl
}
prereq_fedora () {
if [ "${CONTAINER_ENGINE}" == docker ]; then
sudo dnf install -y moby-engine
sudo systemctl enable --now docker.service
else
sudo dnf install -y podman
fi
}
prereq_fedora
kind
if [ "${INSTALL_TERRAFORM}" == true ]; then
terraform_bin
terraform_rpm
fi
if [ "${INSTALL_HELM}" == true ]; then
helm
fi
kubectl