Skip to content

Commit 5e4a6c8

Browse files
kfirtoledomayabar
authored andcommitted
feat: add cleanup for kubernetes dev env (kubernetes-sigs#59)
Signed-off-by: Kfir Toledo <[email protected]>
1 parent 1569cde commit 5e4a6c8

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

DEVELOPMENT.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ make environment.dev.kind
4343

4444
This will create a `kind` cluster (or re-use an existing one) using the system's
4545
local container runtime and deploy the development stack into the `default`
46-
namespace.
46+
namespace.
4747

4848
There are several ways to access the gateway:
4949

@@ -56,15 +56,15 @@ $ kubectl --context kind-gie-dev port-forward service/inference-gateway 8080:80
5656
> **Warning**: This method doesn't work on `podman` correctly, as `podman` support
5757
> with `kind` is not fully implemented yet.
5858
```sh
59-
# Determine the k8s node address
59+
# Determine the k8s node address
6060
$ kubectl --context kind-gie-dev get node -o yaml | grep address
6161
# The service is accessible over port 80 of the worker IP address.
6262
```
6363

6464
**LoadBalancer**
6565

6666
```sh
67-
# Install and run cloud-provider-kind:
67+
# Install and run cloud-provider-kind:
6868
$ go install sigs.k8s.io/cloud-provider-kind@latest && cloud-provider-kind &
6969
$ kubectl --context kind-gie-dev get service inference-gateway
7070
# Wait for the LoadBalancer External-IP to become available. The service is accessible over port 80.
@@ -250,3 +250,20 @@ make environment.dev.kubernetes
250250
```
251251

252252
And test the changes.
253+
254+
### Cleanup Environment
255+
256+
To clean up the development environment and remove all deployed resources in your namespace, run:
257+
258+
```sh
259+
make clean.environment.dev.kubernetes
260+
```
261+
262+
**Warning**: This cleanup doesn't remove any custom pull `Secrets` you may have added. If you are
263+
done with this environment, you may want to remove those manually as well.
264+
265+
If you also want to remove the namespace entirely, run:
266+
267+
```sh
268+
kubectl delete namespace ${NAMESPACE}
269+
```

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ test: check-ginkgo ## Run tests
432432
post-deploy-test: ## Run post deployment tests
433433
echo Success!
434434
@echo "Post-deployment tests passed."
435-
435+
436436
.PHONY: lint
437437
lint: check-golangci-lint ## Run lint
438438
@printf "\033[33;1m==== Running linting ====\033[0m\n"
@@ -780,15 +780,15 @@ environment.dev.kubernetes: check-kubectl check-kustomize check-envsubst
780780
# ------------------------------------------------------------------------------
781781
# Kubernetes Development Environment - Teardown
782782
#
783-
# Tears down the namespace, and therefore the development environment.
783+
# Tears down the development environment.
784784
# ------------------------------------------------------------------------------
785785
.PHONY: clean.environment.dev.kubernetes
786786
clean.environment.dev.kubernetes: check-kubectl check-kustomize check-envsubst
787787
ifndef NAMESPACE
788788
$(error "Error: NAMESPACE is required but not set")
789789
endif
790-
@echo "INFO: deleting namespace $(NAMESPACE)"
791-
kubectl delete namespace $(NAMESPACE)
790+
@echo "INFO: cleaning up dev environment in $(NAMESPACE)"
791+
kustomize build deploy/environments/dev/kubernetes-kgateway | envsubst | kubectl -n "${NAMESPACE}" delete -f -
792792

793793
# -----------------------------------------------------------------------------
794794
# TODO: these are old aliases that we still need for the moment, but will be

0 commit comments

Comments
 (0)