Skip to content

Commit 00a3781

Browse files
📖 update multi-version with the latest changes and address fixes (#4139)
📖 update multi-version with the latest changes and to use the new interface for webhooks
1 parent e8158a6 commit 00a3781

23 files changed

+1560
-791
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Kubebuilder DevContainer",
3+
"image": "golang:1.22",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6+
"ghcr.io/devcontainers/features/git:1": {}
7+
},
8+
9+
"runArgs": ["--network=host"],
10+
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"terminal.integrated.shell.linux": "/bin/bash"
15+
},
16+
"extensions": [
17+
"ms-kubernetes-tools.vscode-kubernetes-tools",
18+
"ms-azuretools.vscode-docker"
19+
]
20+
}
21+
},
22+
23+
"onCreateCommand": "bash .devcontainer/post-install.sh"
24+
}
25+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -x
3+
4+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
5+
chmod +x ./kind
6+
mv ./kind /usr/local/bin/kind
7+
8+
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64
9+
chmod +x kubebuilder
10+
mv kubebuilder /usr/local/bin/
11+
12+
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
13+
curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
14+
chmod +x kubectl
15+
mv kubectl /usr/local/bin/kubectl
16+
17+
docker network create -d=bridge --subnet=172.19.0.0/24 kind
18+
19+
kind version
20+
kubebuilder version
21+
docker --version
22+
go version
23+
kubectl version --client

docs/book/src/multiversion-tutorial/testdata/project/Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Image URL to use all building/pushing image targets
22
IMG ?= controller:latest
33
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
4-
ENVTEST_K8S_VERSION = 1.30.0
4+
ENVTEST_K8S_VERSION = 1.31.0
55

66
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
77
ifeq (,$(shell go env GOBIN))
@@ -63,9 +63,21 @@ vet: ## Run go vet against code.
6363
test: manifests generate fmt vet envtest ## Run tests.
6464
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
6565

66-
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
67-
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
68-
test-e2e:
66+
# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
67+
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
68+
# Prometheus and CertManager are installed by default; skip with:
69+
# - PROMETHEUS_INSTALL_SKIP=true
70+
# - CERT_MANAGER_INSTALL_SKIP=true
71+
.PHONY: test-e2e
72+
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
73+
@command -v kind >/dev/null 2>&1 || { \
74+
echo "Kind is not installed. Please install Kind manually."; \
75+
exit 1; \
76+
}
77+
@kind get clusters | grep -q 'kind' || { \
78+
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
79+
exit 1; \
80+
}
6981
go test ./test/e2e/ -v -ginkgo.v
7082

7183
.PHONY: lint
@@ -158,9 +170,9 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
158170
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
159171

160172
## Tool Versions
161-
KUSTOMIZE_VERSION ?= v5.4.2
162-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
163-
ENVTEST_VERSION ?= release-0.18
173+
KUSTOMIZE_VERSION ?= v5.4.3
174+
CONTROLLER_TOOLS_VERSION ?= v0.16.1
175+
ENVTEST_VERSION ?= release-0.19
164176
GOLANGCI_LINT_VERSION ?= v1.59.1
165177

166178
.PHONY: kustomize

docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ limitations under the License.
1717

1818
/*
1919
*/
20-
2120
package v1
2221

2322
/*
2423
*/
25-
2624
import (
2725
batchv1 "k8s.io/api/batch/v1"
2826
corev1 "k8s.io/api/core/v1"
@@ -34,7 +32,7 @@ import (
3432

3533
// +kubebuilder:docs-gen:collapse=Imports
3634

37-
// CronJobSpec defines the desired state of CronJob
35+
// CronJobSpec defines the desired state of CronJob.
3836
type CronJobSpec struct {
3937
// +kubebuilder:validation:MinLength=0
4038

@@ -98,7 +96,7 @@ const (
9896
ReplaceConcurrent ConcurrencyPolicy = "Replace"
9997
)
10098

101-
// CronJobStatus defines the observed state of CronJob
99+
// CronJobStatus defines the observed state of CronJob.
102100
type CronJobStatus struct {
103101
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
104102
// Important: Run "make" to regenerate code after modifying this file
@@ -129,8 +127,8 @@ type CronJobStatus struct {
129127
// +kubebuilder:object:root=true
130128
// +kubebuilder:subresource:status
131129
// +kubebuilder:storageversion
132-
133-
// CronJob is the Schema for the cronjobs API
130+
// +versionName=v1
131+
// CronJob is the Schema for the cronjobs API.
134132
type CronJob struct {
135133
metav1.TypeMeta `json:",inline"`
136134
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -144,7 +142,7 @@ type CronJob struct {
144142

145143
// +kubebuilder:object:root=true
146144

147-
// CronJobList contains a list of CronJob
145+
// CronJobList contains a list of CronJob.
148146
type CronJobList struct {
149147
metav1.TypeMeta `json:",inline"`
150148
metav1.ListMeta `json:"metadata,omitempty"`

0 commit comments

Comments
 (0)