Skip to content
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

feat: support minikube #262

Merged
merged 4 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions build/installer/install_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ run_install() {

# cache version to file
ensure_success $sh_c "echo 'VERSION=${VERSION}' > /etc/kke/version"
ensure_success $sh_c "echo 'KKE=${KKE_VERSION}' >> /etc/kke/version"
ensure_success $sh_c "echo 'KKE=${TERMINUS_CLI_VERSION}' >> /etc/kke/version"
ensure_success $sh_c "echo 'KUBE=${k8s_version}' >> /etc/kke/version"

# setup after kubesphere is installed
Expand Down Expand Up @@ -1475,26 +1475,24 @@ install_containerd(){
}

install_k8s_ks() {
# KKE_VERSION=0.1.24
KKE_VERSION=0.1.4
TERMINUS_CLI_VERSION=0.1.5

ensure_success $sh_c "mkdir -p /etc/kke"
local kk_bin="${BASE_DIR}/components/terminus-cli"
local kk_tar="${BASE_DIR}/components/terminus-cli-v${KKE_VERSION}_linux_${ARCH}.tar.gz"
# https://github.com/Above-Os/installer/releases/download/0.1.4/terminus-cli-v0.1.4_linux_arm64.tar.gz
local kk_tar="${BASE_DIR}/components/terminus-cli-v${TERMINUS_CLI_VERSION}_linux_${ARCH}.tar.gz"
if [ ! -f "$kk_bin" ]; then
if [ ! -f "$kk_tar" ]; then
ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/Above-Os/installer/releases/download/${KKE_VERSION}/terminus-cli-v${KKE_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-v${KKE_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/beclab/Installer/releases/download/${TERMINUS_CLI_VERSION}/terminus-cli-v${TERMINUS_CLI_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-v${TERMINUS_CLI_VERSION}_linux_${ARCH}.tar.gz"
# if [ x"$PROXY" != x"" ]; then
# ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/beclab/kubekey-ext/releases/download/${KKE_VERSION}/kubekey-ext-v${KKE_VERSION}-linux-${ARCH}.tar.gz"
# ensure_success $sh_c "tar xf kubekey-ext-v${KKE_VERSION}-linux-${ARCH}.tar.gz"
# ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/beclab/kubekey-ext/releases/download/${TERMINUS_CLI_VERSION}/kubekey-ext-v${TERMINUS_CLI_VERSION}-linux-${ARCH}.tar.gz"
# ensure_success $sh_c "tar xf kubekey-ext-v${TERMINUS_CLI_VERSION}-linux-${ARCH}.tar.gz"
# else
# ensure_success $sh_c "curl ${CURL_TRY} -sfL https://raw.githubusercontent.com/beclab/kubekey-ext/master/downloadKKE.sh | VERSION=${KKE_VERSION} sh -"
# ensure_success $sh_c "curl ${CURL_TRY} -sfL https://raw.githubusercontent.com/beclab/kubekey-ext/master/downloadKKE.sh | VERSION=${TERMINUS_CLI_VERSION} sh -"
# fi
else
ensure_success $sh_c "cp ${kk_tar} terminus-cli-${KKE_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-${KKE_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "cp ${kk_tar} terminus-cli-${TERMINUS_CLI_VERSION}_linux_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-${TERMINUS_CLI_VERSION}_linux_${ARCH}.tar.gz"
fi
else
ensure_success $sh_c "cp ${kk_bin} ./"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CURL_TRY="--connect-timeout 30 --retry 5 --retry-delay 1 --retry-max-time 10 "
BASE_DIR=$(dirname $(realpath -s $0))
BASE_DIR=${BASE_DIR:-.}
CLUSTER_NAME=$1
PROFILE_NAME="terminus-${CLUSTER_NAME:-0}"

[[ -f "${BASE_DIR}/.env" && -z "$DEBUG_VERSION" ]] && . "${BASE_DIR}/.env"

Expand Down Expand Up @@ -78,6 +79,23 @@ function retry_cmd(){
return $ret
}

precheck_os() {
os_type=$(uname -s)
case "$os_type" in
Darwin) OSTYPE=darwin; ;;
*) OSTYPE="${os_type}"
esac

os_arch=$(uname -m)
case "$os_arch" in
arm64) ARCH=arm64; ;;
x86_64) ARCH=amd64; ;;
armv7l) ARCH=arm; ;;
aarch64) ARCH=arm64; ;;
*) echo "unsupported arch, exit ...";
exit -1; ;;
esac
}

install_helm() {
if ! command_exists helm; then
Expand All @@ -104,8 +122,43 @@ log_fatal() {
}

install_ks(){
ensure_success $sh_c "${KUBECTL} apply -f ${BASE_DIR}/kubesphere-installer.yaml"
ensure_success $sh_c "${KUBECTL} apply -f ${BASE_DIR}/cluster-configuration.yaml"
KUBE_TYPE=${KUBE_TYPE}
if [ -z $KUBE_TYPE ]; then
KUBE_TYPE="k3s"
fi
TERMINUS_CLI_VERSION="0.1.5"

cmd="mkdir -p ${BASE_DIR}/components"
[ ! -d "${BASE_DIR}/components" ] && ensure_success eval $($cmd)

local kk_bin="${BASE_DIR}/components/terminus-cli"
local kk_tar="${BASE_DIR}/components/terminus-cli-v${TERMINUS_CLI_VERSION}_${OSTYPE}_${ARCH}.tar.gz"
if [ ! -f "$kk_bin" ]; then
if [ ! -f "$kk_tar" ]; then
ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/beclab/Installer/releases/download/${TERMINUS_CLI_VERSION}/terminus-cli-v${TERMINUS_CLI_VERSION}_${OSTYPE}_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-v${TERMINUS_CLI_VERSION}_${OSTYPE}_${ARCH}.tar.gz"
# if [ x"$PROXY" != x"" ]; then
# ensure_success $sh_c "curl ${CURL_TRY} -k -sfLO https://github.com/beclab/kubekey-ext/releases/download/${TERMINUS_CLI_VERSION}/kubekey-ext-v${TERMINUS_CLI_VERSION}-linux-${ARCH}.tar.gz"
# ensure_success $sh_c "tar xf kubekey-ext-v${TERMINUS_CLI_VERSION}-linux-${ARCH}.tar.gz"
# else
# ensure_success $sh_c "curl ${CURL_TRY} -sfL https://raw.githubusercontent.com/beclab/kubekey-ext/master/downloadKKE.sh | VERSION=${TERMINUS_CLI_VERSION} sh -"
# fi
else
ensure_success $sh_c "cp ${kk_tar} terminus-cli-${TERMINUS_CLI_VERSION}_${OSTYPE}_${ARCH}.tar.gz"
ensure_success $sh_c "tar xf terminus-cli-${TERMINUS_CLI_VERSION}_${OSTYPE}_${ARCH}.tar.gz"
fi
else
cmd="cp ${kk_bin} ./"
ensure_success eval $($cmd)
fi

cmd="./terminus-cli terminus init --kube ${KUBE_TYPE} --minikube --profile ${PROFILE_NAME}"
# echo "command: ${cmd}"
# ensure_success eval $($cmd)
ensure_success $sh_c "${cmd}"
# ./terminus-cli terminus init --kube "${KUBE_TYPE}" --minikube --profile "${PROFILE_NAME}"
# $(./terminus-cli terminus init --kube "${KUBE_TYPE}" --minikube --profile "${PROFILE_NAME}")
# ensure_success $sh_c "./terminus-cli terminus init --kube ${KUBE_TYPE} --minikube --profile ${PROFILE_NAME}"
}

get_auth_status(){
Expand Down Expand Up @@ -385,7 +438,8 @@ validate_userpwd() {
preload_images(){
if [ -d $BASE_DIR/images ]; then
echo "preload images to local ... "
ensure_success eval $(minikube -p terminus-0 docker-env)
# res=$(minikube -p "${PROFILE_NAME}" docker-env)
# ensure_success $sh_c "eval ${res}"

local tar_count=$(find $BASE_DIR/images -type f -name '*.tar.gz'|wc -l)
if [ $tar_count -eq 0 ]; then
Expand All @@ -401,7 +455,9 @@ preload_images(){
fi

find $BASE_DIR/images -type f -name '*.tar.gz' | while read filename; do
$sh_c "gunzip -c ${filename} | docker load"
# $sh_c "gunzip -c ${filename} | docker load"
$sh_c "minikube image load ${filename} -p ${PROFILE_NAME}"
echo "Loaded image: ${filename}"
done
fi
}
Expand Down Expand Up @@ -674,6 +730,8 @@ main(){
HOSTNAME=$(hostname)
natgateway=$(ping -c 1 "$HOSTNAME" |awk -F '[()]' '/PING/{print $2}')

precheck_os

if [ x"$natgateway" == x"" ]; then
while :; do
read_tty "Enter the host IP: " natgateway
Expand All @@ -695,9 +753,9 @@ main(){
fi

if command_exists minikube ; then
running=$(minikube profile list|grep "terminus-${CLUSTER_NAME:-0}"|grep Running)
running=$(minikube profile list|grep "${PROFILE_NAME}"|grep Running)
if [ x"$running" == x"" ]; then
ensure_success minikube start -p "terminus-${CLUSTER_NAME:-0}" --kubernetes-version=v1.22.10 --network-plugin=cni --cni=calico --cpus='4' --memory='8g' --ports=30180:30180,443:443,80:80
ensure_success minikube start -p "${PROFILE_NAME}" --kubernetes-version=v1.22.10 --network-plugin=cni --cni=calico --cpus='4' --memory='8g' --ports=30180:30180,443:443,80:80
fi
else
log_fatal "Please install minikube on your machine"
Expand Down
6 changes: 6 additions & 0 deletions build/manifest/images
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ beclab/notification-manager-ext:v0.1.1-ext
beclab/notification-manager-operator-ext:v0.1.0-ext
beclab/notification-tenant-sidecar:v0.1.0
calico/cni:v3.23.2
calico/cni:v3.27.3
calico/kube-controllers:v3.23.2
calico/kube-controllers:v3.27.3
calico/node:v3.23.2
calico/node:v3.27.3
calico/pod2daemon-flexvol:v3.23.2
beclab/citus:12.2
coredns/coredns:1.8.0
Expand All @@ -21,13 +24,15 @@ kubesphere/kube-controller-manager:v1.21.4
kubesphere/kubectl:v1.22.0
kubesphere/kube-proxy:v1.22.10
kubesphere/kube-proxy:v1.21.4
kubesphere/kube-rbac-proxy:v0.12.0
kubesphere/kube-rbac-proxy:v0.11.0
kubesphere/kube-rbac-proxy:v0.8.0
kubesphere/kube-scheduler:v1.22.10
kubesphere/kube-scheduler:v1.21.4
kubesphere/pause:3.5
kubesphere/pause:3.4.1
k8s.gcr.io/pause:3.6
registry.k8s.io/pause:3.5
kubesphere/prometheus-config-reloader:v0.55.1
kubesphere/prometheus-operator:v0.55.1
mirrorgooglecontainers/defaultbackend-amd64:1.4
Expand All @@ -48,3 +53,4 @@ beclab/velero-plugin-for-terminus:v1.0.1
beclab/velero-plugin-for-terminus:v1.0.2
rancher/coredns-coredns:1.8.3
beclab/l4-bfl-proxy:v0.2.6
gcr.io/k8s-minikube/storage-provisioner:v5
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VERSION=$1

DIST_PATH=${DIST_PATH} bash ${BASE_DIR}/package.sh
cp ${BASE_DIR}/upgrade.sh ${DIST_PATH}/.
cp ${BASE_DIR}/developer/* ${DIST_PATH}/.
# cp ${BASE_DIR}/developer/* ${DIST_PATH}/.

# bash ${BASE_DIR}/image-manifest.sh

Expand Down
118 changes: 0 additions & 118 deletions scripts/developer/cluster-configuration.yaml

This file was deleted.

Loading
Loading