-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[CKS] script to generate cks images with cilium as default CNI #12619
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,265 @@ | ||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||
| # Licensed to the Apache Software Foundation (ASF) under one | ||||||||||||||||||
| # or more contributor license agreements. See the NOTICE file | ||||||||||||||||||
| # distributed with this work for additional information | ||||||||||||||||||
| # regarding copyright ownership. The ASF licenses this file | ||||||||||||||||||
| # to you under the Apache License, Version 2.0 (the | ||||||||||||||||||
| # "License"); you may not use this file except in compliance | ||||||||||||||||||
| # with the License. You may obtain a copy of the License at | ||||||||||||||||||
| # | ||||||||||||||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||
| # | ||||||||||||||||||
| # Unless required by applicable law or agreed to in writing, | ||||||||||||||||||
| # software distributed under the License is distributed on an | ||||||||||||||||||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||||||||||||||||
| # KIND, either express or implied. See the License for the | ||||||||||||||||||
| # specific language governing permissions and limitations | ||||||||||||||||||
| # under the License. | ||||||||||||||||||
|
|
||||||||||||||||||
| set -e | ||||||||||||||||||
|
|
||||||||||||||||||
| if [ $# -lt 8 ]; then | ||||||||||||||||||
| echo "============================================================================================================" | ||||||||||||||||||
| echo "CloudStack Kubernetes Service (CKS) - ISO Creation Script with Cilium" | ||||||||||||||||||
| echo "============================================================================================================" | ||||||||||||||||||
| echo "" | ||||||||||||||||||
| echo "This script creates an ISO image containing Kubernetes binaries and dependencies for CKS with Cilium CNI." | ||||||||||||||||||
| echo "" | ||||||||||||||||||
| echo "Usage:" | ||||||||||||||||||
| echo " ./create-kubernetes-binaries-iso-with-cilium.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION BUILD_NAME ARCH ETCD_VERSION CILIUM_VERSION" | ||||||||||||||||||
| echo "" | ||||||||||||||||||
| echo "Parameters:" | ||||||||||||||||||
| echo " OUTPUT_PATH - Directory where the ISO file will be saved (e.g., ./ or /tmp/)" | ||||||||||||||||||
| echo " KUBERNETES_VERSION - Kubernetes version without 'v' prefix (e.g., 1.35.0)" | ||||||||||||||||||
| echo " CNI_VERSION - CNI Plugins version without 'v' prefix (e.g., 1.9.0)" | ||||||||||||||||||
| echo " CRICTL_VERSION - CRI Tools version without 'v' prefix (e.g., 1.35.0)" | ||||||||||||||||||
| echo " BUILD_NAME - Name for the output ISO file without extension (e.g., cks-v1.35.0)" | ||||||||||||||||||
| echo " ARCH - Target architecture: amd64, x86_64, arm64, or aarch64" | ||||||||||||||||||
| echo " ETCD_VERSION - etcd version without 'v' prefix (e.g., 3.6.7)" | ||||||||||||||||||
| echo " CILIUM_VERSION - Cilium version without 'v' prefix (e.g., 1.19.0)" | ||||||||||||||||||
| echo "" | ||||||||||||||||||
| echo "Example:" | ||||||||||||||||||
| echo " ./create-kubernetes-binaries-iso-with-cilium.sh ./ 1.35.0 1.9.0 1.35.0 cks-v1.35.0 amd64 3.6.7 1.19.0" | ||||||||||||||||||
| echo "" | ||||||||||||||||||
| echo "Output:" | ||||||||||||||||||
| echo " The script will generate: cks-v1.35.0-x86_64.iso (or cks-v1.35.0-aarch64.iso for ARM)" | ||||||||||||||||||
| echo "============================================================================================================" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| ARCH="amd64" | ||||||||||||||||||
| ARCH_SUFFIX="x86_64" | ||||||||||||||||||
| if [ "${6}" = "x86_64" ] || [ "${6}" = "amd64" ]; then | ||||||||||||||||||
| ARCH="amd64" | ||||||||||||||||||
| ARCH_SUFFIX="x86_64" | ||||||||||||||||||
| elif [ "${6}" = "aarch64" ] || [ "${6}" = "arm64" ]; then | ||||||||||||||||||
| ARCH="arm64" | ||||||||||||||||||
| ARCH_SUFFIX="aarch64" | ||||||||||||||||||
| else | ||||||||||||||||||
| echo "ERROR: ARCH must be 'x86_64' or 'aarch64'." | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| RELEASE="v${2}" | ||||||||||||||||||
| VAL="1.18.0" | ||||||||||||||||||
| output_dir="${1}" | ||||||||||||||||||
| start_dir="$PWD" | ||||||||||||||||||
| iso_dir=$(mktemp -d) | ||||||||||||||||||
| trap 'rm -rf "${iso_dir}"' EXIT | ||||||||||||||||||
| working_dir="${iso_dir}/" | ||||||||||||||||||
| if [ -n "${5}" ]; then | ||||||||||||||||||
| build_name="${5}-${ARCH_SUFFIX}.iso" | ||||||||||||||||||
| else | ||||||||||||||||||
| build_name="setup-${RELEASE}-${ARCH_SUFFIX}.iso" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| CNI_VERSION="v${3}" | ||||||||||||||||||
| echo "Downloading CNI ${CNI_VERSION}..." | ||||||||||||||||||
| cni_dir="${working_dir}/cni/" | ||||||||||||||||||
| mkdir -p "${cni_dir}" | ||||||||||||||||||
| if ! curl -sSf -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-${ARCH}.tgz" 2>/dev/null; then | ||||||||||||||||||
| echo "Primary CNI URL failed, trying legacy URL format..." | ||||||||||||||||||
| if ! curl -sSf -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-${ARCH}-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-${ARCH}.tgz"; then | ||||||||||||||||||
| echo "ERROR: Failed to download CNI plugins ${CNI_VERSION} for ${ARCH} from both URL formats." | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| CRICTL_VERSION="v${4}" | ||||||||||||||||||
| echo "Downloading CRI tools ${CRICTL_VERSION}..." | ||||||||||||||||||
| crictl_dir="${working_dir}/cri-tools/" | ||||||||||||||||||
| mkdir -p "${crictl_dir}" | ||||||||||||||||||
| curl -sS -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" -o "${crictl_dir}/crictl-linux-${ARCH}.tar.gz" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "Downloading Kubernetes tools ${RELEASE}..." | ||||||||||||||||||
| k8s_dir="${working_dir}/k8s" | ||||||||||||||||||
| mkdir -p "${k8s_dir}" | ||||||||||||||||||
| cd "${k8s_dir}" | ||||||||||||||||||
| curl -sS -L --remote-name-all https://dl.k8s.io/release/"${RELEASE}"/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl} | ||||||||||||||||||
| kubeadm_file_permissions=$(stat --format '%a' kubeadm) | ||||||||||||||||||
| chmod +x kubeadm | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "Downloading kubelet.service ${RELEASE}..." | ||||||||||||||||||
| cd "${start_dir}" | ||||||||||||||||||
| kubelet_service_file="${working_dir}/kubelet.service" | ||||||||||||||||||
| touch "${kubelet_service_file}" | ||||||||||||||||||
| if [[ $(echo "${2} $VAL" | awk '{print ($1 < $2)}') == 1 ]]; then | ||||||||||||||||||
| curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > "${kubelet_service_file}" | ||||||||||||||||||
|
Comment on lines
+106
to
+107
|
||||||||||||||||||
| else | ||||||||||||||||||
| curl -sSL "https://raw.githubusercontent.com/shapeblue/cloudstack-nonoss/main/cks/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > "${kubelet_service_file}" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
Comment on lines
+106
to
+110
|
||||||||||||||||||
|
|
||||||||||||||||||
| echo "Downloading 10-kubeadm.conf ${RELEASE}..." | ||||||||||||||||||
| kubeadm_conf_file="${working_dir}/10-kubeadm.conf" | ||||||||||||||||||
| touch "${kubeadm_conf_file}" | ||||||||||||||||||
| if [[ $(echo "${2} $VAL" | awk '{print ($1 < $2)}') == 1 ]]; then | ||||||||||||||||||
| curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > "${kubeadm_conf_file}" | ||||||||||||||||||
| else | ||||||||||||||||||
| curl -sSL "https://raw.githubusercontent.com/shapeblue/cloudstack-nonoss/main/cks/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > "${kubeadm_conf_file}" | ||||||||||||||||||
| fi | ||||||||||||||||||
|
Comment on lines
+106
to
+119
|
||||||||||||||||||
|
|
||||||||||||||||||
| AUTOSCALER_URL="https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/cloudstack/examples/cluster-autoscaler-standard.yaml" | ||||||||||||||||||
| echo "Downloading kubernetes cluster autoscaler ${AUTOSCALER_URL}" | ||||||||||||||||||
| autoscaler_conf_file="${working_dir}/autoscaler.yaml" | ||||||||||||||||||
| curl -sSL "${AUTOSCALER_URL}" -o "${autoscaler_conf_file}" | ||||||||||||||||||
|
|
||||||||||||||||||
| PROVIDER_URL="https://raw.githubusercontent.com/apache/cloudstack-kubernetes-provider/main/deployment.yaml" | ||||||||||||||||||
| echo "Downloading kubernetes cluster provider ${PROVIDER_URL}" | ||||||||||||||||||
| provider_conf_file="${working_dir}/provider.yaml" | ||||||||||||||||||
| curl -sSL "${PROVIDER_URL}" -o "${provider_conf_file}" | ||||||||||||||||||
|
|
||||||||||||||||||
| CILIUM_VERSION="${8}" | ||||||||||||||||||
| echo "Generating Cilium ${CILIUM_VERSION} manifest..." | ||||||||||||||||||
| network_conf_file="${working_dir}/network.yaml" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Check if helm is installed | ||||||||||||||||||
| if ! command -v helm > /dev/null 2>&1; then | ||||||||||||||||||
| echo "ERROR: Helm is required to generate Cilium manifests. Please install Helm first." | ||||||||||||||||||
| echo "Visit: https://helm.sh/docs/intro/install/" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| helm repo add cilium https://helm.cilium.io/ > /dev/null 2>&1 || true | ||||||||||||||||||
|
||||||||||||||||||
| helm repo add cilium https://helm.cilium.io/ > /dev/null 2>&1 || true | |
| # Add the Cilium Helm repository only if it is not already configured | |
| if ! helm repo list 2>/dev/null | awk 'NR>1 {print $1}' | grep -qx "cilium"; then | |
| helm repo add cilium https://helm.cilium.io/ > /dev/null 2>&1 | |
| fi |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RedHat install path downloads a container-selinux RPM from a CentOS 7 x86_64 URL. This will fail (and possibly install an incompatible package) on aarch64/arm64, even though the script advertises arm support. Consider selecting the correct arch/repo or using distro-provided packages/repos instead of a hard-coded x86_64 RPM URL.
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This curl -sS -L download won’t fail the script on HTTP errors (e.g., 404/500) because --fail isn’t used; the ISO could be generated with an HTML error page instead of the etcd tarball. Add --fail/--fail-with-body (and optionally validate the archive) so the script reliably stops on download problems.
| curl -sS -L "https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz" -o "${etcd_dir}/etcd-linux-${ARCH}.tar.gz" | |
| curl -sS -L --fail "https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz" -o "${etcd_dir}/etcd-linux-${ARCH}.tar.gz" | |
| # Validate that the downloaded etcd archive is a valid tar.gz | |
| if ! tar -tzf "${etcd_dir}/etcd-linux-${ARCH}.tar.gz" > /dev/null; then | |
| echo "ERROR: Downloaded etcd archive is invalid or corrupted." | |
| exit 1 | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mkisofs -o "${output_dir}/${build_name}" -J -R -l "${iso_dir}" | |
| mkisofs -o "${output_dir}/${build_name}" -J -R -l "${iso_dir}" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ARCH validation error message is inconsistent with the accepted values. The script accepts
amd64/arm64as aliases, but the error only mentionsx86_64/aarch64, which can confuse users troubleshooting invalid input. Update the message (and/or the usage text) to reflect all accepted values.