forked from openshift/assisted-test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
216 lines (154 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
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
#############
# Variables #
#############
SHELL=/bin/sh
CONTAINER_COMMAND = $(shell if [ -x "$(shell command -v docker)" ];then echo "docker" ; else echo "podman";fi)
PULL_PARAM=$(shell if [ "${CONTAINER_COMMAND}" = "podman" ];then echo "--pull-always" ; else echo "--pull";fi)
SKIPPER_PARAMS ?= -i
# bm-inventory
BMI_BRANCH := $(or $(BMI_BRANCH), "master")
SERVICE := $(or $(SERVICE), quay.io/ocpmetal/bm-inventory:latest)
# nodes params
ISO := $(or $(ISO), "") # ISO should point to a file that has the '.iso' extension. Otherwise deploy will fail!
NUM_MASTERS := $(or $(NUM_MASTERS),3)
WORKER_MEMORY ?= 8892
MASTER_MEMORY ?= 16984
NUM_WORKERS := $(or $(NUM_WORKERS),0)
STORAGE_POOL_PATH := $(or $(STORAGE_POOL_PATH), $(PWD)/storage_pool)
CLUSTER_ID := $(or $(CLUSTER_ID), "")
CLUSTER_NAME := $(or $(CLUSTER_NAME),test-infra-cluster)
OPENSHIFT_VERSION := $(or $(OPENSHIFT_VERSION), 4.5)
REMOTE_INVENTORY_URL := $(or $(REMOTE_INVENTORY_URL), "")
# network params
BASE_DNS_DOMAINS := $(or $(BASE_DNS_DOMAINS), "")
BASE_DOMAIN := $(or $(BASE_DOMAIN),redhat.com)
NETWORK_CIDR := $(or $(NETWORK_CIDR),"192.168.126.0/24")
NETWORK_NAME := $(or $(NETWORK_NAME), test-infra-net)
NETWORK_BRIDGE := $(or $(NETWORK_BRIDGE), tt0)
PROXY_URL := $(or $(PROXY_URL), "")
RUN_WITH_VIPS := $(or $(RUN_WITH_VIPS), "yes")
# secrets
SSH_PUB_KEY := $(or $(SSH_PUB_KEY),$(shell cat ssh_key/key.pub))
PULL_SECRET := $(or $(PULL_SECRET), $(shell if ! [ -z "${PULL_SECRET_FILE}" ];then cat ${PULL_SECRET_FILE};fi))
ROUTE53_SECRET := $(or $(ROUTE53_SECRET), "")
# deploy
IMAGE_TAG := latest
DEPLOY_TAG := $(or $(DEPLOY_TAG), "")
IMAGE_NAME=test-infra
IMAGE_REG_NAME=quay.io/itsoiref/$(IMAGE_NAME)
.EXPORT_ALL_VARIABLES:
.PHONY: image_build run destroy start_minikube delete_minikube run destroy install_minikube deploy_bm_inventory create_environment delete_all_virsh_resources _download_iso _deploy_bm_inventory _deploy_nodes _destroy_terraform
###########
# General #
###########
all: create_full_environment run_full_flow_with_install
destroy: destroy_nodes delete_minikube
rm -rf build/terraform/*
###############
# Environment #
###############
create_full_environment:
./create_full_environment.sh
create_environment: image_build bring_bm_inventory start_minikube
image_build:
sed 's/^FROM .*bm-inventory.*:latest/FROM $(subst /,\/,${SERVICE})/' Dockerfile.test-infra | \
$(CONTAINER_COMMAND) build ${PULL_PARAM} -t $(IMAGE_NAME):$(IMAGE_TAG) -f- .
clean:
rm -rf build
rm -rf bm-inventory
############
# Minikube #
############
install_minikube:
scripts/install_minikube.sh
start_minikube:
scripts/run_minikube.sh
eval $(minikube docker-env)
delete_minikube:
minikube delete
skipper run discovery-infra/virsh_cleanup.py -m
#############
# Terraform #
#############
copy_terraform_files:
mkdir -p build/terraform
FILE=build/terraform/terraform.tfvars.json
cp -r terraform_files/* build/terraform/;\
run_terraform: copy_terraform_files
skipper make _run_terraform $(SKIPPER_PARAMS)
_run_terraform:
cd build/terraform/ && \
terraform init -plugin-dir=/root/.terraform.d/plugins/ && \
terraform apply -auto-approve -input=false -state=terraform.tfstate -state-out=terraform.tfstate -var-file=terraform.tfvars.json
destroy_terraform:
skipper make _destroy_terraform $(SKIPPER_PARAMS)
_destroy_terraform:
cd build/terraform/ && terraform destroy -auto-approve -input=false -state=terraform.tfstate -state-out=terraform.tfstate -var-file=terraform.tfvars.json || echo "Failed cleanup terraform"
discovery-infra/virsh_cleanup.py -f test-infra
#######
# Run #
#######
run: deploy_bm_inventory deploy_ui
run_full_flow: run deploy_nodes set_dns
redeploy_all: destroy run_full_flow
run_full_flow_with_install: run deploy_nodes_with_install set_dns
redeploy_all_with_install: destroy run_full_flow_with_install
set_dns:
scripts/assisted_deployment.sh set_dns
deploy_ui: start_minikube
DEPLOY_TAG=$(DEPLOY_TAG) scripts/deploy_ui.sh
test_ui: deploy_ui
DEPLOY_TAG=$(DEPLOY_TAG) PULL_SECRET=${PULL_SECRET} scripts/test_ui.sh
kill_all_port_forwardings:
scripts/utils.sh kill_all_port_forwardings
###########
# Cluster #
###########
_install_cluster:
discovery-infra/install_cluster.py -id $(CLUSTER_ID) -ps '$(PULL_SECRET)'
install_cluster:
skipper make _install_cluster $(SKIPPER_PARAMS)
#########
# Nodes #
#########
_deploy_nodes:
discovery-infra/start_discovery.py -i $(ISO) -n $(NUM_MASTERS) -p $(STORAGE_POOL_PATH) -k '$(SSH_PUB_KEY)' -mm $(MASTER_MEMORY) -wm $(WORKER_MEMORY) -nw $(NUM_WORKERS) -ps '$(PULL_SECRET)' -bd $(BASE_DOMAIN) -cN $(CLUSTER_NAME) -vN $(NETWORK_CIDR) -nN $(NETWORK_NAME) -nB $(NETWORK_BRIDGE) -ov $(OPENSHIFT_VERSION) -rv $(RUN_WITH_VIPS) -iU $(REMOTE_INVENTORY_URL) -id $(CLUSTER_ID) -mD $(BASE_DNS_DOMAINS) $(ADDITIONAL_PARAMS)
deploy_nodes_with_install:
skipper make _deploy_nodes ADDITIONAL_PARAMS=-in $(SKIPPER_PARAMS)
deploy_nodes:
skipper make _deploy_nodes $(SKIPPER_PARAMS)
destroy_nodes:
skipper run 'discovery-infra/delete_nodes.py -iU $(REMOTE_INVENTORY_URL) -id $(CLUSTER_ID)' $(SKIPPER_PARAMS)
redeploy_nodes: destroy_nodes deploy_nodes
redeploy_nodes_with_install: destroy_nodes deploy_nodes_with_install
#############
# Inventory #
#############
deploy_bm_inventory: start_minikube bring_bm_inventory
mkdir -p bm-inventory/build
DEPLOY_TAG=$(DEPLOY_TAG) scripts/deploy_bm_inventory.sh
bring_bm_inventory:
@if cd bm-inventory >/dev/null 2>&1; then git fetch --all && git reset --hard origin/$(BMI_BRANCH); else git clone --branch $(BMI_BRANCH) https://github.com/filanov/bm-inventory;fi
deploy_monitoring: bring_bm_inventory
make -C bm-inventory/ deploy-monitoring
clear_inventory:
make -C bm-inventory/ clear-deployment
delete_all_virsh_resources: destroy_nodes delete_minikube
skipper run 'discovery-infra/delete_nodes.py -a' $(SKIPPER_PARAMS)
#######
# ISO #
#######
_download_iso:
discovery-infra/start_discovery.py -k '$(SSH_PUB_KEY)' -ps '$(PULL_SECRET)' -bd $(BASE_DOMAIN) -cN $(CLUSTER_NAME) -ov $(OPENSHIFT_VERSION) -pU $(PROXY_URL) -iU $(REMOTE_INVENTORY_URL) -id $(CLUSTER_ID) -mD $(BASE_DNS_DOMAINS) -iO
download_iso:
skipper make _download_iso $(SKIPPER_PARAMS)
download_iso_for_remote_use: deploy_bm_inventory
skipper make _download_iso $(SKIPPER_PARAMS)
########
# Test #
########
lint:
mkdir -p build
skipper make _lint
_lint:
pre-commit run --all-files