Adding Cert sans to kubeadm config (#188)

* Adding Cert sans to kubeadm config

This patch add the possibility to pass a list of ips or names to the certSans
property in the kubeadm.yml file.

Signed-off-by: Rivera Gonzalez, Julio C <julio.c.rivera.gonzalez@intel.com>

* Make idempotent addition of certSANs

Signed-off-by: Rivera Gonzalez, Julio C <julio.c.rivera.gonzalez@intel.com>
This commit is contained in:
Julio Rivera
2019-10-24 14:45:30 -07:00
committed by Justin Scott
parent aa86c554e8
commit 2ae8360760
+11 -1
View File
@@ -12,6 +12,7 @@ CUR_DIR=$(pwd)
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
: ${TOKEN:=}
: ${MASTER_IP:=}
: ${CERT_SANS:=}
HIGH_POD_COUNT=${HIGH_POD_COUNT:-""}
# versions
@@ -56,7 +57,16 @@ function cluster_init() {
if [[ -n "$K8S_VER" && $(grep -c kubernetesVersion ./kubeadm.yaml) -eq 0 ]]; then
sed -i "s/ClusterConfiguration/ClusterConfiguration\nkubernetesVersion: ${K8S_VER}/g" ./kubeadm.yaml
fi
# Config patches
if [[ -n "$CERT_SANS" ]]; then
if [[ $(grep -c certSANs ./kubeadm.yaml) -gt 0 ]]; then
sed -i '/certSANs/,/[a-zA-Z]*:/{//!d}' ./kubeadm.yaml
else
sed -i "/ClusterConfiguration/a apiServer:\\n certSANs:" ./kubeadm.yaml
fi
for CERT_SAN in ${CERT_SANS[@]}; do
sed -i "/certSANs/a \ \ - ${CERT_SAN}" ./kubeadm.yaml
done
fi
if [[ -n "${HIGH_POD_COUNT}" ]]; then
# increase limits in kubelet
sed -i "/KubeletConfiguration/a maxOpenFiles\: 1048576" ./kubeadm.yaml