Skip to content

Commit b6894d2

Browse files
committed
fix: k8 destroy by namespace
1 parent 70ab79f commit b6894d2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.github/workflows/k8_cluster_destroy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
shell: bash
5353
run: |
5454
git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git
55-
bash cicd-deployment-scripts/k8-cluster/destroy.sh
55+
bash cicd-deployment-scripts/k8-cluster/destroy.sh -n ${{ env.KUBERNETES_NAMESPACE }}
5656
5757
# Deploys application based on given manifest file
5858
# - name: Deploys application

k8-cluster/destroy.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# !/bin/bash
22
set -e
33

4+
KUBERNETES_NAMESPACE=""
5+
6+
while getopts n: flag
7+
do
8+
case "${flag}" in
9+
n) KUBERNETES_NAMESPACE=${OPTARG};;
10+
esac
11+
done
12+
13+
kubectl config set-context --current --namespace=$KUBERNETES_NAMESPACE
414
KUBERNETES_DEPLOYMENTS=$(kubectl get deployment --output json | jq -r '.items[].metadata.name')
515
KUBERNETES_SERVICES=$(kubectl get service --output json | jq -r '.items[].metadata.name')
616

0 commit comments

Comments
 (0)