-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMakefile
226 lines (171 loc) · 12.2 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
IMAGE_REPOSITORY = localhost:5001
PACKAGE_VERSION = latest
RELEASE_VERSION = 0.0.1
UNAME_SYSTEM := $(shell uname -s)
UNAME_MACHINE := $(shell uname -m)
DOCKER_PLATFORM = linux/amd64
ifeq ($(UNAME_SYSTEM),Darwin)
ifeq ($(UNAME_MACHINE),arm64)
DOCKER_PLATFORM = linux/arm64
endif
endif
all: push-all-images deploy-cluster-essentials deploy-training-platform deploy-workshop
build-all-images: build-session-manager build-training-portal \
build-base-environment build-jdk8-environment build-jdk11-environment \
build-jdk17-environment build-conda-environment build-docker-registry \
build-pause-container build-secrets-manager build-tunnel-manager
push-all-images: push-session-manager push-training-portal \
push-base-environment push-jdk8-environment push-jdk11-environment \
push-jdk17-environment push-conda-environment push-docker-registry \
push-pause-container push-secrets-manager push-tunnel-manager
build-core-images: build-session-manager build-training-portal \
build-base-environment build-docker-registry build-pause-container \
build-secrets-manager build-tunnel-manager
push-core-images: push-session-manager push-training-portal \
push-base-environment push-docker-registry push-pause-container \
push-secrets-manager push-tunnel-manager
build-session-manager:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-session-manager:$(PACKAGE_VERSION) session-manager
push-session-manager: build-session-manager
docker push $(IMAGE_REPOSITORY)/educates-session-manager:$(PACKAGE_VERSION)
build-training-portal:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-training-portal:$(PACKAGE_VERSION) training-portal
push-training-portal: build-training-portal
docker push $(IMAGE_REPOSITORY)/educates-training-portal:$(PACKAGE_VERSION)
build-base-environment:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-base-environment:$(PACKAGE_VERSION) workshop-images/base-environment
push-base-environment: build-base-environment
docker push $(IMAGE_REPOSITORY)/educates-base-environment:$(PACKAGE_VERSION)
build-jdk8-environment: build-base-environment
docker build --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk8-environment:$(PACKAGE_VERSION) workshop-images/jdk8-environment
push-jdk8-environment: build-jdk8-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk8-environment:$(PACKAGE_VERSION)
build-jdk11-environment: build-base-environment
docker build --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk11-environment:$(PACKAGE_VERSION) workshop-images/jdk11-environment
push-jdk11-environment: build-jdk11-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk11-environment:$(PACKAGE_VERSION)
build-jdk17-environment: build-base-environment
docker build --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk17-environment:$(PACKAGE_VERSION) workshop-images/jdk17-environment
push-jdk17-environment: build-jdk17-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk17-environment:$(PACKAGE_VERSION)
build-conda-environment: build-base-environment
docker build --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-conda-environment:$(PACKAGE_VERSION) workshop-images/conda-environment
push-conda-environment: build-conda-environment
docker push $(IMAGE_REPOSITORY)/educates-conda-environment:$(PACKAGE_VERSION)
build-desktop-environment: build-base-environment
docker build --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-desktop-environment:$(PACKAGE_VERSION) workshop-images/desktop-environment
push-desktop-environment: build-desktop-environment
docker push $(IMAGE_REPOSITORY)/educates-desktop-environment:$(PACKAGE_VERSION)
build-docker-registry:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-docker-registry:$(PACKAGE_VERSION) docker-registry
push-docker-registry: build-docker-registry
docker push $(IMAGE_REPOSITORY)/educates-docker-registry:$(PACKAGE_VERSION)
build-pause-container:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-pause-container:$(PACKAGE_VERSION) pause-container
push-pause-container: build-pause-container
docker push $(IMAGE_REPOSITORY)/educates-pause-container:$(PACKAGE_VERSION)
build-secrets-manager:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-secrets-manager:$(PACKAGE_VERSION) secrets-manager
push-secrets-manager: build-secrets-manager
docker push $(IMAGE_REPOSITORY)/educates-secrets-manager:$(PACKAGE_VERSION)
build-tunnel-manager:
docker build --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-tunnel-manager:$(PACKAGE_VERSION) tunnel-manager
push-tunnel-manager: build-tunnel-manager
docker push $(IMAGE_REPOSITORY)/educates-tunnel-manager:$(PACKAGE_VERSION)
verify-cluster-essentials-config:
ifneq ("$(wildcard testing/educates-cluster-essentials-values.yaml)","")
@ytt --file carvel-packages/cluster-essentials/bundle/config --data-values-file testing/educates-cluster-essentials-values.yaml
else
@ytt --file carvel-packages/cluster-essentials/bundle/config
endif
push-cluster-essentials-bundle:
ytt -f carvel-packages/cluster-essentials/bundle/config | kbld -f - --imgpkg-lock-output carvel-packages/cluster-essentials/bundle/.imgpkg/images.yml
imgpkg push -b $(IMAGE_REPOSITORY)/educates-cluster-essentials:$(RELEASE_VERSION) -f carvel-packages/cluster-essentials/bundle
mkdir -p testing
ytt -f carvel-packages/cluster-essentials/bundle --data-values-schema-inspect -o openapi-v3 > testing/educates-cluster-essentials-schema-openapi.yaml
ytt -f carvel-packages/cluster-essentials/config/package.yaml -f carvel-packages/cluster-essentials/config/schema.yaml -v imageRegistry.host=$(IMAGE_REPOSITORY) -v version=$(RELEASE_VERSION) -v releasedAt=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --data-value-file openapi=testing/educates-cluster-essentials-schema-openapi.yaml > testing/educates-cluster-essentials.yaml
deploy-cluster-essentials:
ifneq ("$(wildcard testing/educates-cluster-essentials-values.yaml)","")
ytt --file carvel-packages/cluster-essentials/bundle/config --data-values-file testing/educates-cluster-essentials-values.yaml | kapp deploy -a educates-cluster-essentials -f - -y
else
ytt --file carvel-packages/cluster-essentials/bundle/config | kapp deploy -a educates-cluster-essentials -f - -y
endif
delete-cluster-essentials:
kapp delete -a educates-cluster-essentials -y
deploy-cluster-essentials-bundle:
kubectl get ns/educates-package || kubectl create ns educates-package
kubectl apply --namespace educates-package -f package-repository/packages/cluster-essentials.educates.dev/metadata.yaml
kubectl apply --namespace educates-package -f testing/educates-cluster-essentials.yaml
ifneq ("$(wildcard testing/educates-cluster-essentials-values.yaml)","")
kctrl package install --namespace educates-package --package-install educates-cluster-essentials --package cluster-essentials.educates.dev --version $(RELEASE_VERSION) --values-file testing/educates-cluster-essentials-values.yaml
else
kctrl package install --namespace educates-package --package-install educates-cluster-essentials --package cluster-essentials.educates.dev --version $(RELEASE_VERSION)
endif
delete-cluster-essentials-bundle:
kctrl package installed delete --namespace educates-package --package-install educates-cluster-essentials -y
verify-training-platform-config:
ifneq ("$(wildcard testing/educates-training-platform-values.yaml)","")
@ytt --file carvel-packages/training-platform/bundle/config --data-values-file testing/educates-training-platform-values.yaml
else
@ytt --file carvel-packages/training-platform/bundle/config
endif
push-training-platform-bundle:
ytt -f carvel-packages/training-platform/config/images.yaml -f carvel-packages/training-platform/config/schema.yaml -v imageRegistry.host=$(IMAGE_REPOSITORY) -v version=$(PACKAGE_VERSION) > carvel-packages/training-platform/bundle/kbld-images.yaml
cat carvel-packages/training-platform/bundle/kbld-images.yaml | kbld -f - --imgpkg-lock-output carvel-packages/training-platform/bundle/.imgpkg/images.yml
imgpkg push -b $(IMAGE_REPOSITORY)/educates-training-platform:$(RELEASE_VERSION) -f carvel-packages/training-platform/bundle
mkdir -p testing
ytt -f carvel-packages/training-platform/bundle --data-values-schema-inspect -o openapi-v3 > testing/educates-training-platform-schema-openapi.yaml
ytt -f carvel-packages/training-platform/config/package.yaml -f carvel-packages/training-platform/config/schema.yaml -v imageRegistry.host=$(IMAGE_REPOSITORY) -v version=$(RELEASE_VERSION) -v releasedAt=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --data-value-file openapi=testing/educates-training-platform-schema-openapi.yaml > testing/educates-training-platform.yaml
deploy-training-platform:
ifneq ("$(wildcard testing/educates-training-platform-values.yaml)","")
ytt --file carvel-packages/training-platform/bundle/config --data-values-file testing/educates-training-platform-values.yaml | kapp deploy -a educates-training-platform -f - -y
else
ytt --file carvel-packages/training-platform/bundle/config | kapp deploy -a educates-training-platform -f - -y
endif
restart-training-platform:
kubectl rollout restart deployment/secrets-manager -n educates
kubectl rollout restart deployment/session-manager -n educates
delete-training-platform: delete-workshop
kapp delete -a educates-training-platform -y
deploy-training-platform-bundle:
kubectl get ns/educates-package || kubectl create ns educates-package
kubectl apply --namespace educates-package -f package-repository/packages/training-platform.educates.dev/metadata.yaml
kubectl apply --namespace educates-package -f testing/educates-training-platform.yaml
ifneq ("$(wildcard testing/educates-training-platform-values.yaml)","")
kctrl package install --namespace educates-package --package-install educates-training-platform --package training-platform.educates.dev --version $(RELEASE_VERSION) --values-file testing/educates-training-platform-values.yaml
else
kctrl package install --namespace educates-package --package-install educates-training-platform --package training-platform.educates.dev --version $(RELEASE_VERSION)
endif
delete-training-platform-bundle:
kctrl package installed delete --namespace educates-package --package-install educates-training-platform -y
client-programs-educates:
rm -rf client-programs/pkg/renderer/files
mkdir client-programs/pkg/renderer/files
cp -rp workshop-images/base-environment/opt/eduk8s/etc/themes client-programs/pkg/renderer/files/
(cd client-programs; go build -o educates cmd/educates/main.go)
client-programs: client-programs-educates
deploy-workshop:
kubectl apply -f https://github.com/vmware-tanzu-labs/lab-k8s-fundamentals/releases/download/5.0/workshop.yaml
kubectl apply -f https://github.com/vmware-tanzu-labs/lab-k8s-fundamentals/releases/download/5.0/trainingportal.yaml
STATUS=1; ATTEMPTS=0; ROLLOUT_STATUS_CMD="kubectl rollout status deployment/training-portal -n lab-k8s-fundamentals-ui"; until [ $$STATUS -eq 0 ] || $$ROLLOUT_STATUS_CMD || [ $$ATTEMPTS -eq 5 ]; do sleep 5; $$ROLLOUT_STATUS_CMD; STATUS=$$?; ATTEMPTS=$$((ATTEMPTS + 1)); done
delete-workshop:
-kubectl delete trainingportal,workshop lab-k8s-fundamentals --cascade=foreground
open-workshop:
URL=`kubectl get trainingportal/lab-k8s-fundamentals -o go-template={{.status.educates.url}}`; (test -x /usr/bin/xdg-open && xdg-open $$URL) || (test -x /usr/bin/open && open $$URL) || true
prune-images:
docker image prune --force
prune-docker:
docker system prune --force
prune-builds:
rm -rf workshop-images/base-environment/opt/gateway/build
rm -rf workshop-images/base-environment/opt/gateway/node_modules
rm -rf workshop-images/base-environment/opt/helper/node_modules
rm -rf workshop-images/base-environment/opt/helper/out
rm -rf workshop-images/base-environment/opt/renderer/build
rm -rf workshop-images/base-environment/opt/renderer/node_modules
rm -rf training-portal/venv
rm -f client-programs/educates
rm -rf client-programs/pkg/renderer/files
prune-registry:
docker exec educates-registry registry garbage-collect /etc/docker/registry/config.yml --delete-untagged=true
prune-all: prune-docker prune-builds prune-registry