-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (117 loc) · 6.94 KB
/
Makefile
File metadata and controls
130 lines (117 loc) · 6.94 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# ----------------------------------------------------------------------
# I quickly setup this Makefile as a kind of trivial pipeline simulation
# Michele Modolo
# ----------------------------------------------------------------------
# --------------------------------------------------
# Options INSIDE Vagrant box (tested with minikube)
# NOTE: helm installs from a local chart
#
# -- Suggested usage: "make all-vagrant".
# --------------------------------------------------
all-vagrant: docker helm-deploy apptest-nonargocd
docker: builddockerimage loaddockerimagetominikube
helm-deploy: localhelminstall
apptest-nonargocd: apptestnonargocd
# ----------------------------------------------------------------------------------------------
# Options OUTSIDE Vagrant box (tested with docker-desktop)
# Prereqs: helm,docker,k8s (e.g. docker-desktop) installed
# NOTE: helm installs from a remote charts (repo: https://michelemodolo.github.io/sb-helmcharts)
#
# -- Suggested usage: "make all". Once you got satisfied: "make argocd-cleanup" to clean up.
# ----------------------------------------------------------------------------------------------
all: builddockerimage helm-remote argocd-install argocd-appregistration apptest-argocd
helm-remote: helmremote
argocd-install: argocdinstall
argocd-appregistration: argocdappregistration
apptest-argocd: apptestargocd
argocd-cleanup: argocdcleanup
builddockerimage:
@echo "\n--------------------------------------------------------";\
echo "*** I am about to build the alphanumber local docker image...";\
echo "---------------------------------------------------------\n";\
cd docker/alphanumber;\
docker build -t alphanumber:latest . ;\
loaddockerimagetominikube:
@echo "\n----------------------------------------------------------------";\
echo "*** I am about to load the 'alphanumber' local docker image to minikube cluster...";\
echo "-----------------------------------------------------------------\n";\
minikube image load alphanumber:latest ;\
echo "done."
localhelminstall:
# ----------------------------------------------------------------------
# NOTE: this is a LOCAL helm install
# ----------------------------------------------------------------------
@echo "\n-------------------------------------------------------------------------------------------";\
echo "*** I am now installing the alphanumber app through Helm...";\
echo "-------------------------------------------------------------------------------------------\n";\
cd localhelm;\
helm install alphanumber alphanumber/ --values alphanumber/values.yaml;\
echo "\n-----------------------------------------------------------------------------------";\
echo "*** I am giving 40sec to 'alphanumber' app so that all its pods can be running...";\
echo "----------------------------------------------------------------------------------\n";\
sleep 40
apptestnonargocd:
@echo "\n--------------------------------------------------------------------------------------------------";\
echo "*** Testing some endpoints... NOTE: special chars (including spaces) are not correctly handed by CURL";\
echo "*** NOTE1: CURL is needed within a Vagrant box because bridging a host browser from Vagrant is pretty thorny (for me)";\
echo "*** NOTE2: You will use your browser when testing onto your local cluster (check README.md)";\
echo "---------------------------------------------------------------------------------------------------\n";\
export NODE_PORT=$(shell kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services alphanumber) ;\
export NODE_IP=$(shell kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") ;\
echo "---------";\
echo "*** Testing $$NODE_IP:$$NODE_PORT/ready .... ***";\
curl $$NODE_IP:$$NODE_PORT/ready;\
echo "---------";\
echo "*** Testing $$NODE_IP:$$NODE_PORT/Dad .... ***";\
curl $$NODE_IP:$$NODE_PORT/Dad;\
echo "---------";\
echo "*** Testing $$NODE_IP:$$NODE_PORT/Dad37Dad .... ***";\
curl $$NODE_IP:$$NODE_PORT/Dad37Dad;\
echo "---------";\
echo "*** Testing $$NODE_IP:$$NODE_PORT/about .... ***";\
curl $$NODE_IP:$$NODE_PORT/about;\
echo "---------";\
echo "*** UP TO YOU: try testing 'curl $$NODE_IP:$$NODE_PORT/whatever' .... ***";\
echo
helmdestroy:
helm uninstall alphanumber
argocdinstall:
@echo "\n-------------------------------------------------------------------------------------------";\
echo "*** I am installing ArgoCD...";\
echo "-------------------------------------------------------------------------------------------\n";\
kubectl create namespace argocd;\
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml;\
echo "\n--------------------------------------------------------------------------------------------------";\
echo "*** I am giving 60sec to ArgoCD so that all its pods can be running...";\
echo "---------------------------------------------------------------------------------------------------\n";\
sleep 60
helmremote:
# ----------------------------------------------------------------------
# NOTE: this is a prerequisite for the ARGOCD-driven app installation!!
# ----------------------------------------------------------------------
@echo "\n-----------------------------------------------------------------------------------------";\
echo "*** I am adding the michelemodolo.github.io/sb-helmcharts Helm repo as 'michelemodolo'...";\
echo "-----------------------------------------------------------------------------------------\n";\
helm repo add michelemodolo https://michelemodolo.github.io/sb-helmcharts/
helm repo update
# helm install alphanumber michelemodolo/alphanumber
argocdappregistration:
@echo "\n--------------------------------------------------------------------------------------------------";\
echo "*** I am registering the 'alphanumber' app to ArgoCD...";\
echo "---------------------------------------------------------------------------------------------------\n";\
kubectl apply -n argocd -f argocd-alphanumber.yaml;\
echo "\n--------------------------------------------------------------------------------------------------";\
echo "*** I am giving 40sec to ArgoCD so that it can fully deploy the 'alphanumber' app...";\
echo "---------------------------------------------------------------------------------------------------\n";\
sleep 40
apptestargocd:
@echo "\n-------------------------------------------------------------------------------------------";\
echo "*** ----->>> IN YOUR BROWSER GO TO localhost:8888/whatever-you-want-to-test : <<<----- ***";\
echo "-------------------------------------------------------------------------------------------\n";\
echo " AFTER you did your tests don't forget to stop the port binding, if still active, by running: \n";\
echo " 1) ps -ef | grep 'forward svc/alphanumber' \n";\
echo " 2) kill -9 THE-PID-YOU-NEED-TO-KILL \n";\
kubectl port-forward svc/alphanumber -n argocd 8888:8000;\
echo
argocdcleanup:
kubectl delete ns argocd