mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CKS Enhancements: * Ability to specify different compute or service offerings for different types of CKS cluster nodes – worker, master or etcd * Ability to use CKS ready custom templates for CKS cluster nodes * Add and Remove external nodes to and from a kubernetes cluster Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Update remove node timeout global setting * CKS/NSX : Missing variables in worker nodes * CKS: Fix ISO attach logic * CKS: Fix ISO attach logic * address comment * Fix Port - Node mapping when cluster is scaled in the presence of external node(s) * CKS: Externalize control and worker node setup wait time and installation attempts * Fix logger * Add missing headers and fix end of line on files * CKS Mark Nodes for Manual Upgrade and Filter Nodes to add to CKS cluster from the same network * Add support to deploy CKS cluster nodes on hosts dedicated to a domain --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * Support unstacked ETCD --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Fix CKS cluster scaling and minor UI improvement * Reuse k8s cluster public IP for etcd nodes and rename etcd nodes * Fix DNS resolver issue * Update UDP active monitor to ICMP * Add hypervisor type to CKS cluster creation to fix CKS cluster creation when External hosts added * Fix build * Fix logger * Modify hypervisor param description in the create CKS cluster API * CKS delete fails when external nodes are present * CKS delete fails when external nodes are present * address comment * Improve network rules cleanup on failure adding external nodes to CKS cluster * UI: Fix etcd template was not honoured * UI: Fix etcd template was not honoured * Refactor * CKS: Exclude etcd nodes when calculating port numbers * Fix network cleanup in case of CKS cluster failure * Externalize retries and inverval for NSX segment deletion * Fix CKS scaling when external node(s) present in the cluster * CKS: Fix port numbers displayed against ETCD nodes * Add node version details to every node of k8s cluster - as we now support manual upgrade * Add node version details to every node of k8s cluster - as we now support manual upgrade * update column name * CKS: Exclude etcd nodes when calculating port numbers * update param name * update param * UI: Fix CKS cluster creation templates listing for non admins * CKS: Prevent etcd node start port number to coincide with k8s cluster start port numbers * CKS: Set default kubernetes cluster node version to the kubernetes cluster version on upgrade * CKS: Set default kubernetes cluster node version to the kubernetes cluster version on upgrade * consolidate query * Fix upgrade logic --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Fix CKS cluster version upgrade * CKS: Fix etcd port numbers being skipped * Fix CKS cluster with etcd nodes on VPC * Move schema and upgrade for 4.20 * Fix logger * Fix after rebasing * Add support for using different CNI plugins with CKS * Add support for using different CNI plugins with CKS * remove unused import * Add UI support and list cni config API * necessary UI changes * add license * changes to support external cni * UI changes * Fix NPE on restarting VPC with additional public IPs * fix merge conflict * add asnumber to create k8s svc layer * support cni framework to use as-numbers * update code * condition to ignore undefined jinja template variables * CKS: Do not pass AS number when network ID is passed * Fix deletion of Userdata / CNI Configuration in projects * CKS: Add CNI configuration details to the response and UI * Explicit events for registering cni configuration * Add Delete cni configuration API * Fix CKS deployment when using VPC tiers with custom ACLs * Fix DNS list on VR * CKS: Use Network offering of the network passed during CKS cluster creation to get the AS number * CKS cluster with guest IP * Fix: Use control node guest IP as join IP for external nodes addition * Fix DNS resolver issue * Improve etcd indexing - start from 1 * CKS: Add external node to a CKS cluster deployed with etcd node(s) successfully * CKS: Add external node to a CKS cluster deployed with etcd node(s) successfully * simplify logic * Tweak setup-kube-system script for baremetal external nodes * Consider cordoned nodes while getting ready nodes * Fix CKS cluster scale calculations * Set token TTL to 0 (no expire) for external etcd * Fix missing quotes * Fix build * Revert PR 9133 * Add calico commands for ens35 interface * Address review comments: plan CKS cluster deployment based on the node type * Add qemu-guest-agent dependency for kvm based templates * Add marvin test for CKS clusters with different offerings per node type * Remove test tag * Add marvin test and fix update template for cks and since annotations * Fix marvin test for adding and removing external nodes * Fix since version on API params * Address review comments * Fix unit test * Address review comments * UI: Make CKS public templates visible to non-admins on CKS cluster creation * Fix linter * Fix merge error * Fix positional parameters on the create kubernetes ISO script and make the ETCD version optional * fix etcd port displayed * Further improvements to CKS (#118) * Multiple nics support on Ubuntu template * Multiple nics support on Ubuntu template * supports allocating IP to the nic when VM is added to another network - no delay * Add option to select DNS or VR IP as resolver on VPC creation * Add API param and UI to select option * Add column on vpc and pass the value on the databags for CsDhcp.py to fix accordingly * Externalize the CKS Configuration, so that end users can tweak the configuration before deploying the cluster * Add new directory to c8 packaging for CKS config * Remove k8s configuration from resources and make it configurable * Revert "Remove k8s configuration from resources and make it configurable" This reverts commit d5997033ebe4ba559e6478a64578b894f8e7d3db. * copy conf to mgmt server and consume them from there * Remove node from cluster * Add missing /opt/bin directory requrired by external nodes * Login to a specific Project view * add indents * Fix CKS HA clusters * Fix build --------- Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com> * Add missing headers * Fix linter * Address more review comments * Fix unit test * Fix scaling case for the same offering * Revert "Login to a specific Project view" This reverts commit 95e37563f48573780b07a038a7f48c0bc04e9b64. * Revert "Fix CKS HA clusters" (#120) This reverts commit 8dac16aa359faa6500ea1e1ce548169cfd08331a. * Apply suggestions from code review about user data Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * Update api/src/main/java/org/apache/cloudstack/api/command/user/userdata/BaseRegisterUserDataCmd.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com> * Refactor column names and schema path * Fix scaling for non existing previous offering per node type * Update node offering entry if there was an existing offering but a global service offering has been provided on scale --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> Co-authored-by: Daan Hoogland <daan@onecht.net> Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
162 lines
7.2 KiB
Bash
Executable File
162 lines
7.2 KiB
Bash
Executable File
#!/bin/bash -x
|
|
# 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 6 ]; then
|
|
echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG BUILD_NAME [ETCD_VERSION]"
|
|
echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml setup-v1.11.4 3.5.1"
|
|
exit 1
|
|
fi
|
|
|
|
RELEASE="v${2}"
|
|
VAL="1.18.0"
|
|
output_dir="${1}"
|
|
start_dir="$PWD"
|
|
iso_dir="/tmp/iso"
|
|
working_dir="${iso_dir}/"
|
|
mkdir -p "${working_dir}"
|
|
build_name="${7}.iso"
|
|
[ -z "${build_name}" ] && build_name="setup-${RELEASE}.iso"
|
|
|
|
CNI_VERSION="v${3}"
|
|
echo "Downloading CNI ${CNI_VERSION}..."
|
|
cni_dir="${working_dir}/cni/"
|
|
mkdir -p "${cni_dir}"
|
|
cni_status_code=$(curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-amd64-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-amd64.tgz")
|
|
if [[ ${cni_status_code} -eq 404 ]] ; then
|
|
curl -L --write-out "%{http_code}\n" "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" -o "${cni_dir}/cni-plugins-amd64.tgz"
|
|
fi
|
|
|
|
CRICTL_VERSION="v${4}"
|
|
echo "Downloading CRI tools ${CRICTL_VERSION}..."
|
|
crictl_dir="${working_dir}/cri-tools/"
|
|
mkdir -p "${crictl_dir}"
|
|
curl -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz" -o "${crictl_dir}/crictl-linux-amd64.tar.gz"
|
|
|
|
echo "Downloading Kubernetes tools ${RELEASE}..."
|
|
k8s_dir="${working_dir}/k8s"
|
|
mkdir -p "${k8s_dir}"
|
|
cd "${k8s_dir}"
|
|
curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/amd64/{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}
|
|
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
|
|
|
|
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
|
|
|
|
NETWORK_CONFIG_URL="${5}"
|
|
echo "Downloading network config ${NETWORK_CONFIG_URL}"
|
|
network_conf_file="${working_dir}/network.yaml"
|
|
curl -sSL ${NETWORK_CONFIG_URL} -o ${network_conf_file}
|
|
|
|
DASHBORAD_CONFIG_URL="${6}"
|
|
echo "Downloading dashboard config ${DASHBORAD_CONFIG_URL}"
|
|
dashboard_conf_file="${working_dir}/dashboard.yaml"
|
|
curl -sSL ${DASHBORAD_CONFIG_URL} -o ${dashboard_conf_file}
|
|
|
|
# TODO : Change the url once merged
|
|
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}
|
|
|
|
echo "Fetching k8s docker images..."
|
|
ctr -v
|
|
if [ $? -ne 0 ]; then
|
|
echo "Installing containerd..."
|
|
if [ -f /etc/redhat-release ]; then
|
|
sudo yum -y remove docker-common docker container-selinux docker-selinux docker-engine
|
|
sudo yum -y install lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs
|
|
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm
|
|
sudo yum install -y containerd.io
|
|
elif [ -f /etc/lsb-release ]; then
|
|
sudo apt update && sudo apt install containerd.io -y
|
|
fi
|
|
sudo systemctl enable containerd && sudo systemctl start containerd
|
|
fi
|
|
mkdir -p "${working_dir}/docker"
|
|
output=`${k8s_dir}/kubeadm config images list --kubernetes-version=${RELEASE}`
|
|
|
|
# Don't forget about the yaml images !
|
|
for i in ${network_conf_file} ${dashboard_conf_file}
|
|
do
|
|
images=`grep "image:" $i | cut -d ':' -f2- | tr -d ' ' | tr -d "'"`
|
|
output=`printf "%s\n" ${output} ${images}`
|
|
done
|
|
|
|
# Don't forget about the other image !
|
|
autoscaler_image=`grep "image:" ${autoscaler_conf_file} | cut -d ':' -f2- | tr -d ' '`
|
|
output=`printf "%s\n" ${output} ${autoscaler_image}`
|
|
|
|
provider_image=`grep "image:" ${provider_conf_file} | cut -d ':' -f2- | tr -d ' '`
|
|
output=`printf "%s\n" ${output} ${provider_image}`
|
|
|
|
while read -r line; do
|
|
echo "Downloading image $line ---"
|
|
if [[ $line == kubernetesui* ]] || [[ $line == apache* ]] || [[ $line == weaveworks* ]]; then
|
|
line="docker.io/${line}"
|
|
fi
|
|
sudo ctr image pull "$line"
|
|
image_name=`echo "$line" | grep -oE "[^/]+$"`
|
|
sudo ctr image export "${working_dir}/docker/$image_name.tar" "$line"
|
|
sudo ctr image rm "$line"
|
|
done <<< "$output"
|
|
|
|
echo "Restore kubeadm permissions..."
|
|
if [ -z "${kubeadm_file_permissions}" ]; then
|
|
kubeadm_file_permissions=644
|
|
fi
|
|
chmod ${kubeadm_file_permissions} "${working_dir}/k8s/kubeadm"
|
|
|
|
echo "Updating imagePullPolicy to IfNotPresent in yaml files..."
|
|
sed -i "s/imagePullPolicy:.*/imagePullPolicy: IfNotPresent/g" ${working_dir}/*.yaml
|
|
|
|
if [ -n "${8}" ]; then
|
|
# Install etcd dependencies
|
|
etcd_dir="${working_dir}/etcd"
|
|
mkdir -p "${etcd_dir}"
|
|
ETCD_VERSION=v${8}
|
|
wget -q --show-progress "https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" -O ${etcd_dir}/etcd-linux-amd64.tar.gz
|
|
fi
|
|
|
|
mkisofs -o "${output_dir}/${build_name}" -J -R -l "${iso_dir}"
|
|
|
|
rm -rf "${iso_dir}"
|