Skip to content

Commit 3f1ded6

Browse files
camilamacedo86migueleliaswebk8s-ci-robotmateusoliveira43afzal442
authored
🌱 Update book-v4 with master to do PATCH release 4.5.1 (#4574)
* Make kubebuilder go-installable Closes 4079 (Make kubebuilder go install-able) Signed-off-by: Miguel Elias dos Santos <[email protected]> * 🐛 Fix Kubernetes version in the goreleaser by upgrading it from 1.31.0 to 1.32.0 * fix: webhook testEnv Signed-off-by: Mateus Oliveira <[email protected]> * fix: disallow files containing unwanted extension files when initializing a project * 📖 Bump sigs.k8s.io/kubebuilder/v4 Bumps [sigs.k8s.io/kubebuilder/v4](https://github.com/kubernetes-sigs/kubebuilder) from 4.4.0 to 4.5.0. - [Release notes](https://github.com/kubernetes-sigs/kubebuilder/releases) - [Changelog](https://github.com/kubernetes-sigs/kubebuilder/blob/master/RELEASE.md) - [Commits](v4.4.0...v4.5.0) --- updated-dependencies: - dependency-name: sigs.k8s.io/kubebuilder/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * test: add to commmon.sh the latest k8s release 1.32 * Update yamllint target to handle missing dist/chart * doc: update the Artifacts with the latest changes on the EnvTest Makefile target configurations * ✨ Upgrade controller-runtime from v0.20.0 to v0.20.1 (#4528) Upgrade controller-runtime from v0.20.0 to v0.20.1 * 📖 bump github.com/spf13/pflag Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](spf13/pflag@v1.0.5...v1.0.6) --- updated-dependencies: - dependency-name: github.com/spf13/pflag dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * 🌱 bump github.com/spf13/pflag from 1.0.5 to 1.0.6 Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](spf13/pflag@v1.0.5...v1.0.6) --- updated-dependencies: - dependency-name: github.com/spf13/pflag dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * fix: correct minor typos in documentation * Removed Prometheus dependency from e2e scaffolds * 🐛(kustomize/v2): fix ServiceMonitor with TLS kustomize scaffolding * 📖 Remove simplistic advice about multiple controllers reconciling same CR (#4537) Remove simplistic advice about multiple controllers reconciling same CR This advice is simplyfing things and making an "It depends" situation look like there was a clear good and a clear bad way that is the same in all situations. Pretty much none of the issues stated will get better if each controller gets its own CR: * Race conditions: Conflict errors can always happen and all controllers need to be able to deal with them. If a full reconciliation is too expensive, they can use something like `retry.OnConflict` * Concurrency issues with different interpretations of state: This example sounds like just buggy software. Copying the state to a new CR doesn't eliminate this problem * Maintenance and support difficulties: This is definitely not going to get any better by adding more CRDs into the mix, if anything, it will get more complicated * Status tracking complications: This is why conditions exist and Kubernetes api guidelines explicitly state that controllers need to ignore unknown conditions: `Objects may report multiple conditions, and new types of conditions may be added in the future or by 3rd party controllers.`, [ref][0] * Performance issues: If multiple controllers do the same thing, that is a bug regardless of all other considerations and can easily lead to correctness and performance issues. The `workqueue` locks items while they are reconciled to avoid exactly that, but obviously it doesn't work cross-controller To illustrate the situation, think about the `Pod` object, in the lifecycle of a pod we usually have at least cluster-autoscaler, scheduler and kubelet. Making cluster-autoscaler act on a `PodScaleRequest` and scheduler on a `PodScheduleRequest` would be a complication, not a simplification. [0]: https://github.com/kubernetes/community/blob/322066e7dba7c5043071392fec427a57f8660734/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties * 🌱 ci: fix testdata - issues caused by some merge conflict with go mod (#4538) ci: fix testdata - issues caused by some merge conflict with go mod * Revert "Merge pull request #4512 from sarthaksarthak9/lint" (#4539) This reverts commit ded393e, reversing changes made to 543b4a1. * add context.Context to EnqueuRequestsFromMapFunc The underlying `TypedMapFunc` requires this argument, reference https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/handler/enqueue_mapped.go#L36 * 🌱 bump golang.org/x/text from 0.21.0 to 0.22.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.21.0 to 0.22.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](golang/text@v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * handle missing boilerplate file gracefully * 📖 Fix grammar in lets -> let's. * Update controller-runtime version used in the common.sh tests * Update Roadmap 2025 with latest status * 🌱 Improve samples linting & fix samples lint issues This commit includes: - Fix linter issues - Refactor fetchCronJob in sample controller reconcile func - Fix getting-started tutorial lint issues - Fix multiversion tutorial lint issues - Fix cronjob-tutorial lint issues - Refactor cronjob controller reconcile to reduce cyclomatic complexity * Revert "🐛 (kustomize/v2): fix ServiceMonitor with TLS kustomize scaffolding" * 🌱 Bump golang.org/x/tools from 0.29.0 to 0.30.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.29.0 to 0.30.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.29.0...v0.30.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * ✨ Upgrade controller-gen from v0.17.1 to v0.17.2 (#4553) Upgrade controller-gen from v0.17.1 to v0.17.2 * (go/v4,ksutomize/v2,helm/v1-alpha): Fix prometheus integration with TLS check Co-Author: Abhisek Dwivedi <[email protected]> * Update alpha generate command so that --repo is always included when running kubebuilder init to fix issue when not on GOPATH * 🌱 fix testdata generation (#4569) fix testdata generation * 🌱 Bump github.com/spf13/cobra from 1.8.1 to 1.9.1 Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.1 to 1.9.1. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](spf13/cobra@v1.8.1...v1.9.1) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * ✨ Upgrade controller-runtime from v0.20.1 to v0.20.2 (#4570) Upgrade controller-runtime from v0.20.1 to v0.20.2 and K8s version from v1.32.0 to 1.32.1 * Added e2e tests for alpha generate command for scaffolded data under testdata changes due to running make generate --------- Signed-off-by: Miguel Elias dos Santos <[email protected]> Signed-off-by: Mateus Oliveira <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Miguel Elias dos Santos <[email protected]> Co-authored-by: Kubernetes Prow Robot <[email protected]> Co-authored-by: Mateus Oliveira <[email protected]> Co-authored-by: Afzal Ansari <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sarthaksarthak9 <[email protected]> Co-authored-by: sapphire <[email protected]> Co-authored-by: Anshuman <[email protected]> Co-authored-by: Abhisek Dwivedi <[email protected]> Co-authored-by: Alvaro Aleman <[email protected]> Co-authored-by: mwdomino <[email protected]> Co-authored-by: Thomas Guettler <[email protected]> Co-authored-by: Wazery <[email protected]> Co-authored-by: Freddy Esteban Perez <[email protected]> Co-authored-by: Manali Latkar <[email protected]>
1 parent e8b5541 commit 3f1ded6

File tree

176 files changed

+2024
-946
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+2024
-946
lines changed

.github/workflows/lint-sample.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ jobs:
1616
folder: [
1717
"testdata/project-v4",
1818
"testdata/project-v4-with-plugins",
19-
"testdata/project-v4-multigroup"
19+
"testdata/project-v4-multigroup",
20+
"docs/book/src/cronjob-tutorial/testdata/project",
21+
"docs/book/src/getting-started/testdata/project",
22+
"docs/book/src/multiversion-tutorial/testdata/project"
2023
]
2124
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
2225
steps:

.github/workflows/test-e2e-samples.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
4444
sed -i '47,49s/^#//' $KUSTOMIZATION_FILE_PATH
4545
# Uncomment all cert-manager injections
46-
sed -i '59,212s/^#//' $KUSTOMIZATION_FILE_PATH
47-
sed -i '214,229s/^#//' $KUSTOMIZATION_FILE_PATH
46+
sed -i '59,234s/^#//' $KUSTOMIZATION_FILE_PATH
47+
sed -i '236,251s/^#//' $KUSTOMIZATION_FILE_PATH
4848
cd testdata/project-v4/
4949
go mod tidy
5050
@@ -86,10 +86,12 @@ jobs:
8686
# Uncomment only ValidatingWebhookConfiguration
8787
# from cert-manager replaces; we are leaving defaulting uncommented
8888
# since this sample has no defaulting webhooks
89-
sed -i '59,164s/^#//' $KUSTOMIZATION_FILE_PATH
89+
sed -i '59,77s/^#//' $KUSTOMIZATION_FILE_PATH
90+
sed -i '90,107s/^#//' $KUSTOMIZATION_FILE_PATH
91+
sed -i '120,186s/^#//' $KUSTOMIZATION_FILE_PATH
9092
# Uncomment only --conversion webhooks CA injection
91-
sed -i '197,212s/^#//' $KUSTOMIZATION_FILE_PATH
92-
sed -i '214,229s/^#//' $KUSTOMIZATION_FILE_PATH
93+
sed -i '219,234s/^#//' $KUSTOMIZATION_FILE_PATH
94+
sed -i '236,251s/^#//' $KUSTOMIZATION_FILE_PATH
9395
cd testdata/project-v4-with-plugins/
9496
go mod tidy
9597
@@ -129,9 +131,10 @@ jobs:
129131
KUSTOMIZATION_FILE_PATH="testdata/project-v4-multigroup/config/default/kustomization.yaml"
130132
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
131133
# Uncomment all cert-manager injections for webhooks only
132-
sed -i '59,59s/^#//' $KUSTOMIZATION_FILE_PATH
133-
sed -i '98,212s/^#//' $KUSTOMIZATION_FILE_PATH
134-
sed -i '214,229s/^#//' $KUSTOMIZATION_FILE_PATH
134+
sed -i '59,77s/^#//' $KUSTOMIZATION_FILE_PATH
135+
sed -i '90,107s/^#//' $KUSTOMIZATION_FILE_PATH
136+
sed -i '120,234s/^#//' $KUSTOMIZATION_FILE_PATH
137+
sed -i '236,251s/^#//' $KUSTOMIZATION_FILE_PATH
135138
cd testdata/project-v4-multigroup
136139
go mod tidy
137140

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ help: ## Display this help
4646
##@ Build
4747

4848
LD_FLAGS=-ldflags " \
49-
-X main.kubeBuilderVersion=$(shell git describe --tags --dirty --broken) \
50-
-X main.goos=$(shell go env GOOS) \
51-
-X main.goarch=$(shell go env GOARCH) \
52-
-X main.gitCommit=$(shell git rev-parse HEAD) \
53-
-X main.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
49+
-X cmd.kubeBuilderVersion=$(shell git describe --tags --dirty --broken) \
50+
-X cmd.goos=$(shell go env GOOS) \
51+
-X cmd.goarch=$(shell go env GOARCH) \
52+
-X cmd.gitCommit=$(shell git rev-parse HEAD) \
53+
-X cmd.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
5454
"
5555
.PHONY: build
5656
build: ## Build the project locally
57-
go build $(LD_FLAGS) -o bin/kubebuilder ./cmd
57+
go build $(LD_FLAGS) -o bin/kubebuilder
5858

5959
.PHONY: install
6060
install: build ## Build and install the binary with the current source code. Use it to test your changes locally.

RELEASE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The releases occur in an account in the Google Cloud (See [here](https://console
6868
### To build the Kubebuilder CLI binaries:
6969

7070
A trigger GitHub action [release](.github/workflows/release.yml) is trigged when a new tag is pushed.
71-
This action will caall the job [./build/.goreleaser.yml](./build/.goreleaser.yml).
71+
This action will call the job [./build/.goreleaser.yml](./build/.goreleaser.yml).
7272

7373
### (Deprecated) - To build the Kubebuilder-tools: (Artifacts required to use ENV TEST)
7474

@@ -93,7 +93,7 @@ see: https://github.com/kubernetes-sigs/kubebuilder/discussions/3907
9393
These images are built from the project [brancz/kube-rbac-proxy](https://github.com/brancz/kube-rbac-proxy).
9494
The projects built with Kubebuilder creates a side container with `kube-rbac-proxy` to protect the Manager.
9595

96-
These images are can be checked in the consolse, see [here](https://console.cloud.google.com/gcr/images/kubebuilder/GLOBAL/kube-rbac-proxy).
96+
These images can be checked in the console, see [here](https://console.cloud.google.com/gcr/images/kubebuilder/GLOBAL/kube-rbac-proxy).
9797

9898
The project `kube-rbac-proxy` is in the process to be donated to the k8s org. However, it is going on for a long time and then,
9999
we have no ETA for that to occur. When that occurs we can automate this process. But until there we need to generate these images

build/.goreleaser.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ before:
2929
# Build a binary for each target in targets.
3030
builds:
3131
- id: kubebuilder
32-
main: ./cmd
3332
binary: kubebuilder
3433
mod_timestamp: "{{ .CommitTimestamp }}"
3534
ldflags:
36-
- -X main.kubeBuilderVersion={{ .Version }}
37-
- -X main.goos={{ .Os }}
38-
- -X main.goarch={{ .Arch }}
39-
- -X main.gitCommit={{ .Commit }}
40-
- -X main.buildDate={{ .Date }}
41-
- -X main.kubernetesVendorVersion={{ .Env.KUBERNETES_VERSION }}
35+
- -X cmd.kubeBuilderVersion={{ .Version }}
36+
- -X cmd.goos={{ .Os }}
37+
- -X cmd.goarch={{ .Arch }}
38+
- -X cmd.gitCommit={{ .Commit }}
39+
- -X cmd.buildDate={{ .Date }}
40+
- -X cmd.kubernetesVendorVersion={{ .Env.KUBERNETES_VERSION }}
4241
targets:
4342
- linux_amd64
4443
- linux_arm64
@@ -47,7 +46,7 @@ builds:
4746
- darwin_amd64
4847
- darwin_arm64
4948
env:
50-
- KUBERNETES_VERSION=1.31.0
49+
- KUBERNETES_VERSION=1.32.1
5150
- CGO_ENABLED=0
5251

5352
# Only binaries of the form "kubebuilder_${goos}_${goarch}" will be released.

cmd/main.go renamed to cmd/cmd.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package cmd
1818

1919
import (
2020
"github.com/sirupsen/logrus"
@@ -36,7 +36,8 @@ func init() {
3636
logrus.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true})
3737
}
3838

39-
func main() {
39+
// Run bootstraps & runs the CLI
40+
func Run() {
4041
// Bundle plugin which built the golang projects scaffold with base.go/v4 and kustomize/v2 plugins
4142
gov4Bundle, _ := plugin.NewBundleWithOptions(plugin.WithName(golang.DefaultNameQualifier),
4243
plugin.WithVersion(plugin.Version{Number: 4}),

cmd/version.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package cmd
1818

1919
import (
2020
"fmt"
21+
"runtime/debug"
2122
)
2223

24+
const unknown = "unknown"
25+
2326
// var needs to be used instead of const as ldflags is used to fill this
2427
// information in the release process
2528
var (
26-
kubeBuilderVersion = "unknown"
27-
kubernetesVendorVersion = "unknown"
28-
goos = "unknown"
29-
goarch = "unknown"
29+
kubeBuilderVersion = unknown
30+
kubernetesVendorVersion = unknown
31+
goos = unknown
32+
goarch = unknown
3033
gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
3134

3235
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
@@ -44,6 +47,12 @@ type version struct {
4447

4548
// versionString returns the CLI version
4649
func versionString() string {
50+
if kubeBuilderVersion == unknown {
51+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" {
52+
kubeBuilderVersion = info.Main.Version
53+
}
54+
}
55+
4756
return fmt.Sprintf("Version: %#v", version{
4857
kubeBuilderVersion,
4958
kubernetesVendorVersion,

docs/book/install-and-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ chmod +x /tmp/mdbook
7171

7272
echo "grabbing the latest released controller-gen"
7373
go version
74-
go install sigs.k8s.io/controller-tools/cmd/[email protected].0
74+
go install sigs.k8s.io/controller-tools/cmd/[email protected].2
7575

7676
# make sure we add the go bin directory to our path
7777
gobin=$(go env GOBIN)

docs/book/src/cronjob-tutorial/testdata/finalizer_example.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
6464
// examine DeletionTimestamp to determine if object is under deletion
6565
if cronJob.ObjectMeta.DeletionTimestamp.IsZero() {
6666
// The object is not being deleted, so if it does not have our finalizer,
67-
// then lets add the finalizer and update the object. This is equivalent
67+
// then let's add the finalizer and update the object. This is equivalent
6868
// to registering our finalizer.
6969
if !controllerutil.ContainsFinalizer(cronJob, myFinalizerName) {
7070
controllerutil.AddFinalizer(cronJob, myFinalizerName)
@@ -75,7 +75,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
7575
} else {
7676
// The object is being deleted
7777
if controllerutil.ContainsFinalizer(cronJob, myFinalizerName) {
78-
// our finalizer is present, so lets handle any external dependency
78+
// our finalizer is present, so let's handle any external dependency
7979
if err := r.deleteExternalResources(cronJob); err != nil {
8080
// if fail to delete the external dependency here, return with error
8181
// so that it can be retried.

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
6767

6868
# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
6969
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
70-
# Prometheus and CertManager are installed by default; skip with:
71-
# - PROMETHEUS_INSTALL_SKIP=true
70+
# CertManager is installed by default; skip with:
7271
# - CERT_MANAGER_INSTALL_SKIP=true
7372
.PHONY: test-e2e
7473
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
@@ -177,7 +176,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
177176

178177
## Tool Versions
179178
KUSTOMIZE_VERSION ?= v5.5.0
180-
CONTROLLER_TOOLS_VERSION ?= v0.17.1
179+
CONTROLLER_TOOLS_VERSION ?= v0.17.2
181180
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
182181
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
183182
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)

docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func main() {
155155

156156
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
157157
// More info:
158-
// - https://pkg.go.dev/sigs.k8s.io/[email protected].0/pkg/metrics/server
158+
// - https://pkg.go.dev/sigs.k8s.io/[email protected].2/pkg/metrics/server
159159
// - https://book.kubebuilder.io/reference/metrics.html
160160
metricsServerOptions := metricsserver.Options{
161161
BindAddress: metricsAddr,
@@ -167,7 +167,7 @@ func main() {
167167
// FilterProvider is used to protect the metrics endpoint with authn/authz.
168168
// These configurations ensure that only authorized users and service accounts
169169
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
170-
// https://pkg.go.dev/sigs.k8s.io/[email protected].0/pkg/metrics/filters#WithAuthenticationAndAuthorization
170+
// https://pkg.go.dev/sigs.k8s.io/[email protected].2/pkg/metrics/filters#WithAuthenticationAndAuthorization
171171
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
172172
}
173173

docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.17.1
6+
controller-gen.kubebuilder.io/version: v0.17.2
77
name: cronjobs.batch.tutorial.kubebuilder.io
88
spec:
99
group: batch.tutorial.kubebuilder.io

docs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ replacements:
7575
delimiter: '.'
7676
index: 0
7777
create: true
78+
- select: # Uncomment the following to set the Service name for TLS config in Prometheus ServiceMonitor
79+
kind: ServiceMonitor
80+
group: monitoring.coreos.com
81+
version: v1
82+
name: controller-manager-metrics-monitor
83+
fieldPaths:
84+
- spec.endpoints.0.tlsConfig.serverName
85+
options:
86+
delimiter: '.'
87+
index: 0
88+
create: true
7889

7990
- source:
8091
kind: Service
@@ -94,6 +105,17 @@ replacements:
94105
delimiter: '.'
95106
index: 1
96107
create: true
108+
- select: # Uncomment the following to set the Service namespace for TLS in Prometheus ServiceMonitor
109+
kind: ServiceMonitor
110+
group: monitoring.coreos.com
111+
version: v1
112+
name: controller-manager-metrics-monitor
113+
fieldPaths:
114+
- spec.endpoints.0.tlsConfig.serverName
115+
options:
116+
delimiter: '.'
117+
index: 1
118+
create: true
97119

98120
- source: # Uncomment the following block if you have any webhook
99121
kind: Service
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
# Patch for Prometheus ServiceMonitor to enable secure TLS configuration
22
# using certificates managed by cert-manager
3-
apiVersion: monitoring.coreos.com/v1
4-
kind: ServiceMonitor
5-
metadata:
6-
name: controller-manager-metrics-monitor
7-
namespace: system
8-
spec:
9-
endpoints:
10-
- tlsConfig:
11-
insecureSkipVerify: false
12-
ca:
13-
secret:
14-
name: metrics-server-cert
15-
key: ca.crt
16-
cert:
17-
secret:
18-
name: metrics-server-cert
19-
key: tls.crt
20-
keySecret:
21-
name: metrics-server-cert
22-
key: tls.key
3+
- op: replace
4+
path: /spec/endpoints/0/tlsConfig
5+
value:
6+
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
7+
serverName: SERVICE_NAME.SERVICE_NAMESPACE.svc
8+
insecureSkipVerify: false
9+
ca:
10+
secret:
11+
name: metrics-server-cert
12+
key: ca.crt
13+
cert:
14+
secret:
15+
name: metrics-server-cert
16+
key: tls.crt
17+
keySecret:
18+
name: metrics-server-cert
19+
key: tls.key

docs/book/src/cronjob-tutorial/testdata/project/dist/chart/templates/crd/batch.tutorial.kubebuilder.io_cronjobs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
{{- if .Values.crd.keep }}
1010
"helm.sh/resource-policy": keep
1111
{{- end }}
12-
controller-gen.kubebuilder.io/version: v0.17.1
12+
controller-gen.kubebuilder.io/version: v0.17.2
1313
name: cronjobs.batch.tutorial.kubebuilder.io
1414
spec:
1515
group: batch.tutorial.kubebuilder.io

docs/book/src/cronjob-tutorial/testdata/project/dist/chart/templates/prometheus/monitor.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
1616
tlsConfig:
1717
{{- if .Values.certmanager.enable }}
18+
serverName: project-controller-manager-metrics-service.{{ .Release.Namespace }}.svc
1819
# Apply secure TLS configuration with cert-manager
1920
insecureSkipVerify: false
2021
ca:

docs/book/src/cronjob-tutorial/testdata/project/dist/install.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apiVersion: apiextensions.k8s.io/v1
1111
kind: CustomResourceDefinition
1212
metadata:
1313
annotations:
14-
controller-gen.kubebuilder.io/version: v0.17.1
14+
controller-gen.kubebuilder.io/version: v0.17.2
1515
name: cronjobs.batch.tutorial.kubebuilder.io
1616
spec:
1717
group: batch.tutorial.kubebuilder.io
@@ -4276,7 +4276,11 @@ metadata:
42764276
namespace: project-system
42774277
spec:
42784278
endpoints:
4279-
- tlsConfig:
4279+
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
4280+
path: /metrics
4281+
port: https
4282+
scheme: https
4283+
tlsConfig:
42804284
ca:
42814285
secret:
42824286
key: ca.crt
@@ -4289,6 +4293,7 @@ spec:
42894293
keySecret:
42904294
key: tls.key
42914295
name: metrics-server-cert
4296+
serverName: project-controller-manager-metrics-service.project-system.svc
42924297
selector:
42934298
matchLabels:
42944299
app.kubernetes.io/name: project

0 commit comments

Comments
 (0)