From 354ce578446b51554fb0f5f64b038a0784198436 Mon Sep 17 00:00:00 2001 From: ArthurSens Date: Thu, 31 Mar 2022 06:22:38 +0000 Subject: [PATCH] Make it possible to deploy to different clusters Signed-off-by: ArthurSens --- hack/deploy-satellite.sh | 51 +++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/hack/deploy-satellite.sh b/hack/deploy-satellite.sh index 24fedb86..31a4e3cc 100755 --- a/hack/deploy-satellite.sh +++ b/hack/deploy-satellite.sh @@ -1,27 +1,50 @@ #!/bin/bash -kubectl apply -f monitoring-satellite/manifests/namespace.yaml -kubectl apply -f monitoring-satellite/manifests/podsecuritypolicy-restricted.yaml +KUBECONFIG="" +KUBECONFIG_FLAG="" + +opts=$(getopt \ + --longoptions "kubeconfig:" \ + --name "$(basename "$0")" \ + --options "" \ + -- "$@" +) + +eval set -- "$opts" + +while [[ $# -gt 0 ]]; do + case "$1" in + --kubeconfig) KUBECONFIG=$2 ; shift 2 ;; + *) break ;; + esac +done + +if [[ $KUBECONFIG != "" ]]; then + KUBECONFIG_FLAG="--kubeconfig ${KUBECONFIG}" +fi + +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/namespace.yaml +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/podsecuritypolicy-restricted.yaml for CRD in $(find monitoring-satellite/manifests/prometheusOperator/ -type f -name "*CustomResourceDefinition.yaml"); do - kubectl replace -f $CRD || kubectl create -f $CRD + kubectl $KUBECONFIG_FLAG replace -f $CRD || kubectl $KUBECONFIG_FLAG create -f $CRD done -until kubectl get servicemonitors.monitoring.coreos.com --all-namespaces ; do date; sleep 1; echo ""; done -until kubectl get prometheusrules.monitoring.coreos.com --all-namespaces ; do date; sleep 1; echo ""; done +until kubectl $KUBECONFIG_FLAG get servicemonitors.monitoring.coreos.com --all-namespaces ; do date; sleep 1; echo ""; done +until kubectl $KUBECONFIG_FLAG get prometheusrules.monitoring.coreos.com --all-namespaces ; do date; sleep 1; echo ""; done for operatorManifest in $(find monitoring-satellite/manifests/prometheusOperator/ -type f ! -name "*CustomResourceDefinition.yaml"); do - kubectl apply -f $operatorManifest + kubectl $KUBECONFIG_FLAG apply -f $operatorManifest done -kubectl apply -f monitoring-satellite/manifests/prometheus/ -kubectl apply -f monitoring-satellite/manifests/nodeExporter/ -kubectl apply -f monitoring-satellite/manifests/kubernetesControlPlane/ -kubectl apply -f monitoring-satellite/manifests/kubeStateMetrics/ -kubectl apply -f monitoring-satellite/manifests/kubescape/ -kubectl apply -f monitoring-satellite/manifests/grafana/ -kubectl apply -f monitoring-satellite/manifests/alertmanager/ -kubectl apply -f monitoring-satellite/manifests/otelCollector/ \ No newline at end of file +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/prometheus/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/nodeExporter/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/kubernetesControlPlane/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/kubeStateMetrics/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/kubescape/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/grafana/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/alertmanager/ +kubectl $KUBECONFIG_FLAG apply -f monitoring-satellite/manifests/otelCollector/ \ No newline at end of file