-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.sh
executable file
·123 lines (88 loc) · 2.45 KB
/
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
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
#!/bin/bash
# setup
if [ ! -f demo-magic.sh ]; then
curl -LO https://github.com/paxtonhare/demo-magic/raw/master/demo-magic.sh
fi
. demo-magic.sh -d #-n
clear
# demo cleanup
rm score.yaml
score-compose init --no-sample
score-k8s init --no-sample
clear
# make compose-test
# make kind-create-cluster
# make kind-load-image
# make k8s-test
pe "echo \"Developers should not write either Docker Compose file or Kubernetes manifests, let me show you how!\""
pe "code index.js"
pe "code Dockerfile"
cat <<EOF > score.yaml
apiVersion: score.dev/v1b1
metadata:
name: hello-world
containers:
hello-world:
image: .
EOF
pe "code score.yaml"
pe "score-compose generate score.yaml --build 'hello-world={\"context\":\".\",\"tags\":[hello-world:test]}'"
pe "code compose.yaml"
pe "docker compose up --build -d --remove-orphans"
pe "score-k8s generate score.yaml --image hello-world:test"
pe "code manifests.yaml"
pe "kubectl apply -f manifests.yaml"
pe "clear"
pe "echo \"Let's make it more real!\""
clear
pe "echo \"I want to expose my Workload and want to talk to a PostgreSQL database!\""
clear
cat <<EOF > score.yaml
apiVersion: score.dev/v1b1
metadata:
name: hello-world
containers:
hello-world:
image: .
variables:
PORT: "3000"
MESSAGE: "Hello, World!"
DB_DATABASE: \${resources.db.name}
DB_USER: \${resources.db.username}
DB_PASSWORD: \${resources.db.password}
DB_HOST: \${resources.db.host}
DB_PORT: \${resources.db.port}
resources:
db:
type: postgres
dns:
type: dns
route:
type: route
params:
host: \${resources.dns.host}
path: /
port: 8080
service:
ports:
www:
port: 8080
targetPort: 3000
EOF
pe "code score.yaml"
pe "score-compose generate score.yaml --build 'hello-world={\"context\":\".\",\"tags\":[hello-world:test]}'"
pe "code compose.yaml"
pe "score-compose resources list"
pe "docker compose up --build -d --remove-orphans"
pe "docker ps"
pe "curl $(score-compose resources get-outputs dns.default#hello-world.dns --format '{{ .host }}:8080')"
pe "clear"
pe "code .score-compose/zz-default.provisioners.yaml"
pe "score-k8s generate score.yaml --image hello-world:test"
pe "code manifests.yaml"
pe "score-k8s resources list"
pe "kubectl apply -f manifests.yaml"
pe "kubectl get all"
pe "curl $(score-k8s resources get-outputs dns.default#hello-world.dns --format '{{ .host }}:8080')"
pe "clear"
pe "code .score-k8s/zz-default.provisioners.yaml"