forked from hashicorp/vault-plugin-auth-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (60 loc) · 2.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# kind cluster name
KIND_CLUSTER_NAME?=vault-plugin-auth-kubernetes
# kind k8s version
KIND_K8S_VERSION?=v1.25.0
.PHONY: default
default: dev
.PHONY: dev
dev:
CGO_ENABLED=0 go build -o bin/vault-plugin-auth-kubernetes cmd/vault-plugin-auth-kubernetes/main.go
.PHONY: test
test: fmtcheck
CGO_ENABLED=0 go test ./... $(TESTARGS) -timeout=20m
.PHONY: integration-test
integration-test:
INTEGRATION_TESTS=true CGO_ENABLED=0 go test github.com/hashicorp/vault-plugin-auth-kubernetes/integrationtest/... $(TESTARGS) -count=1 -timeout=20m
.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
.PHONY: fmt
fmt:
gofumpt -w .
.PHONY: setup-kind
# create a kind cluster for running the integration tests locally
setup-kind:
kind get clusters | grep --silent "^${KIND_CLUSTER_NAME}$$" || \
kind create cluster \
--image kindest/node:${KIND_K8S_VERSION} \
--name ${KIND_CLUSTER_NAME} \
--config $(CURDIR)/integrationtest/kind/config.yaml
kubectl config use-context kind-${KIND_CLUSTER_NAME}
.PHONY: delete-kind
# delete the kind cluster
delete-kind:
kind delete cluster --name ${KIND_CLUSTER_NAME} || true
.PHONY: vault-image
vault-image:
GOOS=linux make dev
docker build -f integrationtest/vault/Dockerfile bin/ --tag=hashicorp/vault:dev
# Create Vault inside the cluster with a locally-built version of kubernetes auth.
.PHONY: setup-integration-test
setup-integration-test: teardown-integration-test vault-image
kind --name ${KIND_CLUSTER_NAME} load docker-image hashicorp/vault:dev
kubectl create namespace test
helm install vault vault --repo https://helm.releases.hashicorp.com --version=0.22.0 \
--wait --timeout=5m \
--namespace=test \
--set server.dev.enabled=true \
--set server.image.tag=dev \
--set server.image.pullPolicy=Never \
--set injector.enabled=false \
--set server.extraArgs="-dev-plugin-dir=/vault/plugin_directory"
kubectl patch --namespace=test statefulset vault --patch-file integrationtest/vault/hostPortPatch.yaml
kubectl apply --namespace=test -f integrationtest/vault/tokenReviewerServiceAccount.yaml
kubectl apply -f integrationtest/vault/tokenReviewerBinding.yaml
kubectl delete --namespace=test pod vault-0
kubectl wait --namespace=test --for=condition=Ready --timeout=5m pod -l app.kubernetes.io/name=vault
.PHONY: teardown-integration-test
teardown-integration-test:
helm uninstall vault --namespace=test || true
kubectl delete --ignore-not-found namespace test