-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart_demo.sh
executable file
·83 lines (61 loc) · 2.59 KB
/
start_demo.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
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
#!/usr/bin/env bash
########################
# include the magic
########################
. demo/demo-lib.sh
########################
# Configure the options
########################
#
# speed at which to simulate typing. bigger num = faster
#
TYPE_SPEED=50
export PS1="$ "
eval $(minikube docker-env)
# This is your image name
# TODO: setup local image registry for minikube. Push and pull from that registry.
#IMG=gcr.io/mengqiy-dev/manager-demo
#
# custom prompt
#
# see http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html for escape sequences
#
#DEMO_PROMPT="${GREEN}➜ ${CYAN}\W "
DEMO_PROMPT="$ "
#clear
INFO "====> [ Scaffold the project structure ]" "${YELLOW}"
pe "kubebuilder init --domain=cncf.io --dep=false" "${GREEN}"
INFO "====> [ Scaffold the CRD API and controller]" "${YELLOW}"
pe "kubebuilder create api --group=example --version=v1alpha1 --kind=BoundedDeployment --resource --controller --make=false" "${GREEN}"
INFO "====> [ Scaffold the webhook]" "${YELLOW}"
pe "kubebuilder alpha webhook --group=example --version=v1alpha1 --kind=BoundedDeployment --type=mutating --operations=create,update --make=false" "${GREEN}"
INFO "====> [ Run make ]" "${YELLOW}"
pe "make" "${GREEN}"
INFO "====> [ commit generated code ]" "${YELLOW}"
pe "git add -A" "${GREEN}"
pe "git commit -m 'kubebuilder scaffolded content'" "${GREEN}"
pe "clear" "${GREEN}"
INFO "====> [ add business logic ]" "${YELLOW}"
pe "git apply demo/business_logic.patch" "${GREEN}"
INFO "====> [ Show what user needs to implement ]" "${YELLOW}"
pe "git diff" "${GREEN}"
pe "git commit -am 'add business logic'" "${GREEN}"
INFO "====> [ Run make again to update generated code ]" "${YELLOW}"
pe "make" "${GREEN}"
INFO "====> [ Show generated code has been updated ]" "${YELLOW}"
pe "git diff" "${GREEN}"
# changes the yaml of a CR instance and create yaml for another instance.
INFO "====> [ Update CR instances ]" "${YELLOW}"
pe "git apply demo/CR.patch" "${GREEN}"
# use the image built locally for minikube
pe "git apply demo/image_pull.patch" "${GREEN}"
INFO "====> [ Build docker image ]" "${YELLOW}"
pe "make docker-build" "${GREEN}"
pe "clear" "${GREEN}"
INFO "====> [ Deploy the controller and webhook to cluster ]" "${YELLOW}"
pe "make deploy" "${GREEN}"
pe "kubectl get crd" "${GREEN}"
INFO "====> [ Verify the controller and webhooks work ]" "${YELLOW}"
pe "cat config/samples/example_v1alpha1_boundeddeployment.yaml" "${GREEN}"
pe "kubectl apply -f config/samples/example_v1alpha1_boundeddeployment.yaml" "${GREEN}"
pe "kubectl get deployments boundeddeployment-sample-deployment -o yaml | grep replicas" "${GREEN}"