forked from projectcalico/calico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
203 lines (176 loc) · 7.43 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
PACKAGE_NAME = github.com/projectcalico/calico
include metadata.mk
include lib.Makefile
DOCKER_RUN := mkdir -p ./.go-pkg-cache bin $(GOMOD_CACHE) && \
docker run --rm \
--net=host \
--init \
$(EXTRA_DOCKER_ARGS) \
-e LOCAL_USER_ID=$(LOCAL_USER_ID) \
-e GOCACHE=/go-cache \
$(GOARCH_FLAGS) \
-e GOPATH=/go \
-e OS=$(BUILDOS) \
-e GOOS=$(BUILDOS) \
-e GOFLAGS=$(GOFLAGS) \
-v $(CURDIR):/go/src/github.com/projectcalico/calico:rw \
-v $(CURDIR)/.go-pkg-cache:/go-cache:rw \
-w /go/src/$(PACKAGE_NAME)
clean:
$(MAKE) -C api clean
$(MAKE) -C apiserver clean
$(MAKE) -C app-policy clean
$(MAKE) -C calicoctl clean
$(MAKE) -C cni-plugin clean
$(MAKE) -C confd clean
$(MAKE) -C felix clean
$(MAKE) -C kube-controllers clean
$(MAKE) -C libcalico-go clean
$(MAKE) -C node clean
$(MAKE) -C pod2daemon clean
$(MAKE) -C typha clean
rm -rf ./bin
ci-preflight-checks:
$(MAKE) check-dockerfiles
$(MAKE) check-language
$(MAKE) generate
$(MAKE) check-dirty
check-dockerfiles:
./hack/check-dockerfiles.sh
check-language:
./hack/check-language.sh
generate:
$(MAKE) gen-semaphore-yaml
$(MAKE) -C api gen-files
$(MAKE) -C libcalico-go gen-files
$(MAKE) -C felix gen-files
$(MAKE) -C calicoctl gen-crds
$(MAKE) -C app-policy protobuf
$(MAKE) gen-manifests
gen-manifests: bin/helm
cd ./manifests && \
OPERATOR_VERSION=$(OPERATOR_VERSION) \
CALICO_VERSION=$(CALICO_VERSION) \
./generate.sh
# Get operator CRDs from the operator repo, OPERATOR_BRANCH_NAME must be set
get-operator-crds: var-require-all-OPERATOR_BRANCH_NAME
cd ./charts/tigera-operator/crds/ && \
for file in operator.tigera.io_*.yaml; do echo "downloading $$file from operator repo" && curl -fsSL https://raw.githubusercontent.com/tigera/operator/${OPERATOR_BRANCH_NAME}/pkg/crds/operator/$${file%_crd.yaml}.yaml -o $${file}; done
cd ./manifests/ocp/ && \
for file in operator.tigera.io_*.yaml; do echo "downloading $$file from operator repo" && curl -fsSL https://raw.githubusercontent.com/tigera/operator/${OPERATOR_BRANCH_NAME}/pkg/crds/operator/$${file%_crd.yaml}.yaml -o $${file}; done
gen-semaphore-yaml:
cd .semaphore && ./generate-semaphore-yaml.sh
# Build the tigera-operator helm chart.
chart: bin/tigera-operator-$(GIT_VERSION).tgz
bin/tigera-operator-$(GIT_VERSION).tgz: bin/helm $(shell find ./charts/tigera-operator -type f)
bin/helm package ./charts/tigera-operator \
--destination ./bin/ \
--version $(GIT_VERSION) \
--app-version $(GIT_VERSION)
# Build all Calico images for the current architecture.
image:
$(MAKE) -C pod2daemon image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C calicoctl image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C cni-plugin image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C apiserver image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C kube-controllers image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C app-policy image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C typha image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
$(MAKE) -C node image IMAGETAG=$(GIT_VERSION) VALIDARCHES=$(ARCH)
###############################################################################
# Run local e2e smoke test against the checked-out code
# using a local kind cluster.
###############################################################################
E2E_FOCUS ?= "sig-network.*Conformance"
ADMINPOLICY_UNSUPPORTED_FEATURES ?= "BaselineAdminNetworkPolicy"
e2e-test:
$(MAKE) -C e2e build
$(MAKE) -C node kind-k8st-setup
KUBECONFIG=$(KIND_KUBECONFIG) ./e2e/bin/k8s/e2e.test -ginkgo.focus=$(E2E_FOCUS)
KUBECONFIG=$(KIND_KUBECONFIG) ./e2e/bin/adminpolicy/e2e.test -exempt-features=$(ADMINPOLICY_UNSUPPORTED_FEATURES)
###############################################################################
# Release logic below
###############################################################################
# Build the release tool.
release/bin/release: $(shell find ./release -type f -name '*.go')
$(call build_binary, ./release/build, $@)
# Install ghr for publishing to github.
bin/ghr:
$(DOCKER_RUN) -e GOBIN=/go/src/$(PACKAGE_NAME)/bin/ $(CALICO_BUILD) go install github.com/tcnksm/ghr@v0.14.0
# Build a release.
release: release/bin/release
@release/bin/release release build
# Publish an already built release.
release-publish: release/bin/release bin/ghr
@release/bin/release release publish
# Create a release branch.
create-release-branch: release/bin/release
@release/bin/release branch cut -git-publish
# Test the release code
release-test:
$(DOCKER_RUN) $(CALICO_BUILD) ginkgo -cover -r release/pkg
# Currently our openstack builds either build *or* build and publish,
# hence why we have two separate jobs here that do almost the same thing.
build-openstack: bin/yq
$(eval VERSION=$(shell bin/yq '.version' charts/calico/values.yaml))
$(info Building openstack packages for version $(VERSION))
$(MAKE) -C release/packaging release VERSION=$(VERSION)
publish-openstack: bin/yq
$(eval VERSION=$(shell bin/yq '.version' charts/calico/values.yaml))
$(info Publishing openstack packages for version $(VERSION))
$(MAKE) -C release/packaging release-publish VERSION=$(VERSION)
## Kicks semaphore job which syncs github released helm charts with helm index file
.PHONY: helm-index
helm-index:
@echo "Triggering semaphore workflow to update helm index."
SEMAPHORE_PROJECT_ID=30f84ab3-1ea9-4fb0-8459-e877491f3dea \
SEMAPHORE_WORKFLOW_BRANCH=master \
SEMAPHORE_WORKFLOW_FILE=../releases/calico/helmindex/update_helm.yml \
$(MAKE) semaphore-run-workflow
# Creates the tar file used for installing Calico on OpenShift.
bin/ocp.tgz: manifests/ocp/ bin/yq
mkdir -p bin/tmp
cp -r manifests/ocp bin/tmp/
$(DOCKER_RUN) $(CALICO_BUILD) /bin/bash -c " \
for file in bin/tmp/ocp/*crd* ; \
do bin/yq -i 'del(.. | select(has(\"description\")).description)' \$$file ; \
done"
tar czvf $@ -C bin/tmp ocp
rm -rf bin/tmp
## Generates release notes for the given version.
.PHONY: release-notes
release-notes:
@$(MAKE) -C release release-notes
## Update the AUTHORS.md file.
update-authors:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN must be set)
endif
@echo "# Calico authors" > AUTHORS.md
@echo "" >> AUTHORS.md
@echo "This file is auto-generated based on commit records reported" >> AUTHORS.md
@echo "by git for the projectcalico/calico repository. It is ordered alphabetically." >> AUTHORS.md
@echo "" >> AUTHORS.md
@docker run -ti --rm --net=host \
-v $(REPO_ROOT):/code \
-w /code \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
python:3 \
bash -c '/usr/local/bin/python release/get-contributors.py >> /code/AUTHORS.md'
###############################################################################
# Post-release validation
###############################################################################
POSTRELEASE_IMAGE=calico/postrelease
POSTRELEASE_IMAGE_CREATED=.calico.postrelease.created
$(POSTRELEASE_IMAGE_CREATED):
cd hack/postrelease && docker build -t $(POSTRELEASE_IMAGE) .
touch $@
postrelease-checks: $(POSTRELEASE_IMAGE_CREATED)
$(DOCKER_RUN) \
-v /var/run/docker.sock:/var/run/docker.sock \
-e VERSION=$(VERSION) \
-e FLANNEL_VERSION=$(FLANNEL_VERSION) \
-e VPP_VERSION=$(VPP_VERSION) \
-e OPERATOR_VERSION=$(OPERATOR_VERSION) \
$(POSTRELEASE_IMAGE) \
sh -c "nosetests hack/postrelease -e "$(EXCLUDE_REGEX)" -s -v --with-xunit --xunit-file='postrelease-checks.xml' --with-timer $(EXTRA_NOSE_ARGS)"