@@ -62,25 +62,38 @@ urlencode() {
6262 LC_COLLATE=$old_lc_collate
6363}
6464
65+ # get_latest_github_release fetches the latest GitHub release tag matching a regex pattern.
66+ # Usage: get_latest_github_release <org/repo> <pattern>
67+ # org/repo - GitHub organization and repository (e.g. "helm/helm")
68+ # pattern - extended regex that the tag must match (e.g. "^v[0-9]+\.[0-9]+\.[0-9]+$")
69+ # The function automatically selects the mirror URL based on INSTALL_DRYCC_MIRROR.
70+ function get_latest_github_release {
71+ local repo=" $1 "
72+ local pattern=" $2 "
73+ local base_url
74+
75+ if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]]; then
76+ base_url=" https://github.com/${repo} "
77+ else
78+ base_url=" https://github.com/${repo} "
79+ fi
80+
81+ curl -Ls " ${base_url} /releases" \
82+ | grep -o " href=\" /${repo} /releases/tag/[^\" ]*\" " \
83+ | sed " s|href=\" /${repo} /releases/tag/||; s|\" $||" \
84+ | grep -E " ${pattern} " \
85+ | sort -Vr \
86+ | head -1
87+ }
88+
89+ # install_helm downloads and installs the Helm CLI tool from the latest GitHub release.
6590function install_helm {
6691 echo -e " \\ 033[32m---> Start install helm\\ 033[0m"
92+ version=$( get_latest_github_release " helm/helm" " ^v[0-9]+\.[0-9]+\.[0-9]+$" )
93+ tar_name=" helm-${version} -linux-${ARCH} .tar.gz"
6794 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
68- version=$( curl -Ls https://github.com/helm/helm/releases \
69- | grep -o ' href="/helm/helm/releases/tag/v[^"]*"' \
70- | sed ' s|href="/helm/helm/releases/tag/||; s/"$//' \
71- | grep -E ' ^v[0-9]+\.[0-9]+\.[0-9]+$' \
72- | sort -Vr \
73- | head -1)
74- tar_name=" helm-${version} -linux-${ARCH} .tar.gz"
7595 helm_download_url=" https://github.com/helm/${tar_name} "
7696 else
77- version=$( curl -Ls https://github.com/helm/helm/releases \
78- | grep -o ' href="/helm/helm/releases/tag/v[^"]*"' \
79- | sed ' s|href="/helm/helm/releases/tag/||; s/"$//' \
80- | grep -E ' ^v[0-9]+\.[0-9]+\.[0-9]+$' \
81- | sort -Vr \
82- | head -1)
83- tar_name=" helm-${version} -linux-${ARCH} .tar.gz"
8497 helm_download_url=" https://get.helm.sh/${tar_name} "
8598 fi
8699 curl -fsSL -o " ${tar_name} " " ${helm_download_url} "
@@ -90,6 +103,11 @@ function install_helm {
90103 echo -e " \\ 033[32m---> crun runtime install completed!\\ 033[0m"
91104}
92105
106+ # helm_upgrade wraps "helm upgrade --install" with retry logic and a default timeout.
107+ # Usage: helm_upgrade <release> <chart> [helm-options...]
108+ # HELM_MAX_RETRIES - max number of retry attempts (default: 3)
109+ # HELM_RETRY_INTERVAL - seconds between retries (default: 10)
110+ # A default timeout of 10m0s is applied unless --timeout is explicitly passed.
93111function helm_upgrade {
94112 local max_retries=${HELM_MAX_RETRIES:- 3}
95113 local retry_interval=${HELM_RETRY_INTERVAL:- 10}
@@ -117,6 +135,8 @@ function helm_upgrade {
117135 return 1
118136}
119137
138+ # configure_os tunes kernel parameters and OS settings for Kubernetes workloads.
139+ # Includes: iptables cleanup, swap disable, BPF mount, sysctl overrides, CPU governor.
120140function configure_os {
121141 echo -e " \\ 033[32m---> Start configuring kernel parameters\\ 033[0m"
122142 if [[ " $( command -v iptables) " != " " ]] ; then
@@ -150,20 +170,22 @@ EOF
150170 echo -e " \\ 033[32m---> Configuring kernel parameters finish\\ 033[0m"
151171}
152172
173+ # install_crun_runtime downloads and installs the crun OCI runtime binary.
153174function install_crun_runtime {
154175 echo -e " \\ 033[32m---> Start install crun runtime\\ 033[0m"
155176 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
156177 crun_base_url=" https://github.com/containers"
157178 else
158179 crun_base_url=" https://github.com/containers"
159180 fi
160- crun_version=$( curl -Ls ${crun_base_url} /crun/releases | grep / containers/crun/releases/tag/ | sed -E ' s/.*\/containers\/crun\/releases\/tag\/( [0-9\.]{1,} (-rc. [0-9]{1,})?)".*/\1/g ' | head -1 )
181+ crun_version=$( get_latest_github_release " containers/crun" " ^[0-9]+\. [0-9]+(\.[0-9]+)? (-rc[0-9]+)?$ " )
161182 crun_download_url=${crun_base_url} /crun/releases/download/${crun_version} /crun-${crun_version} -linux-${ARCH}
162183 curl -sfL " ${crun_download_url} " -o /usr/local/bin/crun
163184 chmod a+rx /usr/local/bin/crun
164185 echo -e " \\ 033[32m---> crun runtime install completed!\\ 033[0m"
165186}
166187
188+ # install_kata_runtime downloads and installs the Kata Containers runtime for VM-based isolation.
167189function install_kata_runtime {
168190 echo -e " \\ 033[32m---> Start install kata runtime\\ 033[0m"
169191 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
@@ -172,7 +194,7 @@ function install_kata_runtime {
172194 kata_base_url=" https://github.com/kata-containers"
173195 fi
174196
175- kata_version=$( curl -Ls ${kata_base_url} / kata-containers/releases | grep / kata-containers/kata-containers/releases/tag/ | sed -E ' s/.*\/kata-containers\/kata-containers\/releases\/tag\/( [0-9\.]{1,} (-rc. [0-9]{1,})?)".*/\1/g ' | head -1 )
197+ kata_version=$( get_latest_github_release " kata-containers/kata-containers" " ^[0-9]+\. [0-9]+\.[0-9]+ (-rc[0-9]+)?$ " )
176198 kata_package=kata-static-${kata_version} -${ARCH} .tar.zst
177199 kata_download_url=${kata_base_url} /kata-containers/releases/download/${kata_version} /${kata_package}
178200
@@ -185,6 +207,9 @@ function install_kata_runtime {
185207 echo -e " \\ 033[32m---> Kata runtime install completed!\\ 033[0m"
186208}
187209
210+ # install_runtime configures containerd runtimes based on CONTAINERD_RUNTIMES.
211+ # Supported values: "runc" (default), "crun", "kata". Multiple values can be comma-separated.
212+ # Generates the containerd config template and installs the selected runtimes.
188213function install_runtime {
189214 readarray -d , -t containerd_runtimes <<< " $CONTAINERD_RUNTIMES"
190215 if [[ " $CONTAINERD_RUNTIMES " =~ " crun" ]]; then
234259 done
235260}
236261
262+ # configure_registry writes container registry mirror configuration for k3s/containerd.
263+ # Only applies when INSTALL_DRYCC_MIRROR is set to "cn".
237264function configure_registry {
238265 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]]; then
239266 cat << EOF > "${REGISTRY_CONFIG_FILE} "
262289 fi
263290}
264291
292+ # configure_kubectl sets up kubectl defaults, enabling server-side apply by default.
265293function configure_kubectl {
266294 echo -e " \\ 033[32m---> Start configuring kubectl defaults\\ 033[0m"
267295 mkdir -p " $HOME /.kube"
279307 echo -e " \\ 033[32m---> Kubectl defaults configured (server-side apply enabled)\\ 033[0m"
280308}
281309
310+ # configure_k3s_mirrors selects the k3s install URL based on INSTALL_DRYCC_MIRROR.
282311function configure_k3s_mirrors {
283312 echo -e " \\ 033[32m---> Start configuring k3s mirrors\\ 033[0m"
284313 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
@@ -291,6 +320,9 @@ function configure_k3s_mirrors {
291320 echo -e " \\ 033[32m---> Configuring k3s mirrors finish\\ 033[0m"
292321}
293322
323+ # install_k3s_server installs and bootstraps a k3s server (control plane) node.
324+ # Configures OS, runtimes, kubectl, registry mirrors, then installs k3s with
325+ # embedded registry, Cilium CNI, and registers RuntimeClass resources.
294326function install_k3s_server {
295327 configure_os
296328 install_runtime
319351 done
320352}
321353
354+ # install_k3s_agent installs and joins a k3s agent (worker) node to an existing cluster.
322355function install_k3s_agent {
323356 configure_os
324357 install_runtime
@@ -331,6 +364,9 @@ function install_k3s_agent {
331364 curl -sfL " ${k3s_install_url} " | INSTALL_K3S_EXEC=" $INSTALL_K3S_EXEC " sh -s -
332365}
333366
367+ # install_longhorn deploys Longhorn distributed block storage via Helm.
368+ # Usage: install_longhorn [helm-options...]
369+ # LONGHORN_CONFIG_FILE - path to a custom Helm values file; uses defaults if unset.
334370function install_longhorn {
335371 options=${1:- " " }
336372 helm repo add longhorn https://github.com/longhorn-charts
@@ -353,22 +389,13 @@ function install_longhorn {
353389 echo -e " \\ 033[32m---> Longhorn install completed!\\ 033[0m"
354390}
355391
392+ # install_mountpoint deploys the AWS Mountpoint S3 CSI driver via Helm.
356393function install_mountpoint {
357394 options=${1:- " " }
358395 helm repo add aws-mountpoint-s3-csi-driver https://github.com/mountpoint-charts
359396 helm repo update
360397
361- if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
362- mountpoint_api_url=https://github.com/drycc/mountpoint-s3-csi-driver
363- else
364- mountpoint_api_url=https://github.com/drycc/mountpoint-s3-csi-driver
365- fi
366- version=$( curl -Ls $mountpoint_api_url /releases| grep /drycc/mountpoint-s3-csi-driver/releases/tag/\
367- | grep -o ' href="/drycc/mountpoint-s3-csi-driver/releases/tag/[^"]*"' \
368- | sed ' s|href="/drycc/mountpoint-s3-csi-driver/releases/tag/||; s/"$//' \
369- | grep -E ' ^v[0-9]+\.[0-9]+\.[0-9]+$' \
370- | sort -Vr \
371- | head -1)
398+ version=$( get_latest_github_release " drycc/mountpoint-s3-csi-driver" " ^v[0-9]+\.[0-9]+\.[0-9]+$" )
372399 helm_upgrade aws-mountpoint-s3-csi-driver aws-mountpoint-s3-csi-driver/aws-mountpoint-s3-csi-driver \
373400 --set supportLegacySystemDMounts=false \
374401 --set image.repository=registry.drycc.cc/drycc/mountpoint-s3-csi-driver \
@@ -377,15 +404,18 @@ function install_mountpoint {
377404 echo -e " \\ 033[32m---> Mountpoint install completed!\\ 033[0m"
378405}
379406
407+ # check_metallb validates that METALLB_CONFIG_FILE exists if it is set.
380408function check_metallb {
381409 if [[ " ${METALLB_CONFIG_FILE} " && ! -f " ${METALLB_CONFIG_FILE} " ]] ; then
382410 echo -e " \\ 033[33m---> The path ${METALLB_CONFIG_FILE} does not exist...\\ 033[0m"
383411 exit 1
384412 fi
385413}
386414
387- # Best practices
415+ # install_network deploys Cilium as the CNI with kube-proxy replacement and BPF masquerade.
416+ # Usage: install_network [helm-options...]
388417#
418+ # Best practices for production optimization:
389419# 1. Jumbo frames, change MTU(9000).
390420# 2. Big tcp, enableIPv6BIGTCP/enableIPv4BIGTCP.
391421# 3. Set `routingMode=native` and `ipv4NativeRoutingCIDR`.
@@ -418,6 +448,10 @@ function install_network() {
418448 echo -e " \\ 033[32m---> Network install completed!\\ 033[0m"
419449}
420450
451+ # install_metallb deploys MetalLB for LoadBalancer service support with L2 advertisement.
452+ # Usage: install_metallb [helm-options...]
453+ # METALLB_CONFIG_FILE - path to a custom IPAddressPool/L2Advertisement manifest;
454+ # uses a default 192.168.254.0/24 pool if unset.
421455function install_metallb() {
422456 check_metallb
423457 options=${1:- " " }
454488 echo -e " \\ 033[32m---> Metallb install completed!\\ 033[0m"
455489}
456490
491+ # install_gateway deploys the Istio Gateway API and Istio ingress gateway.
492+ # Installs: Gateway API CRDs, istio-base, istiod, and istio-gateway.
493+ # Usage: install_gateway [helm-options...]
457494function install_gateway() {
458495 options=${1:- " " }
459496 echo -e " \\ 033[32m---> Start install gateway...\\ 033[0m"
@@ -462,7 +499,7 @@ function install_gateway() {
462499 else
463500 gateway_api_url=https://github.com/kubernetes-sigs/gateway-api
464501 fi
465- version=$( curl -Ls $gateway_api_url /releases | grep / kubernetes-sigs/gateway-api/releases/tag/ | sed -E ' s/.*\/kubernetes-sigs\/gateway-api\/releases\/tag\/(v [0-9\.]{1,} (-rc. [0-9]{1,})?)".*/\1/g ' | head -1 )
502+ version=$( get_latest_github_release " kubernetes-sigs/gateway-api" " ^v[0-9]+\. [0-9]+\.[0-9]+ (-rc[0-9]+)?$ " )
466503
467504 helm repo add istio https://github.com/istio-charts
468505 helm repo update
@@ -478,6 +515,8 @@ function install_gateway() {
478515 echo -e " \\ 033[32m---> Gateway install completed!\\ 033[0m"
479516}
480517
518+ # install_cert_manager deploys cert-manager with Gateway API support enabled.
519+ # Usage: install_cert_manager [helm-options...]
481520function install_cert_manager() {
482521 options=${1:- " " }
483522 echo -e " \\ 033[32m---> Start install cert-manager...\\ 033[0m"
@@ -490,15 +529,13 @@ function install_cert_manager() {
490529 echo -e " \\ 033[32m---> Cert-manager install completed!\\ 033[0m"
491530}
492531
532+ # install_catalog deploys the Kubernetes Service Catalog via Helm.
533+ # Uses the "canary" image by default; fetches the latest stable version when CHANNEL is "stable".
534+ # Usage: install_catalog [helm-options...]
493535function install_catalog() {
494536 service_catalog_version=" canary"
495537 if [[ " $CHANNEL " == " stable" ]]; then
496- if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
497- service_catalog_url=https://github.com/drycc-addons/service-catalog
498- else
499- service_catalog_url=https://github.com/drycc-addons/service-catalog
500- fi
501- service_catalog_version=$( curl -Ls $service_catalog_url /releases| grep /drycc-addons/service-catalog/releases/tag/ | sed -E ' s/.*\/drycc-addons\/service-catalog\/releases\/tag\/(v[0-9\.]{1,}(-rc.[0-9]{1,})?)".*/\1/g' | head -1)
538+ service_catalog_version=$( get_latest_github_release " drycc-addons/service-catalog" " ^v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?$" )
502539 fi
503540
504541 options=${1:- " " }
@@ -511,6 +548,8 @@ function install_catalog() {
511548 echo -e " \\ 033[32m---> Catalog install completed!\\ 033[0m"
512549}
513550
551+ # install_components installs all infrastructure components in order:
552+ # network (Cilium), metallb, gateway (Istio), cert-manager, catalog.
514553function install_components {
515554 install_network
516555 install_metallb
@@ -519,6 +558,8 @@ function install_components {
519558 install_catalog
520559}
521560
561+ # check_drycc validates that required environment variables are set before installing workflow.
562+ # Requires: PLATFORM_DOMAIN, DRYCC_ADMIN_USERNAME, DRYCC_ADMIN_PASSWORD.
522563function check_drycc {
523564 if [[ -z " ${PLATFORM_DOMAIN} " ]] ; then
524565 echo -e " \\ 033[33m---> Please set the PLATFORM_DOMAIN variable.\\ 033[0m"
@@ -541,16 +582,16 @@ function check_drycc {
541582 fi
542583}
543584
585+ # install_drycc deploys the Drycc Workflow platform via Helm.
586+ # Usage: install_drycc [helm-options...]
587+ # Requires: PLATFORM_DOMAIN, DRYCC_ADMIN_USERNAME, DRYCC_ADMIN_PASSWORD.
588+ # Optional: VICTORIAMETRICS_CONFIG_FILE - path to custom VictoriaMetrics values file.
544589function install_drycc {
545590 check_drycc
546591 options=${1:- " " }
547592 echo -e " \\ 033[32m---> Start install workflow...\\ 033[0m"
548593 if [[ " $CHANNEL " == " stable" ]]; then
549- if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
550- FILER_VERSION=$( curl -Ls https://github.com/drycc/filer/releases| grep /drycc/filer/releases/tag/ | sed -E ' s/.*\/drycc\/filer\/releases\/tag\/(v[0-9\.]{1,}(-rc.[0-9]{1,})?)".*/\1/g' | head -1)
551- else
552- FILER_VERSION=$( curl -Ls https://github.com/drycc/filer/releases| grep /drycc/filer/releases/tag/ | sed -E ' s/.*\/drycc\/filer\/releases\/tag\/(v[0-9\.]{1,}(-rc.[0-9]{1,})?)".*/\1/g' | head -1)
553- fi
594+ FILER_VERSION=$( get_latest_github_release " drycc/filer" " ^v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?$" )
554595 FILER_IMAGE=${DRYCC_REGISTRY} /drycc/filer:$( sed ' s#v##' <<< $FILER_VERSION )
555596 FILER_IMAGE_PULL_POLICY=" IfNotPresent"
556597 else
703744 echo -e " \\ 033[32m---> Workflow install completed!\\ 033[0m"
704745}
705746
747+ # install_helmbroker deploys the Helm Broker and registers it as a ClusterServiceBroker.
748+ # Usage: install_helmbroker [helm-options...]
749+ # HELMBROKER_USERNAME - override the auto-generated broker username
750+ # HELMBROKER_PASSWORD - override the auto-generated broker password
706751function install_helmbroker {
707752 if [[ " ${INSTALL_DRYCC_MIRROR} " == " cn" ]] ; then
708753 addons_base_url=" https://github.com/drycc-addons/addons"
@@ -711,11 +756,8 @@ function install_helmbroker {
711756 fi
712757 version=" latest"
713758 if [[ " $CHANNEL " == " stable" ]]; then
714- for version in $( curl -Ls " ${addons_base_url} " /releases| grep /drycc-addons/addons/releases/tag/ | sed -E ' s/.*\/drycc-addons\/addons\/releases\/tag\/(v[0-9]{1,})".*/\1/g' ) ; do
715- if [[ " $version " != " latest" ]]; then
716- break
717- fi
718- done
759+ version=$( get_latest_github_release " drycc-addons/addons" " ^v[0-9]+$" )
760+ version=${version:- latest}
719761 fi
720762 addons_url=" ${addons_base_url} /releases/download/${version} /index.yaml"
721763
767809 echo -e " \\ 033[32m---> Helmbroker install completed!\\ 033[0m"
768810}
769811
812+ # upgrade upgrades all installed components using --reset-then-reuse-values to preserve
813+ # previous Helm values while applying new chart defaults.
770814function upgrade {
771815 install_network --reset-then-reuse-values
772816 install_metallb --reset-then-reuse-values
0 commit comments