-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (43 loc) · 1.68 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
# Packer
PACKER_IMAGE = hashicorp/packer:1.6.6
PACKER = docker run -it --rm \
-v $(PWD)/packer/:/root \
--workdir /root \
$(PACKER_IMAGE)
# Terraform
TERRAFORM_IMAGE = hashicorp/terraform:0.14.5
TERRAFORM = docker run -it --rm \
-v $(PWD)/terraform/:/root \
--workdir /root \
$(TERRAFORM_IMAGE)
# Build settings
ZONE ?= "ch-dk-2"
.PHONY: packer.build
packer.build: check-env
@$(PACKER) build -var api_key="$(EXOSCALE_API_KEY)" -var api_secret="$(EXOSCALE_API_SECRET)" -var zone=$(ZONE) kubernetes.pkr.hcl
.PHONY: packer.deps
packer.deps:
mkdir -p $(PWD)/packer/.packer.d/plugins && wget -qO - https://github.com/exoscale/packer-builder-exoscale/releases/download/v0.2.3/packer-builder-exoscale_0.2.3_linux_amd64.tar.gz | tar -xvzf - -C $(PWD)/packer/.packer.d/plugins packer-builder-exoscale
.PHONY: terraform.init
terraform.init: check-env
@$(TERRAFORM) init -var api_key="$(EXOSCALE_API_KEY)" -var api_secret="$(EXOSCALE_API_SECRET)" -var zone=$(ZONE)
.PHONY: terraform.apply
terraform.apply: check-env
@$(TERRAFORM) apply -var api_key="$(EXOSCALE_API_KEY)" -var api_secret="$(EXOSCALE_API_SECRET)" -var zone=$(ZONE)
.PHONY: terraform.destroy
terraform.destroy: check-env
@$(TERRAFORM) destroy -var api_key="$(EXOSCALE_API_KEY)" -var api_secret="$(EXOSCALE_API_SECRET)" -var zone=$(ZONE)
.PHONY: ssh-cp
ssh-cp: check-env
@$(TERRAFORM) output -raw provisioning_private_key > .ssh
@chmod 0600 .ssh
@ssh -i .ssh ubuntu@$(shell $(TERRAFORM) output control_plane_public_ip)
@rm .ssh
.PHONY: check-env
check-env:
ifndef EXOSCALE_API_KEY
$(error EXOSCALE_API_KEY environment variable must be set)
endif
ifndef EXOSCALE_API_SECRET
$(error EXOSCALE_API_SECRET environment variable must be set)
endif