-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (73 loc) · 2.24 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Cluster Creation
deploy-from-scratch:
$(MAKE) create-kind-cluster
$(MAKE) deploy
delete-from-scratch:
kind delete cluster -n k8s-concepts
create-kind-cluster:
kind create cluster --config ./k8s/kind/kind-config.yaml --name k8s-concepts
kind export kubeconfig --name k8s-concepts
$(MAKE) install-ingress-controller
$(MAKE) install-cert-manager
$(MAKE) install-metrics-components
$(MAKE) config-contexts
# Kubernetes Shortcuts
deploy:
kubectl apply -f k8s/namespaces.yaml
kubectl apply -f k8s
delete:
kubectl delete -f k8s
redeploy:
$(MAKE) delete
$(MAKE) deploy
port-forward:
kubectl port-forward svc/go-http-app-service 8000:80
# Dependecies Installing
install-metrics-components:
kubectl apply -f k8s/metrics-server.yaml
kubectl wait --namespace kube-system \
--for=condition=available deployment/metrics-server \
--timeout=200s
install-ingress-controller:
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace nginx --create-namespace
sleep 5
kubectl wait --namespace nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=250s
install-cert-manager:
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
sleep 10
kubectl wait --namespace cert-manager \
--for=condition=available deployment/cert-manager \
--timeout=300s
# Kubernetes Context
config-contexts:
kubectl config set-context server \
--namespace=server \
--cluster=kind-k8s-concepts \
--user=kind-k8s-concepts
kubectl config set-context database \
--namespace=database \
--cluster=kind-k8s-concepts \
--user=kind-k8s-concepts
kubectl config view
database-context:
kubectl config use-context database
server-context:
kubectl config use-context server
default-context:
kubectl config use-context kind-k8s-concepts
# Stress Tests
stress-test-fortio:
kubectl run -it fortio --rm --image=fortio/fortio -- load \
-qps 800 \
-t 120s \
-c 70 \
"http://go-http-app-service/healthz"
# Testing
test-serviceaccount-pod-list: # This tests the ServiceAccount from namespace "server" (via injected script)
$(MAKE) server-context
kubectl exec -it \
$$(kubectl get po -o name | head -n 1) \
-- bash test-serviceaccount/test-k8s-api-access.sh