Skip to content

Commit 4a79947

Browse files
authored
Merge pull request #52 from openinfradev/imgpkg_support
Imgpkg 설치 지원
2 parents afb83a7 + ee0a95f commit 4a79947

8 files changed

+68
-35
lines changed

01_prepare_assets.sh

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,37 @@ declare -a DOCKER_PKGS_UBUNTU=("containerd.io_1.6.21-1_amd64.deb" "docker-ce-cli
88
declare -a DOCKER_PKGS_CENTOS=("containerd.io-1.6.21-3.1.el8.x86_64.rpm" "docker-ce-20.10.24-3.el8.x86_64.rpm" "docker-ce-cli-20.10.24-3.el8.x86_64.rpm" "docker-ce-rootless-extras-20.10.24-3.el8.x86_64.rpm" "docker-compose-plugin-2.19.1-1.el8.x86_64.rpm")
99

1010
# Github assets
11-
KIND_ASSETS_URL="https://github.com/kubernetes-sigs/kind/releases"
11+
KIND_ASSETS_URL="https://github.com/kubernetes-sigs/kind"
1212
KIND_ASSETS_FILES=(kind-linux-amd64)
1313
KIND_VERSION="v0.20.0"
14-
CAPI_ASSETS_URL="https://github.com/kubernetes-sigs/cluster-api/releases"
14+
CAPI_ASSETS_URL="https://github.com/kubernetes-sigs/cluster-api"
1515
CAPI_ASSETS_FILES=(metadata.yaml bootstrap-components.yaml cluster-api-components.yaml clusterctl-linux-amd64 control-plane-components.yaml core-components.yaml)
16-
CAPA_ASSETS_URL="https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases"
16+
CAPA_ASSETS_URL="https://github.com/kubernetes-sigs/cluster-api-provider-aws"
1717
CAPA_ASSETS_FILES=(metadata.yaml clusterawsadm-linux-amd64 infrastructure-components.yaml)
18-
BYOH_ASSETS_URL="https://github.com/vmware-tanzu/cluster-api-provider-bringyourownhost/releases"
18+
BYOH_ASSETS_URL="https://github.com/vmware-tanzu/cluster-api-provider-bringyourownhost"
1919
BYOH_ASSETS_FILES=(metadata.yaml infrastructure-components.yaml byoh-hostagent-linux-amd64)
20-
ARGOWF_ASSETS_URL="https://github.com/argoproj/argo-workflows/releases"
20+
ARGOWF_ASSETS_URL="https://github.com/argoproj/argo-workflows"
2121
ARGOWF_ASSETS_FILES=(argo-linux-amd64.gz)
22-
ARGOCD_ASSETS_URL="https://github.com/argoproj/argo-cd/releases"
22+
ARGOCD_ASSETS_URL="https://github.com/argoproj/argo-cd"
2323
ARGOCD_ASSETS_FILES=(argocd-linux-amd64)
24-
GUM_ASSETS_URL="https://github.com/charmbracelet/gum/releases"
25-
GUM_ASSETS_FILES=(gum_0.10.0_linux_x86_64.tar.gz)
26-
GUM_VERSION="v0.10.0"
27-
GITEA_ASSETS_URL="https://github.com/go-gitea/gitea/releases"
24+
GUM_ASSETS_URL="https://github.com/charmbracelet/gum"
25+
GUM_ASSETS_FILES=(gum_0.14.1_linux_x86_64.tar.gz)
26+
GUM_VERSION="v0.14.1"
27+
GITEA_ASSETS_URL="https://github.com/go-gitea/gitea"
2828
GITEA_ASSETS_FILES=(gitea-1.18.1-linux-amd64)
2929
GITEA_VERSION="v1.8.1"
30-
EKSCTL_ASSETS_URL="https://github.com/eksctl-io/eksctl/releases"
30+
EKSCTL_ASSETS_URL="https://github.com/eksctl-io/eksctl"
3131
EKSCTL_ASSETS_FILES=(eksctl_linux_amd64.tar.gz)
3232
EKSCTL_VERSION="latest"
33-
AWS_IAM_AUTHENTICATOR_ASSETS_URL="https://github.com/kubernetes-sigs/aws-iam-authenticator/releases"
33+
AWS_IAM_AUTHENTICATOR_ASSETS_URL="https://github.com/kubernetes-sigs/aws-iam-authenticator"
3434
AWS_IAM_AUTHENTICATOR_ASSETS_FILES=(aws-iam-authenticator_0.5.9_linux_amd64)
3535
AWS_IAM_AUTHENTICATOR_VERSION="v0.5.9"
36-
JQ_ASSETS_URL="https://github.com/jqlang/jq/releases"
36+
JQ_ASSETS_URL="https://github.com/jqlang/jq"
3737
JQ_ASSETS_FILES=(jq-linux64)
3838
JQ_VERSION="jq-1.6"
39+
IMGPKG_ASSETS_URL="https://github.com/carvel-dev/imgpkg"
40+
IMGPKG_ASSETS_FILES=(imgpkg-linux-amd64)
41+
IMGPKG_VERSION="${IMGPKG_VERSION}"
3942

4043
# Git repos
4144
# "repo_url,tag/branch,dest_dir"
@@ -46,7 +49,7 @@ git_repos+=("https://github.com/openinfradev/decapod-flow,${TKS_RELEASE},decapod
4649
git_repos+=("https://github.com/openinfradev/tks-flow,${TKS_RELEASE},tks-flow")
4750
git_repos+=("https://github.com/openinfradev/decapod-base-yaml,${TKS_RELEASE},decapod-base-yaml")
4851
git_repos+=("https://github.com/openinfradev/decapod-site,${TKS_RELEASE},decapod-site")
49-
git_repos+=("https://github.com/rancher/local-path-provisioner.git,master,local-path-provisioner")
52+
git_repos+=("https://github.com/rancher/local-path-provisioner.git,v0.0.28,local-path-provisioner")
5053

5154
# Helm chart
5255
# "chart_name,repo_url,chart_version,dest_dir"
@@ -80,14 +83,16 @@ download_assets_from_github () {
8083
eval files='$'{$1_ASSETS_FILES[@]}
8184
eval version='$'$1_VERSION
8285

83-
reponame=${url%/releases*}
84-
reponame=${reponame##*.com/}
86+
owner=${url#*github.com/}
87+
owner=${owner%%/*}
88+
89+
reponame=${url##*/}
8590

8691
log_info "Downloading assets from $reponame"
8792

8893
if [[ $version == "latest" ]]
8994
then
90-
tag=$(github_get_latest_release $reponame)
95+
tag=$(github_get_latest_release $owner/$reponame)
9196
else
9297
tag=$version
9398
fi
@@ -97,7 +102,7 @@ download_assets_from_github () {
97102

98103
for f in ${files[@]}
99104
do
100-
curl -sSL "$url/download/$tag/$f" -o $dest_dir/$f
105+
curl -sSL "$url/releases/download/$tag/$f" -o $dest_dir/$f
101106
done
102107
}
103108

@@ -186,16 +191,16 @@ if [ -d $ASSETS_DIR ]; then
186191
gum confirm "Are you sure you want to clear the current directory and proceed?" || exit 1
187192
fi
188193

189-
rm -rf $ASSETS_DIR
194+
sudo rm -rf $ASSETS_DIR
190195

191196
mkdir $ASSETS_DIR
192197
mkdir -p output
193198

194199
download_assets_from_github GUM
195200
GUM_ASSETS_DIR="$ASSETS_DIR/gum/$(ls $ASSETS_DIR/gum | grep v)"
196201
cd $GUM_ASSETS_DIR
197-
tar xfz $(ls)
198-
sudo cp gum /usr/local/bin
202+
gum_bin_path=$(tar xvfz ${GUM_ASSETS_FILES[0]} | grep gum$)
203+
sudo cp $gum_bin_path /usr/local/bin
199204
cd - >/dev/null
200205

201206
log_info "Downloading docker packages"
@@ -239,6 +244,11 @@ for provider in ${CAPI_INFRA_PROVIDERS[@]}; do
239244
download_assets_from_github BYOH
240245
cp $ASSETS_DIR/cluster-api-provider-bringyourownhost/$BYOH_VERSION/byoh-hostagent-linux-amd64 output/byoh-hostagent
241246
chmod +x output/byoh-hostagent
247+
248+
download_assets_from_github IMGPKG
249+
cp $ASSETS_DIR/imgpkg/$IMGPKG_VERSION/imgpkg-linux-amd64 output/imgpkg
250+
chmod +x output/imgpkg
251+
242252
sed -i "s#projects.registry.vmware.com/cluster_api_provider_bringyourownhost/cluster-api-byoh-controller:$BYOH_VERSION#$TKS_BYOH_CONTOLLER_IMAGE:$BYOH_TKS_VERSION#g" $ASSETS_DIR/cluster-api-provider-bringyourownhost/$BYOH_VERSION/infrastructure-components.yaml
243253
;;
244254
esac

02_create_bootstrap_cluster.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ASSETS_DIR=$1
1313
KIND_ASSETS_DIR="$1/kind/$(ls $1/kind | grep v)"
1414

1515
check_if_supported_os
16+
GUM_ASSETS_DIR="$ASSETS_DIR/gum/$(ls $ASSETS_DIR/gum | grep v)"
17+
sudo cp $GUM_ASSETS_DIR/gum_*/gum /usr/local/bin
1618

1719
# TODO: check if the bootstrap cluster already exist.
1820
rm -rf ~/.kube/config

05_install_decapod.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ case $TKS_ADMIN_CLUSTER_INFRA_PROVIDER in
320320
# BYOH
321321
curl -v --user tks_admin:$GIT_SVC_TOKEN -X DELETE $GIT_SVC_HTTP://${GIT_SVC_BASE_URL}/api/packages/decapod10/generic/byoh_hostagent/$BYOH_TKS_VERSION/byoh-hostagent-linux-amd64 || true
322322
curl -v --user tks_admin:$GIT_SVC_TOKEN --upload-file output/byoh-hostagent $GIT_SVC_HTTP://${GIT_SVC_BASE_URL}/api/packages/decapod10/generic/byoh_hostagent/$BYOH_TKS_VERSION/byoh-hostagent-linux-amd64
323+
curl -v --user tks_admin:$GIT_SVC_TOKEN -X DELETE $GIT_SVC_HTTP://${GIT_SVC_BASE_URL}/api/packages/decapod10/generic/imgpkg/$IMGPKG_VERSION/imgpkg || true
324+
curl -v --user tks_admin:$GIT_SVC_TOKEN --upload-file output/imgpkg $GIT_SVC_HTTP://${GIT_SVC_BASE_URL}/api/packages/decapod10/generic/imgpkg/$IMGPKG_VERSION/imgpkg
323325
;;
324326
esac
325327

@@ -337,8 +339,9 @@ kubectl create secret generic tks-admin-kubeconfig-secret -n argo --from-file=va
337339
kubectl delete secret byoh-hostagent-install-template -n argo || true
338340
cp templates/install_byoh_hostagent.sh.template templates/install_byoh_hostagent.sh.template.orig
339341
HOSTAGENT_CHECKSUM=$(sha1sum output/byoh-hostagent | awk '{print $1}')
340-
export HOSTAGENT_CHECKSUM BYOH_TKS_VERSION GIT_SVC_USERNAME GITEA_NODE_PORT GITEA_NODE_IP
341-
envsubst '$HOSTAGENT_CHECKSUM $BYOH_TKS_VERSION $GIT_SVC_USERNAME $GITEA_NODE_IP $GITEA_NODE_PORT' <templates/install_byoh_hostagent.sh.template.orig >templates/install_byoh_hostagent.sh.template
342+
IMGPKG_BIN_CHECKSUM=$(sha1sum output/imgpkg | awk '{print $1}')
343+
export HOSTAGENT_CHECKSUM IMGPKG_BIN_CHECKSUM BYOH_TKS_VERSION IMGPKG_VERSION GIT_SVC_USERNAME GITEA_NODE_PORT GITEA_NODE_IP
344+
envsubst '$HOSTAGENT_CHECKSUM $IMGPKG_BIN_CHECKSUM $BYOH_TKS_VERSION $IMGPKG_VERSION $GIT_SVC_USERNAME $GITEA_NODE_IP $GITEA_NODE_PORT' <templates/install_byoh_hostagent.sh.template.orig >templates/install_byoh_hostagent.sh.template
342345
kubectl create secret generic byoh-hostagent-install-template -n argo --from-file=agent-install-template=templates/install_byoh_hostagent.sh.template
343346

344347
log_info "...Done"

byoh_generate_script_for_host.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ envsubst '$BOOTSTRAP_KUBECONFIG $GITEA_NODE_IP $GITEA_NODE_PORT $GIT_SVC_USERNAM
9292
chmod +x $OUTPUT_SCRIPT_PATH
9393

9494
log_info "Copy below files to each host and run a script!"
95-
echo "$OUTPUT_SCRIPT_PATH output/byoh-hostagent"
95+
echo "$OUTPUT_SCRIPT_PATH output/byoh-hostagent output/imgpkg"

lib/versions.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ ARGOCD_APPS_CHART_VERSION="1.3.0"
55

66
CAPI_RELEASE="v1beta1"
77
case $CAPI_RELEASE in
8-
"v1beta1")
9-
CAPI_VERSION="v1.5.0"
10-
CAPA_VERSION="v2.2.1"
11-
BYOH_VERSION="v0.5.0"
12-
BYOH_TKS_VERSION="v0.4.0-tks-20231017"
13-
;;
8+
"v1beta1")
9+
CAPI_VERSION="v1.5.0"
10+
CAPA_VERSION="v2.2.1"
11+
BYOH_VERSION="v0.5.0"
12+
BYOH_TKS_VERSION="v0.5.0-tks-20240403"
13+
;;
1414
esac
1515

16+
IMGPKG_VERSION="v0.36.9"
17+
1618
KIND_NODE_IMAGE_TAG="v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8"

templates/install_byoh_hostagent.sh.template

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -e
33

44
BYOH_HOSTAGENT_BINARY_BASE_URL=http://${GITEA_NODE_IP}:${GITEA_NODE_PORT}/api/packages/${GIT_SVC_USERNAME}/generic/byoh_hostagent
55
BYOH_HOSTAGENT_CHECKSUM=${HOSTAGENT_CHECKSUM}
6+
IMGPKG_BINARY_BASE_URL=http://${GITEA_NODE_IP}:${GITEA_NODE_PORT}/api/packages/${GIT_SVC_USERNAME}/generic/imgpkg
7+
IMGPKG_CHECKSUM=${IMGPKG_BIN_CHECKSUM}
68
BOOTSTRAP_KUBECONFIG="${BOOTSTRAP_KUBECONFIG}"
79

810
check_if_supported_os() {
@@ -33,6 +35,8 @@ check_if_supported_os() {
3335
download_byoh_agent() {
3436
curl -L $BYOH_HOSTAGENT_BINARY_BASE_URL/${BYOH_TKS_VERSION}/byoh-hostagent-linux-amd64 -o byoh-hostagent
3537
echo "$BYOH_HOSTAGENT_CHECKSUM byoh-hostagent" | sha1sum --check
38+
curl -L $IMGPKG_BINARY_BASE_URL/${IMGPKG_VERSION}/imgpkg -o imgpkg
39+
echo "$IMGPKG_CHECKSUM imgpkg" | sha1sum --check
3640
}
3741

3842
prepare_rocky_byoh_node() {
@@ -70,8 +74,8 @@ prepare_byoh_node() {
7074
}
7175

7276
run_byoh_agent() {
73-
sudo cp byoh-hostagent /usr/local/bin/byoh-hostagent
74-
sudo chmod +x /usr/local/bin/byoh-hostagent
77+
sudo cp byoh-hostagent imgpkg /usr/local/bin/
78+
sudo chmod +x /usr/local/bin/byoh-hostagent /usr/local/bin/imgpkg
7579

7680
cat << EOF | sudo tee /etc/systemd/system/byoh-hostagent.service
7781
[Unit]

util/create_byoh-hostagent-install-template_secret.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ GITEA_NODE_IP=$(kubectl get no -ojsonpath='{.items[0].status.addresses[0].addres
99

1010
kubectl delete secret byoh-hostagent-install-template -n argo || true
1111
cp templates/install_byoh_hostagent.sh.template templates/install_byoh_hostagent.sh.template.orig
12-
HOSTAGENT_CHECKSUM=$(sha1sum output/byoh-hostagent-linux-amd64 | awk '{print $1}')
13-
export HOSTAGENT_CHECKSUM BYOH_TKS_VERSION GIT_SVC_USERNAME GITEA_NODE_PORT GITEA_NODE_IP
14-
envsubst '$HOSTAGENT_CHECKSUM $BYOH_TKS_VERSION $GIT_SVC_USERNAME $GITEA_NODE_IP $GITEA_NODE_PORT' < templates/install_byoh_hostagent.sh.template.orig > templates/install_byoh_hostagent.sh.template
12+
HOSTAGENT_CHECKSUM=$(sha1sum output/byoh-hostagent | awk '{print $1}')
13+
IMGPKG_BIN_CHECKSUM=$(sha1sum output/imgpkg | awk '{print $1}')
14+
export HOSTAGENT_CHECKSUM IMGPKG_BIN_CHECKSUM BYOH_TKS_VERSION IMGPKG_VERSION GIT_SVC_USERNAME GITEA_NODE_PORT GITEA_NODE_IP
15+
envsubst '$HOSTAGENT_CHECKSUM $IMGPKG_BIN_CHECKSUM $BYOH_TKS_VERSION $IMGPKG_VERSION $GIT_SVC_USERNAME $GITEA_NODE_IP $GITEA_NODE_PORT' < templates/install_byoh_hostagent.sh.template.orig > templates/install_byoh_hostagent.sh.template
1516
kubectl create secret generic byoh-hostagent-install-template -n argo --from-file=agent-install-template=templates/install_byoh_hostagent.sh.template

util/wait_for_all_pods_in_ns.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@ source $SCRIPT_DIR/../lib/log.sh
99
kubectl get ns $1 > /dev/null
1010
[ $? -eq 0 ] || log_error "namespace $1 is not exist"
1111

12+
i=0
13+
while true; do
14+
NUM_PODS=$(kubectl get po -n $1 --no-headers | wc -l)
15+
16+
[[ $NUM_PODS -eq 0 ]] || break
17+
[[ $i -lt 10 ]] || log_error "there is no pods in the $1 namespace"
18+
19+
((i++))
20+
sleep 2
21+
done
22+
1223
kubectl get po -n $1 -o jsonpath='{.items[*].metadata.name}' | xargs kubectl wait --for=condition=Ready -n $1 --timeout=600s po $po > /dev/null

0 commit comments

Comments
 (0)