Skip to content

Commit

Permalink
Merge pull request #9 from soerenschneider/delete-resources
Browse files Browse the repository at this point in the history
add cleanup targets and documentation
  • Loading branch information
soerenschneider authored Dec 30, 2024
2 parents ed5460a + f134a98 commit f20a17a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,6 @@ bootstrap-kind-cluster: .check-binary-docker .check-binary-kind .check-binary-ku
deploy-2a: .check-binary-helm ## Deploy 2A to the management cluster
$(HELM) install hmc $(HMC_REPO) --version $(HMC_VERSION) -n $(HMC_NAMESPACE) --create-namespace

##@ Tear down management cluster

.PHONY: delete-kind-cluster
delete-kind-cluster: .check-binary-kind ## Tear down local kind cluster
@if $(KIND) get clusters | grep -q $(KIND_CLUSTER_NAME); then\
$(KIND) kind delete cluster --name=$(KIND_CLUSTER_NAME);\
else\
echo "Can't find kind cluster with the name $(KIND_CLUSTER_NAME)";\
fi

##@ TBD

Expand Down Expand Up @@ -440,6 +431,21 @@ certs/platform-engineer1/platform-engineer1.csr: certs/platform-engineer1/platfo
certs/platform-engineer1/platform-engineer1.crt: certs/platform-engineer1/platform-engineer1.csr certs/ca/ca.crt certs/ca/ca.key
openssl x509 -req -in certs/platform-engineer1/platform-engineer1.csr -CA certs/ca/ca.crt -CAkey certs/ca/ca.key -CAcreateserial -out certs/platform-engineer1/platform-engineer1.crt -days 360

##@ Tear down managed cluster
.PHONY: cleanup-clusters
cleanup-clusters: clean-certs
# use the explicit --context option to be specific about which cluster should be used to prevent disaster
kubectl --context=kind-$(KIND_CLUSTER_NAME) delete managedclusters.hmc.mirantis.com -n $(HMC_NAMESPACE) --all

##@ Tear down management cluster
.PHONY: cleanup
cleanup: cleanup-clusters clean-certs
@if $(KIND) get clusters | grep -q $(KIND_CLUSTER_NAME); then\
$(KIND) kind delete cluster --name=$(KIND_CLUSTER_NAME);\
else\
echo "Can't find kind cluster with the name $(KIND_CLUSTER_NAME)";\
fi

.PHONY: clean-certs
clean-certs:
rm -rf certs/ca
Expand Down Expand Up @@ -503,4 +509,4 @@ helm-push: helm-package
fi; \
fi; \
fi; \
done
done
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,14 @@ This demo is currently broken in HMC 0.0.5 until [#818](https://github.com/Miran

## Demo 10: Use ServiceTemplate in separate Namespace

## Cleaning up

To clean up the resources created on the public cloud providers, run the following command
```shell
make cleanup-clusters
```

As running the whole 2a setup can be quite taxing on your hardware, run the following command to clean up everything (both the public cloud resources mentioned above but also all local containers):
```shell
make cleanup
```

0 comments on commit f20a17a

Please sign in to comment.