Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch calico manifests from release artifacts #2149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ hack/boilerplate/*.pyc

# release notes
_releasenotes

# calico manifests archive
release-*/manifests/calico-*.yaml
CecileRobertMichon marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,21 @@ generate-e2e-templates: $(KUSTOMIZE) ## Generate Azure infrastructure templates
$(KUSTOMIZE) build $(AZURE_TEMPLATES)/v1beta1/cluster-template-kcp-scale-in --load-restrictor LoadRestrictionsNone > $(AZURE_TEMPLATES)/v1beta1/cluster-template-kcp-scale-in.yaml

.PHONY: generate-addons
generate-addons: ## Generate metric-server, calico calico-ipv6 addons.
generate-addons: fetch-calico-manifests ## Generate metric-server, calico calico-ipv6 addons.
$(KUSTOMIZE) build $(ADDONS_DIR)/metrics-server > $(ADDONS_DIR)/metrics-server/metrics-server.yaml
$(KUSTOMIZE) build $(ADDONS_DIR)/calico > $(ADDONS_DIR)/calico.yaml
$(KUSTOMIZE) build $(ADDONS_DIR)/calico-ipv6 > $(ADDONS_DIR)/calico-ipv6.yaml

# When updating this, make sure to also update the Windows image version in templates/addons/windows/calico.
CALICO_VERSION := v3.22.1

.PHONY: fetch-calico-manifests
fetch-calico-manifests: ## Get Calico release manifests and unzip them.
@echo "Fetching Calico release manifests from release artifacts, this might take a minute..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this get fetched everytime? can us a file locally prevent that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everytime. The issue I'm trying to deal with is having to fetch it everytime vs. making sure generated files aren't outdated. If we don't fetch it how do we know the base manifest wasn't manually edited?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we drop a symlink to a versioned file name, to check if it is been downloaded and do a diff with previous version on the file to determine if it was changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do a diff with previous version on the file

Are you saying looking at a previous git version to compare the file? our CI just checks out the branch it's running on, we don't have any precedent with comparing things in previous versions... If I make it compare with "main" it wouldn't be accurate once this gets put into a release branch if we want to do a backport and the main file has changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the durations in job history for make verify (https://prow.k8s.io/job-history/gs/kubernetes-jenkins/pr-logs/directory/pull-cluster-api-provider-azure-verify) it doesn't look like this is adding that much extra time compared to previous runs, we're talking about ~ 1 minute difference so if we can't find a way around it I think we can take the hit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking from a developer experience perspective since generate flavors calls this:

generate-flavors: $(KUSTOMIZE) generate-addons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the diff on my machine (it's pretty slow so might be faster for others):

➜  cluster-api-provider-azure git:(main) ✗ time make generate-flavors
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/metrics-server > templates/addons/metrics-server/metrics-server.yaml
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/calico > templates/addons/calico.yaml
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/calico-ipv6 > templates/addons/calico-ipv6.yaml
./hack/gen-flavors.sh
make generate-flavors  37.28s user 2.41s system 98% cpu 40.261 total


➜  cluster-api-provider-azure git:(fix-calico-fetch) time make generate-flavors
Fetching Calico release manifests from release artifacts, this might take a minute...
wget -qO- https://github.com/projectcalico/calico/releases/download/v3.22.1/release-v3.22.1.tgz | tar xz release-v3.22.1/manifests/calico-vxlan.yaml release-v3.22.1/manifests/calico-policy-only.yaml
mv release-v3.22.1/manifests/calico-vxlan.yaml templates/addons/calico
mv release-v3.22.1/manifests/calico-policy-only.yaml templates/addons/calico-ipv6
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/metrics-server > templates/addons/metrics-server/metrics-server.yaml
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/calico > templates/addons/calico.yaml
/Users/cerobert/go/src/sigs.k8s.io/cluster-api-provider-azure/hack/tools/bin/kustomize-v4.5.2 build templates/addons/calico-ipv6 > templates/addons/calico-ipv6.yaml
./hack/gen-flavors.sh
make generate-flavors  43.69s user 4.54s system 49% cpu 1:36.70 total

I was using the make verify job for comparison because it runs a full make generate (which includes make generate-flavors)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to add about six seconds to the related make targets, at least for me. I think that's acceptable.

wget -qO- https://github.com/projectcalico/calico/releases/download/$(CALICO_VERSION)/release-$(CALICO_VERSION).tgz | tar xz release-$(CALICO_VERSION)/manifests/calico-vxlan.yaml release-$(CALICO_VERSION)/manifests/calico-policy-only.yaml
mv release-$(CALICO_VERSION)/manifests/calico-vxlan.yaml $(ADDONS_DIR)/calico
mv release-$(CALICO_VERSION)/manifests/calico-policy-only.yaml $(ADDONS_DIR)/calico-ipv6

.PHONY: modules
modules: ## Runs go mod tidy to ensure proper vendoring.
go mod tidy
Expand Down
Loading