Skip to content

Commit

Permalink
Merge pull request #999 from XudongLiuHarold/add-cloud-build-for-vsph…
Browse files Browse the repository at this point in the history
…ere-cpi

Add gcp cloud build configuration for vsphere cloud provider
  • Loading branch information
k8s-ci-robot authored May 7, 2024
2 parents 4bffe77 + bcf04f5 commit a7f0534
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Ignore the build output.
/.build

# Ignore tooling binaries.
/hack/tools/bin

# Ignore vendor at the root of the project. Please note that
# /vendor/bitbucket.org/ww/goautoneg is versioned forcefully in order to
# bypass a build issue.
/vendor

*.json
*.sublime-project
*.sublime-workspace
*.swp
.idea


# OSX leaves these everywhere on SMB shares
._*

# OSX trash
.DS_Store

# Eclipse files
.classpath
.project
.settings/**

# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
.idea/
*.iml

# Vscode files
.vscode

# irrelated file for building image
/charts
/docs
/manifests
/releases
/scripts
/test
62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ $(warning This project uses Go modules and should not be cloned into the GOPATH)
endif
endif

# Use GOPROXY environment variable if set
GOPROXY := $(shell go env GOPROXY)
ifeq (,$(strip $(GOPROXY)))
GOPROXY := https://proxy.golang.org
endif
export GOPROXY

################################################################################
## DEPENDENCIES ##
################################################################################
Expand Down Expand Up @@ -356,3 +363,58 @@ docker-image:
-f cluster/images/controller-manager/Dockerfile \
-t "$(IMAGE):$(BRANCH_NAME)" \
--build-arg "VERSION=${VERSION}" . \

################################################################################
## GCP CLOUDBUILD RELEATED ##
################################################################################
# Define DGCP Cloud build related variables.
PROD_REGISTRY ?= registry.k8s.io/cloud-pv-vsphere

STAGING_REGISTRY ?= gcr.io/k8s-staging-cloud-pv-vsphere
STAGING_BUCKET ?= k8s-staging-cloud-pv-vsphere

IMAGE_NAME ?= cloud-provider-vsphere
VERSION ?=$(shell git describe --dirty --always)
# Default build type, this can be choosen from pr/ci/release
BUILD_TYPE := ci
BUILD_FOLDER := .build/bin

.PHONY: docker-build
docker-build:
docker build \
-f cluster/images/controller-manager/Dockerfile \
-t "$(STAGING_REGISTRY)/$(BUILD_TYPE)/$(IMAGE_NAME):$(VERSION)" \
--build-arg "VERSION=${VERSION}" \
--build-arg "GOPROXY=${GOPROXY}" \
.

.PHONY: docker-push
docker-push:
docker push "$(STAGING_REGISTRY)/$(BUILD_TYPE)/$(IMAGE_NAME):$(VERSION)"

.PHONY: ccm-bin-push
ccm-bin-push:
$(shell shasum -a 256 $(BUILD_FOLDER)/vsphere-cloud-controller-manager.$(GOOS)_$(GOARCH) 2>/dev/null > $(BUILD_FOLDER)/vsphere-cloud-controller-manager.$(GOOS)_$(GOARCH).sha256)
gsutil cp "$(BUILD_FOLDER)/vsphere-cloud-controller-manager.$(GOOS)_$(GOARCH)" "gs://$(STAGING_BUCKET)/$(BUILD_TYPE)/$(VERSION)/bin/$(GOOS)/$(GOARCH)/vsphere-cloud-controller-manager"
gsutil cp "$(BUILD_FOLDER)/vsphere-cloud-controller-manager.$(GOOS)_$(GOARCH).sha256" "gs://$(STAGING_BUCKET)/$(BUILD_TYPE)/$(VERSION)/bin/$(GOOS)/$(GOARCH)/vsphere-cloud-controller-manager.sha256"

.PHONY: pr-staging
pr-staging:
$(MAKE) BUILD_TYPE=pr docker-build
$(MAKE) BUILD_TYPE=pr docker-push
$(MAKE) build-bins
$(MAKE) BUILD_TYPE=pr ccm-bin-push

.PHONY: ci-staging
ci-staging:
$(MAKE) BUILD_TYPE=ci docker-build
$(MAKE) BUILD_TYPE=ci docker-push
$(MAKE) build-bins
$(MAKE) BUILD_TYPE=ci ccm-bin-push

.PHONY: release-staging
release-staging:
$(MAKE) BUILD_TYPE=release docker-build
$(MAKE) BUILD_TYPE=release docker-push
$(MAKE) build-bins
$(MAKE) BUILD_TYPE=release ccm-bin-push
21 changes: 21 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://cloud.google.com/cloud-build/docs/build-config
# See https://console.cloud.google.com/gcr/images/k8s-staging-test-infra/global/gcb-docker-gcloud
timeout: 2700s
options:
substitution_option: ALLOW_LOOSE
machineType: 'E2_HIGHCPU_8'
steps:
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20240210-29014a6e3a'
entrypoint: make
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- TAG=$_GIT_TAG
- PULL_BASE_REF=$_PULL_BASE_REF
- DOCKER_BUILDKIT=1
args:
- release-staging
substitutions:
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
_GIT_TAG: '12345'
_PULL_BASE_REF: 'dev'

0 comments on commit a7f0534

Please sign in to comment.