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

Add build info for CAPX #1313

Merged
merged 8 commits into from
Sep 29, 2022
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
5 changes: 5 additions & 0 deletions UPSTREAM_PROJECTS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ projects:
- name: metallb
versions:
- tag: v0.12.1
- org: nutanix-cloud-native
repos:
- name: cluster-api-provider-nutanix
versions:
- tag: v0.5.1
- org: rancher
repos:
- name: local-path-provisioner
Expand Down
4 changes: 3 additions & 1 deletion build/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ function build::gather_licenses() {

# the version of go used here must be the version go-licenses was installed with
# by default we use 1.16, but due to changes in 1.17, there are some changes that require using 1.17
if [ "$golang_version" == "1.18" ]; then
if [ "$golang_version" == "1.19" ]; then
build::common::use_go_version 1.19
elif [ "$golang_version" == "1.18" ]; then
build::common::use_go_version 1.18
elif [ "$golang_version" == "1.17" ]; then
build::common::use_go_version 1.17
Expand Down
4 changes: 4 additions & 0 deletions build/lib/install_go_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ setupgo "${GOLANG115_VERSION:-1.15.15}"
setupgo "${GOLANG116_VERSION:-1.16.15}"
setupgo "${GOLANG117_VERSION:-1.17.12}"
setupgo "${GOLANG118_VERSION:-1.18.5}"
setupgo "${GOLANG119_VERSION:-1.19.1}"

# use 1.16 or 1.17 when installing and running go-licenses
# go-licenses needs to be installed by the same version of go that is being used
Expand All @@ -53,6 +54,9 @@ GOBIN=${GOPATH}/go1.17/bin go install github.com/google/[email protected]
build::common::use_go_version "1.18"
GOBIN=${GOPATH}/go1.18/bin go install github.com/google/[email protected]

build::common::use_go_version "1.19"
GOBIN=${GOPATH}/go1.19/bin go install github.com/google/[email protected]
Comment on lines +57 to +58
Copy link
Contributor Author

Choose a reason for hiding this comment

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

without this the make commands default togo1.16

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to take care of it as mentioned here google/go-licenses#128

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the latest run, switching to 1.0.0 doesn't seem to have an effect on the CI run. I don't see this locally on my machine but I have the 1.0.0 version of the binary. Switching the local binary to 1.2.1 I am able to repro the issue.


# 1.16 is the default so symlink it to /go/bin
unlink ${GOPATH}/bin/go-licenses
ln -s ${GOPATH}/go1.16/bin/go-licenses ${GOPATH}/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cluster-api-provider-nutanix
_output
1,564 changes: 1,564 additions & 0 deletions projects/nutanix-cloud-native/cluster-api-provider-nutanix/ATTRIBUTION.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
28d96463c36c630eab3a815ac107251d46537a407b2114ca98d07923d83b80f3 _output/bin/cluster-api-provider-nutanix/linux-amd64/manager
b4b7809b9b15bcb3a1ac3a4bc9fc5c4fa911d20b821a2b777147df9771470522 _output/bin/cluster-api-provider-nutanix/linux-arm64/manager
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.5.1
57 changes: 57 additions & 0 deletions projects/nutanix-cloud-native/cluster-api-provider-nutanix/Help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@



########### DO NOT EDIT #############################
# To update call: make add-generated-help-block
# This is added to help document dynamic targets and support shell autocompletion


##@ GIT/Repo Targets
clone-repo: ## Clone upstream `cluster-api-provider-nutanix`
checkout-repo: ## Checkout upstream tag based on value in GIT_TAG file
patch-repo: ## Patch upstream repo with patches in patches directory

##@ Binary Targets
binaries: ## Build all binaries: `manager` for `linux/amd64 linux/arm64`
_output/bin/cluster-api-provider-nutanix/linux-amd64/manager: ## Build `_output/bin/cluster-api-provider-nutanix/linux-amd64/manager`
_output/bin/cluster-api-provider-nutanix/linux-arm64/manager: ## Build `_output/bin/cluster-api-provider-nutanix/linux-arm64/manager`

##@ Image Targets
local-images: ## Builds `cluster-api-provider-nutanix/images/amd64` as oci tars for presumbit validation
images: ## Pushes `cluster-api-provider-nutanix/images/push` to IMAGE_REPO
cluster-api-provider-nutanix/images/amd64: ## Builds/pushes `cluster-api-provider-nutanix/images/amd64`
cluster-api-provider-nutanix/images/push: ## Builds/pushes `cluster-api-provider-nutanix/images/push`

##@ Checksum Targets
checksums: ## Update checksums file based on currently built binaries.
validate-checksums: # Validate checksums of currently built binaries against checksums file.

##@ Artifact Targets
tarballs: ## Create tarballs by calling build/lib/simple_create_tarballs.sh unless SIMPLE_CREATE_TARBALLS=false, then tarballs must be defined in project Makefile
s3-artifacts: # Prepare ARTIFACTS_PATH folder structure with tarballs/manifests/other items to be uploaded to s3
upload-artifacts: # Upload tarballs and other artifacts from ARTIFACTS_PATH to S3

##@ License Targets
gather-licenses: ## Helper to call $(GATHER_LICENSES_TARGETS) which gathers all licenses
attribution: ## Generates attribution from licenses gathered during `gather-licenses`.
attribution-pr: ## Generates PR to update attribution files for projects

##@ Clean Targets
clean: ## Removes source and _output directory
clean-repo: ## Removes source directory

##@ Helpers
help: ## Display this help
add-generated-help-block: ## Add or update generated help block to document project make file and support shell auto completion

##@Update Helpers
run-target-in-docker: ## Run `MAKE_TARGET` using builder base docker container
update-attribution-checksums-docker: ## Update attribution and checksums using the builder base docker container
stop-docker-builder: ## Clean up builder base docker container
generate: ## Update UPSTREAM_PROJECTS.yaml
create-ecr-repos: ## Create repos in ECR for project images for local testing

##@ Build Targets
build: ## Called via prow presubmit, calls `validate-checksums attribution local-images upload-artifacts attribution-pr`
release: ## Called via prow postsubmit + release jobs, calls `validate-checksums images upload-artifacts`
########### END GENERATED ###########################
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BASE_DIRECTORY:=$(shell git rev-parse --show-toplevel)
GIT_TAG:=$(shell cat GIT_TAG)
GOLANG_VERSION?="1.18"

REPO=cluster-api-provider-nutanix
REPO_OWNER=nutanix-cloud-native

BASE_IMAGE_NAME?=eks-distro-minimal-base-nonroot

BINARY_TARGET_FILES=manager
SOURCE_PATTERNS=.
EXTRA_GO_LDFLAGS=$(shell $(BUILD_LIB)/version.sh $(REPO) sigs.k8s.io/cluster-api-provider-nutanix/pkg/version)

HAS_S3_ARTIFACTS=true

include $(BASE_DIRECTORY)/Common.mk

s3-artifacts: create-manifests

.PHONY: create-manifests
create-manifests: tarballs
build/create_manifests.sh $(REPO) $(OUTPUT_DIR) $(ARTIFACTS_PATH) $(GIT_TAG) $(IMAGE_REPO) $(IMAGE_TAG) $(GOLANG_VERSION)

########### DO NOT EDIT #############################
# To update call: make add-generated-help-block
# This is added to help document dynamic targets and support shell autocompletion
# Run make help for a formatted help block with all targets
include Help.mk
########### END GENERATED ###########################
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **Cluster API Provider for Nutanix**
![Version](https://img.shields.io/badge/version-v0.5.1-blue)

The [Cluster API Provider for Nutanix (CAPX)](https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix) is a the implementation of Cluster API for Nutanix.


### Updating

1. Review releases and changelogs in upstream [repo](https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix) and decide on the new version.
Please review carefully and if there are questions about changes necessary to eks-anywhere to support the new version
and/or automatically update between eks-anywhere version reach out to @jaxesn, @pokearu or @abhinavmpandey08.
2. Update the `GIT_TAG` file to have the new desired version based on the upstream release tags.
3. Check the go.mod file to see if the golang version has changed when updating a version. Update the `GOLANG_VERSION` in `Makefile` to match the version upstream.
Copy link
Member

Choose a reason for hiding this comment

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

I dont like pointing to the go.mod as the source of truth for golang versions. Is there a better file in the CAPX repo, maybe the release job or makefile or dockerfile?

Copy link
Contributor Author

@thunderboltsid thunderboltsid Sep 26, 2022

Choose a reason for hiding this comment

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

Not really (we have github workflows which also specify the same value); can you elaborate on why we don't like go.mod specifying the version of Go?

Copy link
Member

Choose a reason for hiding this comment

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

That is because, the go directive in a go.mod file represents the minimum Go version that's required to compile that source code. For example, if your code uses generics, both your Go mod version and actual Go compile toolchain must be 1.18 because generics was added only in 1.18. But if there's nothing specific to 1.18 in the code, the go mod may contain 1.17 and still be compiled with 1.18 or anything above it. The ideal version for build-tooling should be, as Jackson stated above, the one you use in Makefile/Dockerfile/goreleaser.yml for go build

4. Compare the old tag to the new, looking specifically for Makefile changes. If `release-manifests` target has changed in the Makefile, make the required changes in `create_manifests.sh`
5. Update checksums and attribution using `make update-attribution-checksums-docker`.
6. Update the version at the top of this Readme.
7. Run `make generate` to update the UPSTREAM_PROJECTS.yaml file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


set -x
set -o errexit
set -o pipefail

REPO="$1"
OUTPUT_DIR="$2"
ARTIFACTS_PATH="$3"
TAG="$4"
IMAGE_REPO="$5"
IMAGE_TAG="$6"
GOLANG_VERSION="$7"

MAKE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
source "${MAKE_ROOT}/../../../build/lib/common.sh"

build::common::use_go_version $GOLANG_VERSION

cd $REPO

make release-manifests \
RELEASE_DIR="out" \
IMG="${IMAGE_REPO}:${IMAGE_TAG}"

mkdir -p $OUTPUT_DIR/manifests/infrastructure-nutanix/$TAG
cp out/metadata.yaml "$OUTPUT_DIR/manifests/infrastructure-nutanix/$TAG"
cp out/cluster-template.yaml "$OUTPUT_DIR/manifests/infrastructure-nutanix/$TAG"
cp out/infrastructure-components.yaml "$OUTPUT_DIR/manifests/infrastructure-nutanix/$TAG"

cp -rf $OUTPUT_DIR/manifests $ARTIFACTS_PATH
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG BASE_IMAGE # https://gallery.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot
FROM $BASE_IMAGE

ARG TARGETARCH
ARG TARGETOS

WORKDIR /

COPY _output/bin/cluster-api-provider-nutanix/$TARGETOS-$TARGETARCH/manager /manager
COPY _output/LICENSES /LICENSES
COPY ATTRIBUTION.txt /ATTRIBUTION.txt

USER 65532
ENTRYPOINT ["/manager"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SHA256SUM
SHA256SUM.sha256
SHA256SUM.sha512
SHA512SUM
SHA512SUM.sha256
SHA512SUM.sha512
cluster-api-provider-nutanix-linux-amd64-$GIT_TAG.tar.gz
cluster-api-provider-nutanix-linux-amd64-$GIT_TAG.tar.gz.sha256
cluster-api-provider-nutanix-linux-amd64-$GIT_TAG.tar.gz.sha512
cluster-api-provider-nutanix-linux-arm64-$GIT_TAG.tar.gz
cluster-api-provider-nutanix-linux-arm64-$GIT_TAG.tar.gz.sha256
cluster-api-provider-nutanix-linux-arm64-$GIT_TAG.tar.gz.sha512
githash
manifests/infrastructure-nutanix/$GIT_TAG/cluster-template.yaml
manifests/infrastructure-nutanix/$GIT_TAG/infrastructure-components.yaml
manifests/infrastructure-nutanix/$GIT_TAG/metadata.yaml
6 changes: 6 additions & 0 deletions release/staging-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ batch:
variables:
PROJECT_PATH: projects/kubernetes-sigs/vsphere-csi-driver
CLONE_URL: https://git-codecommit.us-west-2.amazonaws.com/v1/repos/kubernetes-sigs.vsphere-csi-driver
- identifier: nutanix_cloud_native_cluster_api_provider_nutanix
buildspec: buildspec.yml
env:
variables:
PROJECT_PATH: projects/nutanix-cloud-native/cluster-api-provider-nutanix
CLONE_URL: https://git-codecommit.us-west-2.amazonaws.com/v1/repos/nutanix-cloud-native.cluster-api-provider-nutanix
- identifier: rancher_local_path_provisioner
buildspec: buildspec.yml
env:
Expand Down