Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit 3f97a48

Browse files
authored
Merge pull request #24 from vshn/arch
Improve kind builds for different CPU architectures
2 parents bf8b56c + c52faf6 commit 3f97a48

File tree

8 files changed

+642
-556
lines changed

8 files changed

+642
-556
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ generate: ## Generate additional code and artifacts
6060
.PHONY: clean
6161
clean: ## Cleans local build artifacts
6262
rm -rf docs/node_modules $(docs_out_dir) dist .cache
63+
docker rmi $(CONTAINER_IMG) || true

go.mod

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,18 @@ require (
99
github.com/stretchr/testify v1.7.1
1010
github.com/urfave/cli/v2 v2.4.0
1111
go.uber.org/zap v1.21.0
12-
sigs.k8s.io/kind v0.12.0
1312
)
1413

1514
require (
16-
github.com/BurntSushi/toml v0.4.1 // indirect
17-
github.com/alessio/shellescape v1.4.1 // indirect
1815
github.com/benbjohnson/clock v1.1.0 // indirect
1916
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
2017
github.com/davecgh/go-spew v1.1.1 // indirect
21-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
22-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2318
github.com/kr/pretty v0.2.0 // indirect
24-
github.com/mattn/go-isatty v0.0.14 // indirect
25-
github.com/pelletier/go-toml v1.9.4 // indirect
26-
github.com/pkg/errors v0.9.1 // indirect
2719
github.com/pmezard/go-difflib v1.0.0 // indirect
2820
github.com/russross/blackfriday/v2 v2.1.0 // indirect
29-
github.com/spf13/cobra v1.2.1 // indirect
30-
github.com/spf13/pflag v1.0.5 // indirect
3121
go.uber.org/atomic v1.7.0 // indirect
3222
go.uber.org/multierr v1.6.0 // indirect
33-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
3423
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
3524
gopkg.in/yaml.v2 v2.4.0 // indirect
3625
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
37-
sigs.k8s.io/yaml v1.3.0 // indirect
3826
)

go.sum

Lines changed: 0 additions & 537 deletions
Large diffs are not rendered by default.

kind/go.mod

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module kind
2+
3+
go 1.17
4+
5+
require sigs.k8s.io/kind v0.12.0
6+
7+
require (
8+
github.com/BurntSushi/toml v0.4.1 // indirect
9+
github.com/alessio/shellescape v1.4.1 // indirect
10+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
11+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
12+
github.com/mattn/go-isatty v0.0.14 // indirect
13+
github.com/pelletier/go-toml v1.9.4 // indirect
14+
github.com/pkg/errors v0.9.1 // indirect
15+
github.com/spf13/cobra v1.2.1 // indirect
16+
github.com/spf13/pflag v1.0.5 // indirect
17+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
18+
gopkg.in/yaml.v2 v2.4.0 // indirect
19+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
20+
sigs.k8s.io/yaml v1.3.0 // indirect
21+
)

kind/go.sum

Lines changed: 591 additions & 0 deletions
Large diffs are not rendered by default.

kind/kind.mk

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
kind_dir ?= .kind
1+
kind_dir ?= $(PWD)/.kind
2+
kind_bin = $(kind_dir)/kind
3+
4+
# Prepare kind binary
5+
# We need to set the Go arch since the binary is meant for the user's OS.
6+
$(kind_bin): export GOOS = $(shell go env GOOS)
7+
$(kind_bin): export GOARCH = $(shell go env GOARCH)
8+
$(kind_bin):
9+
@mkdir -p $(kind_dir)
10+
cd kind && go build -o $@ sigs.k8s.io/kind
211

312
.PHONY: kind
413
kind: export KUBECONFIG = $(KIND_KUBECONFIG)
@@ -14,18 +23,21 @@ kind-setup-ingress: kind-setup ## Install NGINX as ingress controller onto kind
1423
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
1524

1625
.PHONY: kind-load-image
26+
# We fix the arch to linux/amd64 since kind runs in amd64 even on Mac/arm.
27+
kind-load-image: export GOOS = linux
28+
kind-load-image: export GOARCH = amd64
1729
kind-load-image: kind-setup build-docker ## Load the container image onto kind cluster
18-
@$(KIND) load docker-image --name $(KIND_CLUSTER) $(CONTAINER_IMG)
30+
@$(kind_bin) load docker-image --name $(KIND_CLUSTER) $(CONTAINER_IMG)
1931

2032
.PHONY: kind-clean
2133
kind-clean: export KUBECONFIG = $(KIND_KUBECONFIG)
2234
kind-clean: ## Removes the kind Cluster
23-
@$(KIND) delete cluster --name $(KIND_CLUSTER) || true
35+
@$(kind_bin) delete cluster --name $(KIND_CLUSTER) || true
2436
@rm -rf $(kind_dir)
2537

2638
$(KIND_KUBECONFIG): export KUBECONFIG = $(KIND_KUBECONFIG)
27-
$(KIND_KUBECONFIG):
28-
$(KIND) create cluster \
39+
$(KIND_KUBECONFIG): $(kind_bin)
40+
$(kind_bin) create cluster \
2941
--name $(KIND_CLUSTER) \
3042
--image $(KIND_IMAGE) \
3143
--config kind/config.yaml

kind/tools.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build tools
2+
// +build tools
3+
4+
// Package tools is a place to put any tooling dependencies as imports.
5+
// Go modules will be forced to download and install them.
6+
package tools
7+
8+
import (
9+
// To have kind updated via Renovate.
10+
_ "sigs.k8s.io/kind"
11+
)

tools.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
package tools
77

88
import (
9-
// To have kind updated via Renovate.
10-
_ "sigs.k8s.io/kind"
9+
// Add any build-time dependencies here with blank imports like `_ "package"`
1110
)

0 commit comments

Comments
 (0)