From 2ae83607609f5777fc1ba378e0da861f69c127a0 Mon Sep 17 00:00:00 2001 From: Julio Rivera Date: Thu, 24 Oct 2019 16:45:30 -0500 Subject: [PATCH] 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 * Make idempotent addition of certSANs Signed-off-by: Rivera Gonzalez, Julio C --- clr-k8s-examples/create_stack.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clr-k8s-examples/create_stack.sh b/clr-k8s-examples/create_stack.sh index 49acaa5..38740f9 100755 --- a/clr-k8s-examples/create_stack.sh +++ b/clr-k8s-examples/create_stack.sh @@ -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