From 31fed3501879b2bf3269889a3017906fb7dfdff7 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Tue, 23 Mar 2021 15:17:25 +0100 Subject: [PATCH] add an approve-csr option --- cluster | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cluster b/cluster index 098917b..8e73e4b 100755 --- a/cluster +++ b/cluster @@ -60,9 +60,7 @@ function apply () { # Auto-approve all pending CSRs for i in {0..240}; do - oc --insecure-skip-tls-verify --kubeconfig="$cluster_name/auth/kubeconfig" get csr --no-headers \ - | awk '/Pending/ {print $1}' \ - | xargs --no-run-if-empty oc --insecure-skip-tls-verify --kubeconfig="$cluster_name/auth/kubeconfig" adm certificate approve + approve_csr "$cluster_name" sleep 15 done & @@ -81,6 +79,19 @@ function ping () { oc --insecure-skip-tls-verify --kubeconfig="$cluster_name/auth/kubeconfig" whoami } +function approve_csr () { + local cluster_name="${1:-}" + + if [ ! -d "$cluster_name" ]; then + echo "Cluster '$cluster_name' does not exist!" + exit 1 + fi + + oc --insecure-skip-tls-verify --kubeconfig="$cluster_name/auth/kubeconfig" get csr --no-headers \ + | awk '/Pending/ {print $1}' \ + | xargs --no-run-if-empty oc --insecure-skip-tls-verify --kubeconfig="$cluster_name/auth/kubeconfig" adm certificate approve +} + function start () { local cluster_name="${1:-}" @@ -226,6 +237,14 @@ apply) shift apply "$@" ;; +approve-csr) + if [ -z "${2:-}" ]; then + echo "Usage: $0 approve-csr cluster-name" + exit 1 + fi + shift + approve_csr "$@" +;; ping) if [ -z "${2:-}" ]; then echo "Usage: $0 ping cluster-name" @@ -251,7 +270,7 @@ post-install) post_install "$@" ;; *) - echo "Usage: $0 {init|apply|post-install|destroy|start|stop} cluster-name" + echo "Usage: $0 {init|apply|approve-csr|post-install|destroy|ping|start|stop} cluster-name" exit 1 ;; esac