Skip to content

Commit c3df758

Browse files
committed
Removed flux system namespace from state to make cleanup easier
1 parent b18d0d1 commit c3df758

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

terraform/destroy.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ sed -i '/^module "flux_v2"/,/^}/s/^/# /' saas_gitops.tf
3737
# Also comment out gitea references in the configmap
3838
sed -i '/gitea_token.*=/s/^/ # /' saas_gitops.tf
3939

40-
# Remove gitea resources from terraform state
41-
echo "Removing gitea resources from terraform state..."
40+
# Remove gitea and flux resources from terraform state
41+
echo "Removing gitea and flux resources from terraform state..."
4242
terraform state rm 'gitea_repository.eks-saas-gitops' 2>/dev/null || true
4343
terraform state rm 'data.aws_ssm_parameter.gitea_token' 2>/dev/null || true
44+
terraform state rm 'kubernetes_namespace.flux_system' 2>/dev/null || true
4445

4546
# Reinitialize terraform without gitea provider
4647
echo "Reinitializing terraform without gitea provider..."
@@ -50,15 +51,6 @@ terraform init
5051
# Skip provider verification since Gitea server will be destroyed
5152
export TF_SKIP_PROVIDER_VERIFY=1
5253

53-
# Force remove flux-system namespace if it's stuck
54-
echo "Checking for stuck flux-system namespace..."
55-
if kubectl get namespace flux-system 2>/dev/null; then
56-
echo "Removing finalizers from flux-system namespace..."
57-
kubectl get namespace flux-system -o json | jq '.spec.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/flux-system/finalize" -f - || true
58-
echo "Waiting for namespace cleanup..."
59-
sleep 30
60-
fi
61-
6254
# Clean up ECR repositories
6355
echo "Cleaning up ECR repositories..."
6456
for repo in $(aws ecr describe-repositories --region $AWS_REGION --query 'repositories[].repositoryName' --output text 2>/dev/null || echo ""); do

0 commit comments

Comments
 (0)