Skip to content

Commit

Permalink
Stability: Simplify Image Building and Publishing CI (solo-io#8060)
Browse files Browse the repository at this point in the history
* clarify variables in makefile around creating assets

* simplify setup-kind script, move assets into kind directory, reuse os/arch variables from makefile

* change script reference

* introduce build-cli-local, remove arm code for mtls test

* make fmt

* cleanup references to localhost:5000

* add changelog

* update changelog

* unfocus test

* simplify docker/kind make targets

* move changelog dir to rc1

* Adding changelog file to new location

* Deleting changelog file from old location

* move changelog dir to beta1

* remove extended images, simplify docker publishing

* docker-retag: DRY

* small cleanup

* separate retag and publish-retag

* undo import rename

* setup-kind: improve readability

* docker-publish -> publish-docker

* Adding changelog file to new location

* Deleting changelog file from old location

* support kind-build-and-load-% like we do in solo-projects

* oneline

* fix oneline naming

* fix oneline naming

* Adding changelog file to new location

* Deleting changelog file from old location

* IMAGE_REPO -> IMAGE_REGISTRY

---------

Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: changelog-bot <changelog-bot>
  • Loading branch information
sam-heilbron and soloio-bulldozer[bot] authored Apr 19, 2023
1 parent 5b83075 commit 35bfd59
Show file tree
Hide file tree
Showing 19 changed files with 310 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .github/actions/regression-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ runs:
KUBE2E_TESTS: ${{ matrix.kube-e2e-test-type }}
CLUSTER_NAME: 'kind'
CLUSTER_NODE_VERSION: ${{ matrix.kube-version.node }}
run: ./ci/deploy-to-kind-cluster.sh
run: ./ci/kind/setup-kind.sh
- name: Testing - kube e2e regression tests
env:
KUBE2E_TESTS: ${{ matrix.kube-e2e-test-type }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-analysis-scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Run and Push Security Scan Files to Google Cloud Bucket
env:
SCAN_DIR: _output/scans
IMAGE_REPO: quay.io/solo-io
IMAGE_REGISTRY: quay.io/solo-io
MIN_SCANNED_VERSION: 'v1.10.0' # ⚠️ you should also change docs-gen.yaml ⚠️
run: |
mkdir -p $SCAN_DIR
Expand Down
257 changes: 116 additions & 141 deletions Makefile

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions Makefile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ $(OUTPUT_DIR)/glooctl: $(SOURCES)
GO111MODULE=on go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go

$(OUTPUT_DIR)/glooctl-linux-arm64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux GOARCH=arm64 go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-linux-amd64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux GOARCH=amd64 go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-darwin-amd64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=darwin GOARCH=amd64 go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(GO_BUILD_FLAGS) GOOS=darwin go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-darwin-arm64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=darwin GOARCH=arm64 go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(GO_BUILD_FLAGS) GOOS=darwin go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go

$(OUTPUT_DIR)/glooctl-windows-$(GOARCH).exe: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=windows go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
Expand All @@ -37,5 +37,8 @@ glooctl-darwin-arm64: $(OUTPUT_DIR)/glooctl-darwin-arm64
.PHONY: glooctl-windows-$(GOARCH)
glooctl-windows-$(GOARCH): $(OUTPUT_DIR)/glooctl-windows-$(GOARCH).exe

.PHONY: build-cli-local
build-cli-local: glooctl-$(GOOS)-$(GOARCH) ## Build the CLI according to your local GOOS and GOARCH

.PHONY: build-cli
build-cli: glooctl-linux-amd64 glooctl-linux-arm64 glooctl-darwin-amd64 glooctl-darwin-arm64 glooctl-windows-$(GOARCH)
6 changes: 6 additions & 0 deletions changelog/v1.15.0-beta3/simplify-test-image-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NON_USER_FACING
issueLink: https://github.com/solo-io/gloo/issues/5471
resolvesIssue: false
description: >-
Simplify how we setup a kind cluster used in our kubernetes regression tests.
14 changes: 7 additions & 7 deletions ci/cloudbuild/publish-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ steps:

# Run make targets to push docker images to quay.io
- name: 'gcr.io/$PROJECT_ID/go-mod-make:0.6.2'
id: 'docker-push-extended'
id: 'publish-docker'
args:
- 'docker-push-extended'
- 'publish-docker'
dir: *dir
secretEnv:
- 'GITHUB_TOKEN'
Expand All @@ -63,7 +63,7 @@ steps:
- 'auth'
- 'configure-docker'
waitFor:
- 'docker-push-extended'
- 'publish-docker'

- name: 'gcr.io/$PROJECT_ID/go-mod-make:0.6.2'
id: 'release-chart'
Expand All @@ -86,16 +86,16 @@ steps:
id: 'docker-push-extended-gcr'
dir: *dir
args:
- 'docker-push-retag'
- 'publish-docker-retag'
env:
- 'IMAGE_REPO=gcr.io/gloo-edge'
- 'RETAG_IMAGE_REGISTRY=quay.io/solo-io'
- 'ORIGINAL_IMAGE_REGISTRY=quay.io/solo-io'
- 'IMAGE_REGISTRY=gcr.io/gloo-edge'
secretEnv:
- 'GITHUB_TOKEN'
waitFor:
- 'gcr-auth'
- 'prepare-gcr-zone'
- 'docker-push-extended'
- 'publish-docker'

secrets:
- kmsKeyName: 'projects/solo-public/locations/global/keyRings/build/cryptoKeys/build-key'
Expand Down
150 changes: 0 additions & 150 deletions ci/deploy-to-kind-cluster.sh

This file was deleted.

9 changes: 0 additions & 9 deletions ci/extended-docker/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions ci/extended-docker/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions ci/extended-docker/extended-docker.sh

This file was deleted.

13 changes: 13 additions & 0 deletions ci/kind/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
metadata:
name: config
- |
apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
metadata:
name: config
73 changes: 73 additions & 0 deletions ci/kind/setup-kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash -ex

# 0. Assign default values to some of our environment variables
# Get directory this script is located in to access script local files
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
# The name of the kind cluster to deploy to
CLUSTER_NAME="${CLUSTER_NAME:-kind}"
# The version of the Node Docker image to use for booting the cluster
CLUSTER_NODE_VERSION="${CLUSTER_NODE_VERSION:-v1.25.3}"
# The version used to tag images
VERSION="${VERSION:-1.0.0-ci}"
# Skip building docker images if we are testing a released version
SKIP_DOCKER="${SKIP_DOCKER:-false}"
# Stop after creating the kind cluster
JUST_KIND="${JUST_KIND:-false}"
# Offer a default value for type of installation
KUBE2E_TESTS="${KUBE2E_TESTS:-gateway}" # If 'KUBE2E_TESTS' not set or null, use 'gateway'.
# The version of istio to install for glooctl tests
# https://istio.io/latest/docs/releases/supported-releases/#support-status-of-istio-releases
ISTIO_VERSION="${ISTIO_VERSION:-1.17.1}"

function create_kind_cluster_or_skip() {
activeClusters=$(kind get clusters)

# if the kind cluster exists already, return
if [[ "$activeClusters" =~ .*"$CLUSTER_NAME".* ]]; then
echo "cluster exists, skipping cluster creation"
return
fi

echo "creating cluster ${CLUSTER_NAME}"
kind create cluster \
--name "$CLUSTER_NAME" \
--image "kindest/node:$CLUSTER_NODE_VERSION" \
--config="$SCRIPT_DIR/cluster.yaml"
echo "Finished setting up cluster $CLUSTER_NAME"

# so that you can just build the kind image alone if needed
if [[ $JUST_KIND == 'true' ]]; then
echo "JUST_KIND=true, not building images"
exit
fi
}

# 1. Create a kind cluster (or skip creation if a cluster with name=CLUSTER_NAME already exists)
# This config is roughly based on: https://kind.sigs.k8s.io/docs/user/ingress/
create_kind_cluster_or_skip

if [[ $SKIP_DOCKER == 'true' ]]; then
echo "SKIP_DOCKER=true, not building images or chart"
else
# 2. Make all the docker images and load them to the kind cluster
VERSION=$VERSION CLUSTER_NAME=$CLUSTER_NAME make kind-build-and-load

# 3. Build the test helm chart, ensuring we have a chart in the `_test` folder
VERSION=$VERSION make build-test-chart
fi

# 4. Build the gloo command line tool, ensuring we have one in the `_output` folder
make build-cli-local

# 5. Install additional resources used for particular KUBE2E tests
if [[ $KUBE2E_TESTS = "glooctl" || $KUBE2E_TESTS = "istio" ]]; then
TARGET_ARCH=x86_64
if [[ $ARCH == 'arm64' ]]; then
TARGET_ARCH=arm64
fi
echo "Downloading Istio $ISTIO_VERSION"
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=$ISTIO_VERSION TARGET_ARCH=$TARGET_ARCH sh -

echo "Installing Istio"
yes | "./istio-$ISTIO_VERSION/bin/istioctl" install --set profile=minimal
fi
Loading

0 comments on commit 35bfd59

Please sign in to comment.