forked from slauger/hcloud-okd4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (68 loc) · 3.81 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
.DEFAULT_GOAL := build
OPENSHIFT_MIRROR=https://mirror.openshift.com/pub/openshift-v4
OKD_RELEASE=4.7.0-0.okd-2021-03-07-090821
FCOS_STREAM=stable
FCOS_RELEASE=33.20210217.3.0
OCP_RELEASE=4.7.0
RHCOS_RELEASE=4.7.0
RHCOS_RELEASE_MINOR=$(shell echo $(RHCOS_RELEASE) | egrep -o 4\.[0-9]+)
CONTAINER_NAME=docker.io/cmon2k/openshift-toolbox
CONTAINER_TAG=$(OPENSHIFT_RELEASE)
DEPLOYMENT_TYPE?=okd
BOOTSTRAP=false
MODE=apply
ifeq ($(DEPLOYMENT_TYPE),ocp)
OPENSHIFT_RELEASE=$(OCP_RELEASE)
COREOS_IMAGE=rhcos
COREOS_RELEASE=$(RHCOS_RELEASE)
else ifeq ($(DEPLOYMENT_TYPE),okd)
OPENSHIFT_RELEASE=$(OKD_RELEASE)
COREOS_IMAGE=fcos
COREOS_RELEASE=$(FCOS_RELEASE)
else
$(error installer only supports ocp or okd)
endif
print_version:
@echo $(OPENSHIFT_RELEASE)
fetch: fetch_$(DEPLOYMENT_TYPE)
fetch_okd:
wget -O openshift-install-linux-$(OPENSHIFT_RELEASE).tar.gz https://github.com/openshift/okd/releases/download/$(OPENSHIFT_RELEASE)/openshift-install-linux-$(OPENSHIFT_RELEASE).tar.gz
wget -O openshift-client-linux-$(OPENSHIFT_RELEASE).tar.gz https://github.com/openshift/okd/releases/download/$(OPENSHIFT_RELEASE)/openshift-client-linux-$(OPENSHIFT_RELEASE).tar.gz
fetch_ocp:
wget -O openshift-install-linux-$(OPENSHIFT_RELEASE).tar.gz $(OPENSHIFT_MIRROR)/clients/ocp/$(OPENSHIFT_RELEASE)/openshift-install-linux-$(OPENSHIFT_RELEASE).tar.gz
wget -O openshift-client-linux-$(OPENSHIFT_RELEASE).tar.gz $(OPENSHIFT_MIRROR)/clients/ocp/$(OPENSHIFT_RELEASE)/openshift-client-linux-$(OPENSHIFT_RELEASE).tar.gz
build:
docker build --build-arg OPENSHIFT_RELEASE=$(OPENSHIFT_RELEASE) -t $(CONTAINER_NAME):$(CONTAINER_TAG) .
test:
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(shell pwd):/src:ro gcr.io/gcp-runtimes/container-structure-test:latest test --image $(CONTAINER_NAME):$(CONTAINER_TAG) --config /src/tests/image.tests.yaml
push:
docker push $(CONTAINER_NAME):$(CONTAINER_TAG)
run:
docker run -it --hostname openshift-toolbox --mount type=bind,source="$(shell pwd)",target=/workspace --mount type=bind,source="$(HOME)/.ssh,target=/root/.ssh" $(CONTAINER_NAME):$(CONTAINER_TAG) /bin/bash
generate_manifests:
mkdir config
cp install-config.yaml config/install-config.yaml
openshift-install create manifests --dir=config
generate_ignition:
rsync -av config/ ignition
openshift-install create ignition-configs --dir=ignition
hcloud_image:
@if [ -z "$(HCLOUD_TOKEN)" ]; then echo "ERROR: HCLOUD_TOKEN is not set"; exit 1; fi
if [ "$(DEPLOYMENT_TYPE)" == "okd" ]; then (cd packer && packer build -var fcos_stream=$(FCOS_STREAM) -var fcos_release=$(FCOS_RELEASE) hcloud-fcos.json); fi
if [ "$(DEPLOYMENT_TYPE)" == "ocp" ]; then (cd packer && packer build -var rhcos_release=$(RHCOS_RELEASE) -var rhcos_release_minor=$(RHCOS_RELEASE_MINOR) hcloud-rhcos.json); fi
sign_csr:
@if [ ! -f "ignition/auth/kubeconfig" ]; then echo "ERROR: ignition/auth/kubeconfig not found"; exit 1; fi
bash -c "export KUBECONFIG=$(shell pwd)/ignition/auth/kubeconfig; oc get csr -o name | xargs oc adm certificate approve || true"
wait_bootstrap:
openshift-install --dir=ignition/ wait-for bootstrap-complete --log-level=debug
wait_completion:
openshift-install --dir=ignition/ wait-for install-complete --log-level=debug
infrastructure:
@if [ -z "$(TF_VAR_dns_domain)" ]; then echo "ERROR: TF_VAR_dns_domain is not set"; exit 1; fi
@if [ -z "$(TF_VAR_dns_zone_id)" ]; then echo "ERROR: TF_VAR_dns_zone_id is not set"; exit 1; fi
@if [ -z "$(HCLOUD_TOKEN)" ]; then echo "ERROR: HCLOUD_TOKEN is not set"; exit 1; fi
@if [ -z "$(CLOUDFLARE_EMAIL)" ]; then echo "ERROR: CLOUDFLARE_EMAIL is not set"; exit 1; fi
(cd terraform && terraform init && terraform $(MODE) -var image=$(COREOS_IMAGE) -var bootstrap=$(BOOTSTRAP))
if [ "$(MODE)" == "apply" ]; then (cd ansible && ansible-playbook site.yml); fi
destroy:
(cd terraform && terraform init && terraform destroy)