-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
179 lines (168 loc) · 6.24 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
# Copyright 2023 VMware, Inc.
# SPDX-License-Identifier: MPL-2.0
SHELL := /usr/bin/env bash -o errexit -o pipefail -o nounset
MAKEFLAGS += -s
.DEFAULT_GOAL := help
.EXPORT_ALL_VARIABLES:
# Default variables
BYOI_IMAGE_NAME = vsphere-tanzu-byoi
DEFAULT_ARTIFACTS_CONTAINER_PORT = 8081
MAKE_HELPERS_PATH = $(shell pwd)/hack/make-helpers
SUPPORTED_VERSIONS_JSON = $(shell pwd)/supported-versions.json
# Terminal colors
clear=\033[0m
green=\033[0;32m
define LIST_VERSIONS_HELP_INFO
# To list supported Kubernetes versions and their corresponding supported OS targets
#
# Example:
# make list-versions
endef
.PHONY: list-versions
ifeq ($(PRINT_HELP),y)
list-versions:
printf "$$green$$LIST_VERSIONS_HELP_INFO$$clear\n"
else
list-versions:
$(MAKE_HELPERS_PATH)/list-versions.sh
endif
define RUN_ARTIFACTS_CONTAINER_HELP_INFO
# Runs the artifacts container for a Kubernetes version.
#
# Arguments:
# KUBERNETES_VERSION: [Required] kubernetes version of the artifacts containers, to see
# list of supported kubernetes versions use "make list-versions"
# ARTIFACTS_CONTAINER_PORT: [Optional] container port, if not provided
# defaults to $(DEFAULT_ARTIFACTS_CONTAINER_PORT)
# Example:
# make run-artifacts-container KUBERNETES_VERSION=v1.22.13+vmware.1
# make run-artifacts-container KUBERNETES_VERSION=v1.22.13+vmware.1 ARTIFACTS_CONTAINER_PORT=9090
endef
.PHONY: run-artifacts-container
ifeq ($(PRINT_HELP),y)
run-artifacts-container:
printf "$$green$$RUN_ARTIFACTS_CONTAINER_HELP_INFO$$clear\n"
else
run-artifacts-container:
$(MAKE_HELPERS_PATH)/run-artifacts-container.sh -p $(ARTIFACTS_CONTAINER_PORT) -k $(KUBERNETES_VERSION)
endif
define BUILD_IMAGE_BUILDER_CONTAINER_HELP_INFO
# Will create a docker container image for creation of TKGs OVA with the dependencies
# like packer, ansible and kubernetes image builder code.
#
# Example:
# make build-image-builder-container
endef
.PHONY: build-image-builder-container
ifeq ($(PRINT_HELP),y)
build-image-builder-container:
printf "$$green$$BUILD_IMAGE_BUILDER_CONTAINER_HELP_INFO$$clear\n"
else
build-image-builder-container:
docker build -q -t $(BYOI_IMAGE_NAME) .
endif
define BUILD_NODE_IMAGE
# To build vSphere Tanzu Kubernetes Grid compliant node images
#
# Arguments:
# OS_TARGET: [Required] Node Image OS target, to see list of supported OS target
# use "make list-versions".
# KUBERNETES_VERSION: [Required] kubernetes version of the artifacts containers, to see
# list of supported kubernetes versions use "make list-versions".
# TKR_SUFFIX: [Required] TKR suffix for the generated Node image, this can be used to
# distinguish different node images.
# IMAGE_ARTIFACTS_PATH: [Required] Node image OVA and packer logs output folder.
# ARTIFACTS_CONTAINER_IP: [Required] Host IP on where artifacts container is running.
# ARTIFACTS_CONTAINER_PORT: [Optional] Artifacts container port, defaults to $(DEFAULT_ARTIFACTS_CONTAINER_PORT)
#
# Example:
# make build-node-image OS_TARGET=photon-3 KUBERNETES_VERSION=v1.23.15+vmware.1 TKR_SUFFIX=byoi ARTIFACTS_CONTAINER_IP=1.2.3.4 IMAGE_ARTIFACTS_PATH=$(HOME)/image
# make build-node-image OS_TARGET=photon-3 KUBERNETES_VERSION=v1.23.15+vmware.1 TKR_SUFFIX=byoi ARTIFACTS_CONTAINER_IP=1.2.3.4 IMAGE_ARTIFACTS_PATH=$(HOME)/image ARTIFACTS_CONTAINER_PORT=9090
endef
.PHONY: build-node-image
ifeq ($(PRINT_HELP),y)
build-node-image:
printf "$$green$$BUILD_NODE_IMAGE$$clear\n"
else
build-node-image: build-image-builder-container
$(MAKE_HELPERS_PATH)/build-node-image.sh
endif
define CLEAN_CONTAINERS_HELP_IFO
# To Stops and remove BYOI related docker containers
#
# Arguments:
# LABEL: [Optional] To delete containers selectively based on labels
# When docker containers are created they are labeled with the below keys, both artifacts and
# image builder container will have the "byoi" label key. Artifacts containers will have
# "byoi_artifacts" and Kubernetes version label keys are added. Image builder containers
# will have "byoi_image_builder", Kubernetes version, and OS target label keys are added
# Example:
# make clean-containers
# make clean-containers LABEL=byoi
# make clean-containers LABEL=byoi_artifacts
# make clean-containers LABEL=byoi_image_builder
# make clean-containers LABEL=v1.23.15+vmware.1
# make clean-containers LABEL=photon-3
endef
.PHONY: clean-containers
ifeq ($(PRINT_HELP),y)
clean-containers:
printf "$$green$$CLEAN_CONTAINERS_HELP_IFO$$clear\n"
else
clean-containers:
$(MAKE_HELPERS_PATH)/clean-containers.sh
endif
define CLEAN_IMAGE_ARTIFACTS_HELP_INFO
# To clean the artifacts generated by the image builder container
#
# Arguments:
# IMAGE_ARTIFACTS_PATH: [Required] Node image OVA and packer logs output folder.
#
# Example:
# make clean-image-artifacts IMAGE_ARTIFACTS_PATH=$(HOME)/image-artifacts
endef
.PHONY: clean-image-artifacts
ifeq ($(PRINT_HELP),y)
clean-image-artifacts:
printf "$$green$$CLEAN_IMAGE_ARTIFACTS_HELP_INFO$$clear\n"
else
clean-image-artifacts:
$(MAKE_HELPERS_PATH)/clean-image-artifacts.sh
endif
define CLEAN_HELP_INFO
# To clean the artifacts and containers generated or created when building the image
#
# Arguments:
# IMAGE_ARTIFACTS_PATH: [Required] Node image OVA and packer logs output folder.
# LABEL: [Optional] To delete containers selectively based on labels
# When docker containers are created they are labeled with the below keys, both artifacts and
# image builder container will have the "byoi" label key. Artifacts containers will have
# "byoi_artifacts" and Kubernetes version label keys are added. Image builder containers
# will have "byoi_image_builder", Kubernetes version, and OS target label keys are added
#
# Example:
# make clean IMAGE_ARTIFACTS_PATH=$(HOME)/image-artifacts
# make clean IMAGE_ARTIFACTS_PATH=$(HOME)/image-artifacts LABEL=byoi
endef
.PHONY: clean
ifeq ($(PRINT_HELP),y)
clean:
printf "$$green$$CLEAN_HELP_INFO$$clear\n"
else
clean: clean-containers clean-image-artifacts
endif
define HELP_INFO
# Use to list supported Kubernetes versions and the corresponding supported OS targets
#
# Example:
# make
# make help
endef
.PHONY: help
ifeq ($(PRINT_HELP),y)
help:
printf "$$green$$HELP_INFO$$clear\n"
else
help: ## help
$(MAKE_HELPERS_PATH)/make-help.sh
endif