Skip to content

Commit

Permalink
Merge pull request #4 from openinfradev/k8s_1.27_1.28
Browse files Browse the repository at this point in the history
K8s 1.27, 1.28 버전 지원
  • Loading branch information
zugwan authored May 2, 2024
2 parents 35d5bf6 + c91d452 commit afe02f1
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 161 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ replace github.com/insomniacslk/dhcp => github.com/harvester/dhcp v0.0.0-2022042
replace golang.org/x/net => golang.org/x/net v0.17.0

require (
github.com/docker/cli v24.0.5+incompatible
github.com/docker/docker v24.0.5+incompatible
github.com/docker/cli v24.0.7+incompatible
github.com/docker/docker v24.0.7+incompatible
github.com/go-logr/logr v1.2.3
github.com/jackpal/gateway v1.0.7
github.com/kube-vip/kube-vip v0.5.5
Expand Down Expand Up @@ -117,7 +117,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
Expand All @@ -143,14 +143,14 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand Down
45 changes: 14 additions & 31 deletions go.sum

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions installer/bundle_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
# // Build and store a BYOH bundle
# docker run --rm -v <INGREDIENTS_HOST_ABS_PATH>:/ingredients -v <BUNDLE_OUTPUT_ABS_PATH>:/bundle --env <THIS_IMAGE>

FROM k14s/image
# https://github.com/carvel-dev/docker-image/blob/develop/Dockerfile
FROM ubuntu
# perl is needed for shasum
RUN apt-get -y update && apt-get install -y wget perl ca-certificates && update-ca-certificates && rm -rf /var/lib/apt/lists/*
RUN bash -c "set -eo pipefail; wget -O- https://carvel.dev/install.sh | bash"
RUN ytt version && kapp version && kbld version && kwt version && imgpkg version && vendir version

# If set to 1 bundle is built and available as bundle/bundle.tar
# If set to 0 bundle is build and pushed to repo
Expand All @@ -32,4 +37,4 @@ RUN mkdir /ingredients && mkdir /bundle
ENV PATH="/bundle-builder:${PATH}"

WORKDIR /tmp/bundle
ENTRYPOINT ["build-push-bundle.sh", "/ingredients", "/config"]
ENTRYPOINT ["build-push-bundle.sh", "/ingredients", "/config", "rpm"]
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

2 changes: 1 addition & 1 deletion installer/bundle_builder/ingredients/deb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ARG BASE_IMAGE=ubuntu:20.04
FROM $BASE_IMAGE as build

# Override to download other version
ENV CONTAINERD_VERSION=1.6.18
ENV CONTAINERD_VERSION=1.6.26
ENV KUBERNETES_VERSION=1.26.6-00
ENV ARCH=amd64

Expand Down
6 changes: 3 additions & 3 deletions installer/bundle_builder/ingredients/rpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
# 2. Run the image
#

ARG BASE_IMAGE=rockylinux:8.7
ARG BASE_IMAGE=rockylinux:8
FROM $BASE_IMAGE as build

# Override to download other version
ENV CONTAINERD_VERSION=1.6.18
ENV KUBERNETES_VERSION=1.25.11-0
ENV CONTAINERD_VERSION=1.6.31
ENV KUBERNETES_VERSION=1.28
ENV ARCH=x86_64

RUN dnf -y install sudo
Expand Down
20 changes: 7 additions & 13 deletions installer/bundle_builder/ingredients/rpm/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@

set -e

echo Update the apt package index and install packages needed to use the Kubernetes apt repository
sudo dnf install -y apt-transport-https ca-certificates curl
sudo dnf install -y 'dnf-command(download)'

echo Download containerd
curl -LOJR https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/cri-containerd-cni-${CONTAINERD_VERSION}-linux-amd64.tar.gz

echo Download the Google Cloud public signing key
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://dl.k8s.io/apt/doc/apt-key.gpg

echo Add the Kubernetes apt repository
sudo cat <<EOF > /etc/yum.repos.d/kubernetes.repo
echo Add the Kubernetes repository
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
baseurl=https://pkgs.k8s.io/core:/stable:/v${KUBERNETES_VERSION}/rpm/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
gpgkey=https://pkgs.k8s.io/core:/stable:/v${KUBERNETES_VERSION}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF

echo Update dnf package index, install kubelet, kubeadm and kubectl
sudo dnf download {kubelet,kubeadm,kubectl}-$KUBERNETES_VERSION --arch $ARCH
sudo dnf download kubernetes-cni-1.1.1-0 --arch $ARCH
sudo dnf download cri-tools-1.25.0-0 --arch $ARCH
dnf download kubelet kubeadm kubectl cri-tools kubernetes-cni --disableexcludes=kubernetes --arch ${ARCH}
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 afe02f1

Please sign in to comment.