Skip to content

Commit

Permalink
fix indents in the installer
Browse files Browse the repository at this point in the history
  • Loading branch information
zugwan committed May 2, 2024
1 parent ecb8be6 commit 51dc772
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 104 deletions.
33 changes: 16 additions & 17 deletions installer/bundle_builder/build-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright 2021 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0


INGREDIENTS_PATH=$1
CONFIG_PATH=$2
PACKAGETYPE=$3
Expand All @@ -21,24 +20,24 @@ cp $INGREDIENTS_PATH/*containerd* containerd.tar

# Conditional actions based on the OS argument
if [ "$PACKAGETYPE" == "deb" ]; then
# Mandatory
cp $INGREDIENTS_PATH/*kubeadm*.deb ./kubeadm.deb
cp $INGREDIENTS_PATH/*kubelet*.deb ./kubelet.deb
cp $INGREDIENTS_PATH/*kubectl*.deb ./kubectl.deb
# Optional
cp $INGREDIENTS_PATH/*cri-tools*.deb cri-tools.deb > /dev/null || true
cp $INGREDIENTS_PATH/*kubernetes-cni*.deb kubernetes-cni.deb > /dev/null || true
# Mandatory
cp $INGREDIENTS_PATH/*kubeadm*.deb ./kubeadm.deb
cp $INGREDIENTS_PATH/*kubelet*.deb ./kubelet.deb
cp $INGREDIENTS_PATH/*kubectl*.deb ./kubectl.deb
# Optional
cp $INGREDIENTS_PATH/*cri-tools*.deb cri-tools.deb >/dev/null || true
cp $INGREDIENTS_PATH/*kubernetes-cni*.deb kubernetes-cni.deb >/dev/null || true
elif [ "$PACKAGETYPE" == "rpm" ]; then
# Mandatory
cp $INGREDIENTS_PATH/*kubeadm*.rpm ./kubeadm.rpm
cp $INGREDIENTS_PATH/*kubelet*.rpm ./kubelet.rpm
cp $INGREDIENTS_PATH/*kubectl*.rpm ./kubectl.rpm
# Optional
cp $INGREDIENTS_PATH/*cri-tools*.deb cri-tools.deb > /dev/null || true
cp $INGREDIENTS_PATH/*kubernetes-cni*.deb kubernetes-cni.deb > /dev/null || true
# Mandatory
cp $INGREDIENTS_PATH/*kubeadm*.rpm ./kubeadm.rpm
cp $INGREDIENTS_PATH/*kubelet*.rpm ./kubelet.rpm
cp $INGREDIENTS_PATH/*kubectl*.rpm ./kubectl.rpm
# Optional
cp $INGREDIENTS_PATH/*cri-tools*.rpm cri-tools.rpm >/dev/null || true
cp $INGREDIENTS_PATH/*kubernetes-cni*.rpm kubernetes-cni.rpm >/dev/null || true
else
echo "Unsupported PACKAGETYPE: $PACKAGETYPE"
exit 1
echo "Unsupported PACKAGETYPE: $PACKAGETYPE"
exit 1
fi

echo Configuration $CONFIG_PATH
Expand Down
6 changes: 2 additions & 4 deletions installer/bundle_builder/build-push-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
set -e

build-bundle.sh $1 $2 $3
if [ $BUILD_ONLY -eq 0 ]
then
push-bundle.sh ${@:4}
if [ $BUILD_ONLY -eq 0 ]; then
push-bundle.sh ${@:4}
fi

151 changes: 68 additions & 83 deletions installer/internal/algo/rocky8k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,111 +67,96 @@ func (s *Rocky8Installer) Uninstall() string {
// contains the installation and uninstallation steps for the supported os and k8s
var (
DoRocky8K8s1_2x = `
set -euox pipefail
BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
IMGPKG_VERSION={{.ImgpkgVersion}}
ARCH={{.Arch}}
BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR
if ! command -v imgpkg >>/dev/null; then
echo "installing imgpkg"
if command -v wget >>/dev/null; then
dl_bin="wget -nv -O-"
elif command -v curl >>/dev/null; then
dl_bin="curl -s -L"
else
echo "installing curl"
sudo yum install -y curl
dl_bin="curl -s -L"
fi
$dl_bin github.com/vmware-tanzu/carvel-imgpkg/releases/download/$IMGPKG_VERSION/imgpkg-linux-$ARCH > /tmp/imgpkg
sudo mv /tmp/imgpkg /usr/local/bin/imgpkg
sudo chmod +x /usr/local/bin/imgpkg
fi
set -euox pipefail
BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
IMGPKG_VERSION={{.ImgpkgVersion}}
ARCH={{.Arch}}
BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR
echo "downloading bundle"
mkdir -p $BUNDLE_PATH
/usr/local/bin/imgpkg pull -i $BUNDLE_ADDR -o $BUNDLE_PATH
if ! command -v imgpkg >>/dev/null; then
echo "error: imgpkg is not found."
exit 1
fi
echo "downloading bundle"
mkdir -p $BUNDLE_PATH
/usr/local/bin/imgpkg pull -i $BUNDLE_ADDR -o $BUNDLE_PATH
## disable swap
sudo swapoff -a && sudo sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
## disable swap
sudo swapoff -a && sudo sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
## diable selinux
sudo setenforce 0 || true
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
## diable selinux
sudo setenforce 0 || true
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# disable firewall
echo "Stopping and disabling Firewalld."
sudo systemctl stop firewalld || true
sudo systemctl disable firewalld || true
# disable firewall
echo "Stopping and disabling Firewalld."
sudo systemctl stop firewalld || true
sudo systemctl disable firewalld || true
## load kernal modules
sudo modprobe overlay && sudo modprobe br_netfilter || true
## load kernal modules
sudo modprobe overlay && sudo modprobe br_netfilter || true
## adding os configuration
tar -C /etc/sysctl.d -xvf "$BUNDLE_PATH/conf.tar" && sudo sysctl --system
## adding os configuration
tar -C /etc/sysctl.d -xvf "$BUNDLE_PATH/conf.tar" && sudo sysctl --system
## installing yum-plugin-versionlock
sudo yum install yum-plugin-versionlock -y
## installing dnf-plugin-versionlock
sudo dnf install dnf-plugin-versionlock -y
## installing rpm packages
sudo yum install "$BUNDLE_PATH/kubernetes-cni.rpm" "$BUNDLE_PATH/kubelet.rpm" -y
sudo yum versionlock kubernetes-cni kubelet
for pkg in cri-tools kubectl kubeadm; do
sudo yum install "$BUNDLE_PATH/$pkg.rpm" -y
sudo yum versionlock "$pkg"
done
## installing rpm packages
sudo dnf install "$BUNDLE_PATH/kubernetes-cni.rpm" "$BUNDLE_PATH/kubelet.rpm" -y
sudo dnf versionlock kubernetes-cni kubelet
for pkg in cri-tools kubectl kubeadm; do
sudo dnf install "$BUNDLE_PATH/$pkg.rpm" -y
sudo dnf versionlock "$pkg"
done
## intalling containerd
tar -C / -xvf "$BUNDLE_PATH/containerd.tar"
## intalling containerd
tar -C / -xvf "$BUNDLE_PATH/containerd.tar"
## starting kubelet service
sudo systemctl daemon-reload && systemctl enable kubelet && systemctl start kubelet
## starting kubelet service
sudo systemctl daemon-reload && systemctl enable kubelet && systemctl start kubelet
## starting containerd service
sudo systemctl daemon-reload && systemctl enable containerd && systemctl start containerd`
## starting containerd service
sudo systemctl daemon-reload && systemctl enable containerd && systemctl start containerd`

UndoRocky8K8s1_2x = `
set -euox pipefail
set -euox pipefail
BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR
BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR
## disabling containerd service
sudo systemctl stop containerd && systemctl disable containerd && systemctl daemon-reload
## disabling containerd service
sudo systemctl stop containerd && systemctl disable containerd && systemctl daemon-reload
## removing containerd configurations and cni plugins
sudo rm -rf /opt/cni/ && sudo rm -rf /opt/containerd/ && tar tf "$BUNDLE_PATH/containerd.tar" | xargs -n 1 echo '/' | sed 's/ //g' | grep -e '[^/]$' | xargs rm -f
## removing containerd configurations and cni plugins
sudo rm -rf /opt/cni/ && sudo rm -rf /opt/containerd/ && tar tf "$BUNDLE_PATH/containerd.tar" | xargs -n 1 echo '/' | sed 's/ //g' | grep -e '[^/]$' | xargs rm -f
## removing rpm packages
for pkg in kubeadm kubelet kubectl kubernetes-cni cri-tools; do
sudo yum remove $pkg -y
done
## removing rpm packages
for pkg in kubeadm kubelet kubectl kubernetes-cni cri-tools; do
sudo dnf remove $pkg -y
done
## removing os configuration
tar tf "$BUNDLE_PATH/conf.tar" | xargs -n 1 echo '/etc/sysctl.d' | sed 's/ //g' | grep -e "[^/]$" | xargs rm -f
## removing os configuration
tar tf "$BUNDLE_PATH/conf.tar" | xargs -n 1 echo '/etc/sysctl.d' | sed 's/ //g' | grep -e "[^/]$" | xargs rm -f
## remove kernal modules
sudo modprobe -rq overlay && modprobe -r br_netfilter
## remove kernal modules
sudo modprobe -rq overlay && modprobe -r br_netfilter
## enable firewall
echo "Starting and enabling Firewalld."
sudo systemctl start firewalld || true
sudo systemctl enable firewalld || true
## enable firewall
echo "Starting and enabling Firewalld."
sudo systemctl start firewalld || true
sudo systemctl enable firewalld || true
## enable selinux
sudo setenforce 1 || true
sudo sed -i 's/^SELINUX=permissive$/SELINUX=enforcing/' /etc/selinux/config
## enable selinux
sudo setenforce 1 || true
sudo sed -i 's/^SELINUX=permissive$/SELINUX=enforcing/' /etc/selinux/config
## enable swap
sudo swapon -a || true && sed -ri '/\sswap\s/s/^#?//' /etc/fstab
## enable swap
sudo swapon -a || true && sed -ri '/\sswap\s/s/^#?//' /etc/fstab
rm -rf $BUNDLE_PATH || true`
rm -rf $BUNDLE_PATH || true`
)

0 comments on commit 51dc772

Please sign in to comment.