Skip to content

Commit 65f9853

Browse files
📖 update samples
1 parent 7245d41 commit 65f9853

40 files changed

+14471
-6408
lines changed

docs/book/src/cronjob-tutorial/testdata/generate_cronjob.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function gen_cronjob_tutorial {
5252
mkdir project
5353
cd project
5454
header_text "creating tutorial.kubebuilder.io base ..."
55-
kubebuilder init --plugins=go/v3-alpha --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
55+
kubebuilder init --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
5656
kubebuilder create api --group batch --version v1 --kind CronJob --resource --controller
5757
kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation
5858
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ all: manager
1717
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
1818
test: generate fmt vet manifests
1919
mkdir -p ${ENVTEST_ASSETS_DIR}
20-
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0-alpha.6/hack/setup-envtest.sh
20+
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0/hack/setup-envtest.sh
2121
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
2222

2323
# Build manager binary
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
domain: tutorial.kubebuilder.io
2-
layout: go.kubebuilder.io/v3-alpha
2+
layout: go.kubebuilder.io/v3
33
projectName: project
44
repo: tutorial.kubebuilder.io/project
55
resources:
6-
- crdVersion: v1
6+
- api:
7+
crdVersion: v1
78
group: batch
89
kind: CronJob
910
version: v1
10-
webhookVersion: v1
11+
webhooks:
12+
webhookVersion: v1
1113
version: 3-alpha

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ the fields.
6262

6363
// CronJobSpec defines the desired state of CronJob
6464
type CronJobSpec struct {
65-
// +kubebuilder:validation:MinLength=0
65+
//+kubebuilder:validation:MinLength=0
6666

6767
// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
6868
Schedule string `json:"schedule"`
6969

70-
// +kubebuilder:validation:Minimum=0
70+
//+kubebuilder:validation:Minimum=0
7171

7272
// Optional deadline in seconds for starting the job if it misses scheduled
7373
// time for any reason. Missed jobs executions will be counted as failed ones.
@@ -90,14 +90,14 @@ type CronJobSpec struct {
9090
// Specifies the job that will be created when executing a CronJob.
9191
JobTemplate batchv1beta1.JobTemplateSpec `json:"jobTemplate"`
9292

93-
// +kubebuilder:validation:Minimum=0
93+
//+kubebuilder:validation:Minimum=0
9494

9595
// The number of successful finished jobs to retain.
9696
// This is a pointer to distinguish between explicit zero and not specified.
9797
// +optional
9898
SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"`
9999

100-
// +kubebuilder:validation:Minimum=0
100+
//+kubebuilder:validation:Minimum=0
101101

102102
// The number of failed finished jobs to retain.
103103
// This is a pointer to distinguish between explicit zero and not specified.
@@ -160,8 +160,8 @@ As previously noted, we don't need to change this, except to mark that
160160
we want a status subresource, so that we behave like built-in kubernetes types.
161161
*/
162162

163-
// +kubebuilder:object:root=true
164-
// +kubebuilder:subresource:status
163+
//+kubebuilder:object:root=true
164+
//+kubebuilder:subresource:status
165165

166166
// CronJob is the Schema for the cronjobs API
167167
type CronJob struct {
@@ -174,7 +174,7 @@ type CronJob struct {
174174
Status CronJobStatus `json:"status,omitempty"`
175175
}
176176

177-
// +kubebuilder:object:root=true
177+
//+kubebuilder:object:root=true
178178

179179
// CronJobList contains a list of CronJob
180180
type CronJobList struct {
@@ -187,4 +187,4 @@ func init() {
187187
SchemeBuilder.Register(&CronJob{}, &CronJobList{})
188188
}
189189

190-
// +kubebuilder:docs-gen:collapse=Root Object Definitions
190+
//+kubebuilder:docs-gen:collapse=Root Object Definitions

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This marker is responsible for generating a mutating webhook manifest.
5454
The meaning of each marker can be found [here](/reference/markers/webhook.md).
5555
*/
5656

57-
// +kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io
57+
//+kubebuilder:webhook:path=/mutate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,verbs=create;update,versions=v1,name=mcronjob.kb.io
5858

5959
/*
6060
We use the `webhook.Defaulter` interface to set defaults to our CRD.
@@ -90,7 +90,7 @@ This marker is responsible for generating a validating webhook manifest.
9090
*/
9191

9292
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
93-
// +kubebuilder:webhook:verbs=create;update,path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,versions=v1,name=vcronjob.kb.io
93+
//+kubebuilder:webhook:verbs=create;update,path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,versions=v1,name=vcronjob.kb.io
9494

9595
/*
9696
To validate our CRD beyond what's possible with declarative validation.

docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ metadata for the CRDs it creates from this package.
2424
*/
2525

2626
// Package v1 contains API Schema definitions for the batch v1 API group
27-
// +kubebuilder:object:generate=true
28-
// +groupName=batch.tutorial.kubebuilder.io
27+
//+kubebuilder:object:generate=true
28+
//+groupName=batch.tutorial.kubebuilder.io
2929
package v1
3030

3131
import (

docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
. "github.com/onsi/gomega"
3030

3131
admissionv1beta1 "k8s.io/api/admission/v1beta1"
32-
// +kubebuilder:scaffold:imports
32+
//+kubebuilder:scaffold:imports
3333
"k8s.io/apimachinery/pkg/runtime"
3434
"k8s.io/client-go/rest"
3535
ctrl "sigs.k8s.io/controller-runtime"
@@ -81,7 +81,7 @@ var _ = BeforeSuite(func() {
8181
err = admissionv1beta1.AddToScheme(scheme)
8282
Expect(err).NotTo(HaveOccurred())
8383

84-
// +kubebuilder:scaffold:scheme
84+
//+kubebuilder:scaffold:scheme
8585

8686
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
8787
Expect(err).NotTo(HaveOccurred())
@@ -102,7 +102,7 @@ var _ = BeforeSuite(func() {
102102
err = (&CronJob{}).SetupWebhookWithManager(mgr)
103103
Expect(err).NotTo(HaveOccurred())
104104

105-
// +kubebuilder:scaffold:webhook
105+
//+kubebuilder:scaffold:webhook
106106

107107
go func() {
108108
err = mgr.Start(ctx)

docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# The following manifests contain a self-signed issuer CR and a certificate CR.
22
# More document can be found at https://docs.cert-manager.io
3-
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
4-
# breaking changes
5-
apiVersion: cert-manager.io/v1alpha2
3+
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
4+
apiVersion: cert-manager.io/v1
65
kind: Issuer
76
metadata:
87
name: selfsigned-issuer
98
namespace: system
109
spec:
1110
selfSigned: {}
1211
---
13-
apiVersion: cert-manager.io/v1alpha2
12+
apiVersion: cert-manager.io/v1
1413
kind: Certificate
1514
metadata:
1615
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
# It should be run by config/default
44
resources:
55
- bases/batch.tutorial.kubebuilder.io_cronjobs.yaml
6-
# +kubebuilder:scaffold:crdkustomizeresource
6+
#+kubebuilder:scaffold:crdkustomizeresource
77

88
patchesStrategicMerge:
99
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
1111
#- patches/webhook_in_cronjobs.yaml
12-
# +kubebuilder:scaffold:crdkustomizewebhookpatch
12+
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1313

1414
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
1515
# patches here are for enabling the CA injection for each CRD
1616
#- patches/cainjection_in_cronjobs.yaml
17-
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
17+
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
1818

1919
# the following config is for teaching kustomize how to do kustomization for CRDs.
2020
configurations:

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,30 @@ bases:
1818
- ../manager
1919
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2020
# crd/kustomization.yaml
21-
- ../webhook
21+
#- ../webhook
2222
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
23-
- ../certmanager
23+
#- ../certmanager
2424
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2525
#- ../prometheus
2626

2727
patchesStrategicMerge:
28-
# Protect the /metrics endpoint by putting it behind auth.
29-
# If you want your controller-manager to expose the /metrics
30-
# endpoint w/o any authn/z, please comment the following line.
28+
# Protect the /metrics endpoint by putting it behind auth.
29+
# If you want your controller-manager to expose the /metrics
30+
# endpoint w/o any authn/z, please comment the following line.
3131
- manager_auth_proxy_patch.yaml
3232

33+
# Mount the controller config file for loading manager configurations
34+
# through a ComponentConfig type
35+
#- manager_config_patch.yaml
36+
3337
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
3438
# crd/kustomization.yaml
35-
- manager_webhook_patch.yaml
39+
#- manager_webhook_patch.yaml
3640

3741
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
3842
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
3943
# 'CERTMANAGER' needs to be enabled to use ca injection
40-
- webhookcainjection_patch.yaml
44+
#- webhookcainjection_patch.yaml
4145

4246
# the following config is for teaching kustomize how to do var substitution
4347
vars:
@@ -46,15 +50,15 @@ vars:
4650
objref:
4751
kind: Certificate
4852
group: cert-manager.io
49-
version: v1alpha2
53+
version: v1
5054
name: serving-cert # this name should match the one in certificate.yaml
5155
fieldref:
5256
fieldpath: metadata.namespace
5357
- name: CERTIFICATE_NAME
5458
objref:
5559
kind: Certificate
5660
group: cert-manager.io
57-
version: v1alpha2
61+
version: v1
5862
name: serving-cert # this name should match the one in certificate.yaml
5963
- name: SERVICE_NAMESPACE # namespace of the service
6064
objref:

0 commit comments

Comments
 (0)