Skip to content

Commit

Permalink
Small updates for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
phenixblue committed Mar 31, 2021
1 parent a14f45e commit 6f4532a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ deploy: manifests
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default | kubectl apply -f -

# Deploy controller using the "Prod" example overlay
deploy-prod: manifests
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/overlays/prod | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
Expand Down Expand Up @@ -87,3 +92,19 @@ CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

# Setup Test Namespace and artifacts
test-setup:
kubectl create ns test1
kubectl label ns test1 k8s.twr.dev/owner="user1"
kubectl apply -f ./testing/kubernetes/crdb-sts.yaml -n test1

set-reclaim-delete:
kubectl -n test1 label pvc --all storage.k8s.twr.dev/reclaim-policy=Delete --overwrite

set-reclaim-retain:
kubectl -n test1 label pvc --all storage.k8s.twr.dev/reclaim-policy=Retain --overwrite

set-reclaim-recycle:
kubectl -n test1 label pvc --all storage.k8s.twr.dev/reclaim-policy=Recycle --overwrite

5 changes: 5 additions & 0 deletions config/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- "../../default"

patchesStrategicMerge:
- "volrec-startup-args-patch.yaml"
17 changes: 17 additions & 0 deletions config/overlays/prod/volrec-startup-args-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: volrec-controller
namespace: volrec-system
spec:
replicas: 2
template:
spec:
containers:
- name: volrec
command:
- /manager
args:
- --enable-leader-election
- --set-owner
- --set-ns
19 changes: 10 additions & 9 deletions notes/testing.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Notes on Testing the volrec Controller

## Create Test Namespace
## Deploy Volrec

```shell
$ kubectl create ns test1
$ make deploy-prod
```

## Label Namespace
## Setup Test environment

```shell
$ kubectl label ns test1 k8s.twr.dev/owner="user1"
```
This creates a test namespace, applies appropriate labels, and deploys a sample Statefulset with dynamic PVC/PV's.

The PVC claim wihtin the Statefulset is configured to set PV reclaim policy from to `Retain`.

## Deploy Test Statefulset

```shell
$ kubectl apply -f ./testing/kubernetes/crdb-sts.yaml -n test1
$ make test-setup
```

## Check the logs of the controller
Expand All @@ -27,7 +26,9 @@ $ kubectl logs -n volrec-system -l app=volrec -c volrec -f
## Apply labels to PVC to change Reclaim Policy

```shell
$ kubectl label pvc -n test1 datadir-crdb1-0 storage.k8s.twr.dev/reclaim-policy=Retain --overwrite
$ make set-reclaim-delete
$ make set-reclaim-recycle
$ make set-reclaim-retain
```

NOTE: The default Reclaim Policy could differ, so update the label value to something pertinent for your environment
Expand Down

0 comments on commit 6f4532a

Please sign in to comment.