-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathpacker.mk
executable file
·129 lines (111 loc) · 5.03 KB
/
packer.mk
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
SHELL=/bin/bash -o pipefail
GOARCH=amd64
ifeq (${ARCHITECTURE},ARM64)
GOARCH=arm64
endif
build-packer: generate-prefetch-scripts build-aks-node-controller build-lister-binary
ifeq (${ARCHITECTURE},ARM64)
@echo "${MODE}: Building with Hyper-v generation 2 ARM64 VM"
ifeq (${OS_SKU},Ubuntu)
@echo "Using packer template file vhd-image-builder-arm64-gen2.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-arm64-gen2.json
else ifeq (${OS_SKU},CBLMariner)
@echo "Using packer template file vhd-image-builder-mariner-arm64.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner-arm64.json
else ifeq (${OS_SKU},AzureLinux)
@echo "Using packer template file vhd-image-builder-mariner-arm64.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner-arm64.json
else
$(error OS_SKU was invalid ${OS_SKU})
endif
else ifeq (${ARCHITECTURE},X86_64)
ifeq (${HYPERV_GENERATION},V2)
@echo "${MODE}: Building with Hyper-v generation 2 x86_64 VM"
else ifeq (${HYPERV_GENERATION},V1)
@echo "${MODE}: Building with Hyper-v generation 1 X86_64 VM"
else
$(error HYPERV_GENERATION was invalid ${HYPERV_GENERATION})
endif
ifeq (${OS_SKU},Ubuntu)
@echo "Using packer template file: vhd-image-builder-base.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-base.json
else ifeq (${OS_SKU},CBLMariner)
@echo "Using packer template file vhd-image-builder-mariner.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner.json
else ifeq (${OS_SKU},AzureLinux)
@echo "Using packer template file vhd-image-builder-mariner.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-mariner.json
else
$(error OS_SKU was invalid ${OS_SKU})
endif
endif
build-packer-windows:
ifeq (${MODE},windowsVhdMode)
ifeq (${SIG_FOR_PRODUCTION},True)
ifeq (${HYPERV_GENERATION},V1)
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Classic Storage Account"
else
@echo "${MODE}: Building with Hyper-v generation 2 VM and save to Classic Storage Account"
endif
else
ifeq (${HYPERV_GENERATION},V1)
@echo "${MODE}: Building with Hyper-v generation 1 VM and save to Shared Image Gallery"
else
@echo "${MODE}: Building with Hyper-v generation 2 VM and save to Shared Image Gallery"
endif
endif
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/windows-vhd-builder-sig.json
endif
az-login:
ifeq (${MODE},windowsVhdMode)
ifeq ($(origin MANAGED_IDENTITY_ID), undefined)
@echo "Logging in with Hosted Pool's Default Managed Identity"
@az login --identity
else
@echo "Logging in with Hosted Pool's Managed Identity: ${MANAGED_IDENTITY_ID}"
@az login --identity --username ${MANAGED_IDENTITY_ID}
endif
else
@echo "Logging into Azure with identity: ${AZURE_MSI_RESOURCE_STRING}..."
@az login --identity --username ${AZURE_MSI_RESOURCE_STRING}
endif
@echo "Using the subscription ${SUBSCRIPTION_ID}"
@az account set -s ${SUBSCRIPTION_ID}
init-packer:
@./vhdbuilder/packer/init-variables.sh
run-packer: az-login
@packer init ./vhdbuilder/packer/linux-packer-plugin.pkr.hcl && packer version && ($(MAKE) -f packer.mk init-packer | tee packer-output) && ($(MAKE) -f packer.mk build-packer | tee -a packer-output)
run-packer-windows: az-login
@packer init ./vhdbuilder/packer/packer-plugin.pkr.hcl && packer version && ($(MAKE) -f packer.mk init-packer | tee packer-output) && ($(MAKE) -f packer.mk build-packer-windows | tee -a packer-output)
cleanup: az-login
@./vhdbuilder/packer/cleanup.sh
backfill-cleanup: az-login
@chmod +x ./vhdbuilder/packer/backfill-cleanup.sh
@./vhdbuilder/packer/backfill-cleanup.sh
generate-publishing-info: az-login
@./vhdbuilder/packer/generate-vhd-publishing-info.sh
convert-sig-to-classic-storage-account-blob: az-login
@./vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh
test-building-vhd: az-login
@./vhdbuilder/packer/test/run-test.sh
scanning-vhd: az-login
@./vhdbuilder/packer/vhd-scanning.sh
test-scan-and-cleanup: az-login
@./vhdbuilder/packer/test-scan-and-cleanup.sh
evaluate-build-performance: az-login
@./vhdbuilder/packer/build-performance/evaluate-build-performance.sh
generate-prefetch-scripts:
#ifeq (${MODE},linuxVhdMode)
@echo "${MODE}: Generating prefetch scripts"
@bash -c "pushd vhdbuilder/prefetch; go run cmd/main.go --components-path=../../parts/linux/cloud-init/artifacts/components.json --output-path=../packer/prefetch.sh || exit 1; popd"
#endif
build-aks-node-controller:
@echo "Building aks-node-controller binaries"
@bash -c "pushd aks-node-controller && \
go test ./... && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/aks-node-controller-linux-amd64 && \
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/aks-node-controller-linux-arm64 && \
popd"
build-lister-binary:
@echo "Building lister binary for $(GOARCH)"
@bash -c "pushd vhdbuilder/lister && CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -o bin/lister main.go && popd"