Skip to content

Commit

Permalink
update namespace on cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sungil committed Nov 13, 2024
1 parent 1f37e6e commit 70c5778
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions deploy_apps/tks-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,16 @@ spec:
kube_secret=$(kubectl get secret -n ${cluster_id} ${cluster_id}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$kube_secret" > kubeconfig
while ! kubectl --kubeconfig=kubeconfig get svc -n lma grafana --ignore-not-found; do
while ! kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana --ignore-not-found; do
echo "Waiting for the grafana service to appear in cluster ${cluster_id} (5s)"
sleep 5
done
grafana_ep_secret=$(kubectl get secret -n ${cluster_id} tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d ) || grafana_ep_secret=""
if [ "$grafana_ep_secret" == "" ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [[ "$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [[ "$(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]]; then
log "FAIL" "A service for the grafana in ${cluster_id} is not configured properly.(No LoadBalancer)"
exit -1
fi
Expand All @@ -326,7 +326,7 @@ spec:
sleep 3
done
endpoint=$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
endpoint=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
else
endpoint=${grafana_ep_secret}
fi
Expand Down Expand Up @@ -470,12 +470,12 @@ spec:
kube_secret=$(kubectl get secret -n ${cluster_id} ${cluster_id}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$kube_secret" > kubeconfig
pods=$(kubectl --kubeconfig kubeconfig get pods -n lma | grep grafana | awk '{print $1}')
pods=$(kubectl --kubeconfig kubeconfig get pods -n taco-system | grep grafana | awk '{print $1}')
for pod in $pods
do
echo "Deleting pod $pod"
kubectl --kubeconfig kubeconfig delete pod $pod -n lma --ignore-not-found=true
kubectl --kubeconfig kubeconfig delete pod $pod -n taco-system --ignore-not-found=true
done

envFrom:
Expand Down
34 changes: 17 additions & 17 deletions deploy_apps/tks-primary-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ spec:
LOKI_SERVICE=$(kubectl get secret -n ${primary_cluster} tks-endpoint-secret -o jsonpath='{.data.loki}'| base64 -d )
if [[ "$LOKI_SERVICE" == "" ]]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma loki-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-loki-distributed-gateway -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-loki-distributed-gateway -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
log "FAIL" "The infras on primary are not cofigured properly.(No LoadBalancer)"
exit -1
fi
Expand All @@ -484,8 +484,8 @@ spec:
sleep 3
done
LOKI_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
LOKI_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-loki-distributed-gateway -o jsonpath="{.spec.ports[0].port}")
LOKI_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
LOKI_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-loki-distributed-gateway -o jsonpath="{.spec.ports[0].port}")
else
LOKI_HOST=$(echo $LOKI_SERVICE | awk -F : '{print $1}')
LOKI_PORT=$(echo $LOKI_SERVICE | awk -F : '{print $2}')
Expand All @@ -497,9 +497,9 @@ spec:
LOKI_USER_SERVICE=$(kubectl get secret -n ${primary_cluster} tks-endpoint-secret -o jsonpath='{.data.loki_user}'| base64 -d )
if [[ "$LOKI_USER_SERVICE" == "" ]]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma loki-user-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-user-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-user-loki-distributed-gateway -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-user-loki-distributed-gateway -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
log "FAIL" "The infras on primary are not cofigured properly.(No LoadBalancer)"
exit -1
fi
Expand All @@ -508,8 +508,8 @@ spec:
sleep 3
done
LOKI_USER_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-user-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
LOKI_USER_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n lma loki-user-loki-distributed-gateway -o jsonpath="{.spec.ports[0].port}")
LOKI_USER_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-user-loki-distributed-gateway -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
LOKI_USER_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system loki-user-loki-distributed-gateway -o jsonpath="{.spec.ports[0].port}")
else
LOKI_USER_HOST=$(echo $LOKI_USER_SERVICE | awk -F : '{print $1}')
LOKI_USER_PORT=$(echo $LOKI_USER_SERVICE | awk -F : '{print $2}')
Expand All @@ -521,8 +521,8 @@ spec:
if [[ "${primary_cluster}" == "${current_cluster}" ]] && [[ "$OBJECT_STORE" == "minio" ]]; then
S3_SERVICE=$(kubectl get secret -n ${primary_cluster} tks-endpoint-secret -o jsonpath='{.data.minio}'| base64 -d )
if [[ "$S3_SERVICE" == "" ]]; then
S3_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n lma minio -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
S3_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n lma minio -o jsonpath="{.spec.ports[0].port}")
S3_HOST=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system minio -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
S3_PORT=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system minio -o jsonpath="{.spec.ports[0].port}")
S3_SERVICE=${S3_HOST}:${S3_PORT}
fi
fi
Expand Down Expand Up @@ -741,10 +741,10 @@ spec:
PROMETHEUS_URL=$(kubectl get secret -n ${member} tks-endpoint-secret -o jsonpath='{.data.prometheus}'| base64 -d )
if [[ "$PROMETHEUS_URL" != "" ]]; then
eplist="${eplist}, \"${PROMETHEUS_URL}\""
elif [ `kubectl --kubeconfig=kubeconfig get svc -n lma lma-thanos-external --ignore-not-found=true | grep -v NAME | wc -l ` -eq 1 ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma lma-thanos-external -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
elif [ `kubectl --kubeconfig=kubeconfig get svc -n taco-system lma-thanos-external --ignore-not-found=true | grep -v NAME | wc -l ` -eq 1 ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n taco-system lma-thanos-external -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]
do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma lma-thanos-external -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n taco-system lma-thanos-external -o jsonpath="{.spec.type}")" -neq "LoadBalancer" ]; then
log "FAIL" "A service for the thanos-sidcar in ${member} is not cofigured properly.(No LoadBalancer)"
exit -1
fi
Expand All @@ -753,7 +753,7 @@ spec:
sleep 3
done
eplist="${eplist}, \"$(kubectl --kubeconfig=kubeconfig get svc -n lma lma-thanos-external -o jsonpath="{.status.loadBalancer.ingress[0].hostname}"):$(kubectl --kubeconfig=kubeconfig get svc -n lma lma-thanos-external -o jsonpath="{.spec.ports[0].port}")\""
eplist="${eplist}, \"$(kubectl --kubeconfig=kubeconfig get svc -n taco-system lma-thanos-external -o jsonpath="{.status.loadBalancer.ingress[0].hostname}"):$(kubectl --kubeconfig=kubeconfig get svc -n taco-system lma-thanos-external -o jsonpath="{.spec.ports[0].port}")\""
else
log "WARN" "Cluster(${member}) has no prometheus sidecar"
fi
Expand Down Expand Up @@ -1068,7 +1068,7 @@ spec:
kubectl --kubeconfig /kube/value get secret -n ${cluster_id} ${cluster_id}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d > ~/kubeconfig
export KUBECONFIG=~/kubeconfig
kubectl delete job -n lma empty-buckets-before-delete-them --ignore-not-found=true
kubectl delete job -n taco-system empty-buckets-before-delete-them --ignore-not-found=true
cat <<EOF | kubectl apply -f -
apiVersion: batch/v1
kind: Job
Expand Down Expand Up @@ -1099,12 +1099,12 @@ spec:
backoffLimit: 4
EOF
while [ $(kubectl get -n lma job empty-buckets-before-delete-them -o jsonpath='{.status.conditions[0].type}'|wc -c) -eq 0 ]; do
while [ $(kubectl get -n taco-system job empty-buckets-before-delete-them -o jsonpath='{.status.conditions[0].type}'|wc -c) -eq 0 ]; do
echo "A job is not completed. wait 10 seconds...."
sleep 10
done
if [[ $(kubectl get -n lma job empty-buckets-before-delete-them -o jsonpath='{.status.conditions[0].type}') == "Complete" ]]; then
if [[ $(kubectl get -n taco-system job empty-buckets-before-delete-them -o jsonpath='{.status.conditions[0].type}') == "Complete" ]]; then
exit 0
else
exit -1
Expand Down
8 changes: 4 additions & 4 deletions deploy_apps/tks-remove-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ spec:
kube_secret=$(kubectl get secret -n ${cluster_id} ${cluster_id}-tks-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$kube_secret" > kubeconfig
while ! kubectl --kubeconfig=kubeconfig get svc -n lma grafana --ignore-not-found; do
while ! kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana --ignore-not-found; do
echo "Waiting for the grafana service to appear in cluster ${cluster_id} (5s)"
sleep 5
done
grafana_ep_secret=$(kubectl get secret -n ${cluster_id} tks-endpoint-secret -o jsonpath='{.data.grafana}'| base64 -d ) || grafana_ep_secret=""
if [ "$grafana_ep_secret" == "" ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]; then
while [ -z $(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath="{.status.loadBalancer.ingress[*].hostname}") ]; do
if [ "$(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath='{.spec.type}')" != "LoadBalancer" ]; then
log "FAIL" "A service for the grafana in ${cluster_id} is not configured properly.(No LoadBalancer)"
exit -1
fi
Expand All @@ -353,7 +353,7 @@ spec:
sleep 3
done
endpoint=$(kubectl --kubeconfig=kubeconfig get svc -n lma grafana -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
endpoint=$(kubectl --kubeconfig=kubeconfig get svc -n taco-system grafana -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
else
endpoint=${grafana_ep_secret}
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/validate-service-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
exit 1
fi
kubectl get po -n lma | grep -Ev "Running|Completed|NAME"
kubectl get po -n taco-system | grep -Ev "Running|Completed|NAME"
if [[ $? != 1 ]]; then
echo "ERROR - invalid pod status"
exit 1
Expand Down

0 comments on commit 70c5778

Please sign in to comment.