Skip to content

Update hack script to accept custom kubeconfig #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions hack/deploy-satellite.sh
Original file line number Diff line number Diff line change
@@ -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/
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/