Files
kagent-oci-devops-demo/k8s/delete-namespace-command-spec.yaml
Oracle Public Cloud User 8b3cc8dd10 adding files 2
2026-09-04 13:54:16 +00:00

51 lines
1.4 KiB
YAML

version: 0.1
component: command
timeoutInSeconds: 900
shell: bash
failImmediatelyOnError: true
env:
variables:
APP_NAMESPACE: "kagent-demo"
WAIT_TIMEOUT: "300s"
steps:
- type: Command
name: Confirm target namespace
command: |
echo "Full cleanup will delete the namespace and all resources inside it."
echo "APP_NAMESPACE=${APP_NAMESPACE}"
if [ "${APP_NAMESPACE}" = "default" ] || [ "${APP_NAMESPACE}" = "kube-system" ] || [ "${APP_NAMESPACE}" = "kagent" ]; then
echo "Refusing to delete protected namespace: ${APP_NAMESPACE}"
exit 1
fi
kubectl get namespace "${APP_NAMESPACE}"
- type: Command
name: Delete LoadBalancer before namespace cleanup
command: |
echo "Deleting LoadBalancer service first to start OCI load balancer cleanup"
kubectl delete service order-service-lb \
-n "${APP_NAMESPACE}" \
--ignore-not-found=true
- type: Command
name: Delete namespace
command: |
kubectl delete namespace "${APP_NAMESPACE}" \
--ignore-not-found=true \
--timeout="${WAIT_TIMEOUT}"
- type: Command
name: Verify namespace deletion
command: |
if kubectl get namespace "${APP_NAMESPACE}" >/dev/null 2>&1; then
echo "Namespace ${APP_NAMESPACE} still exists or is terminating."
kubectl get namespace "${APP_NAMESPACE}" -o wide
exit 1
fi
echo "Namespace ${APP_NAMESPACE} was deleted successfully."