-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.sh
executable file
·47 lines (40 loc) · 1.5 KB
/
cmd.sh
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
build(){
'''
Firstly, we have to build our app "image".
Building such images take lots of time and memory, but be patient since we need them for efficient deployment
Behaviors of following lines are ellaborated in comments next to it
'''
docker build -t hello-kube . # Build the 'image' name hello-kube, with tag 'latest', for simplicity, I do not choose the 'tagname' here, but actually we can set it to 1.0 or whatever version/real product version
docker save hello-kube:latest | (eval $(minikube docker-env) && docker load) # save to local for minikube to pull, since 'minikube' use different docker env
}
start(){
kubectl create namespace myserver
kubectl apply -f deploy.yaml -n myserver
# kubectl port-forward -n myserver deployment/hello-kube-deployment 8000:8000 # this development will be 'visible' to localhost:8000, but not int the 'cluster'
# kubectl port-forward -n myserver service/hello-kube-service 8888:8080 # the service makes made our application 'visible' inside cluster
# now leverage the ingress to make our application 'visible' outside the cluster
kubectl apply -f ingress.yaml -n myserver
}
stop(){
kubectl delete -f deploy.yaml -n myserver
kubectl delete -f ingress.yaml -n myserver
kubectl delete namespace myserver
}
CMD=$1
case $CMD in
"build")
echo "Dockerizing server..."
build
;;
"start")
echo "Starting components..."
start
;;
"stop")
echo "Stoping components..."
stop
;;
*)
echo "unknown command"
;;
esac