Skip to content

Commit 1428bba

Browse files
authored
Merge pull request #1934 from estroz/update-release-3
🌱 update release-3 for v3.0.0-alpha.1
2 parents 21de760 + 26d7b42 commit 1428bba

File tree

280 files changed

+15579
-7208
lines changed

Some content is hidden

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

280 files changed

+15579
-7208
lines changed

cmd/main.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@ func main() {
3434
&pluginv2.Plugin{},
3535
&pluginv3.Plugin{},
3636
),
37-
cli.WithDefaultPlugins(config.Version2,
38-
&pluginv2.Plugin{},
39-
),
40-
cli.WithDefaultPlugins(config.Version3Alpha,
41-
&pluginv2.Plugin{},
42-
),
37+
cli.WithDefaultPlugins(config.Version2, &pluginv2.Plugin{}),
38+
cli.WithDefaultPlugins(config.Version3Alpha, &pluginv3.Plugin{}),
4339
cli.WithCompletion,
4440
)
4541
if err != nil {

docs/book/src/component-config-tutorial/api-changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps](/quick-start.md#installation) before continuing.
1111
```bash
1212
# we'll use a domain of tutorial.kubebuilder.io,
1313
# so all API groups will be <group>.tutorial.kubebuilder.io.
14-
kubebuilder init --plugins=go/v3-alpha --domain tutorial.kubebuilder.io --component-config
14+
kubebuilder init --domain tutorial.kubebuilder.io --component-config
1515
```
1616

1717
## Setting up an exising project

docs/book/src/cronjob-tutorial/cronjob-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ project:
4646
```bash
4747
# we'll use a domain of tutorial.kubebuilder.io,
4848
# so all API groups will be <group>.tutorial.kubebuilder.io.
49-
kubebuilder init --plugins=go/v3-alpha --domain tutorial.kubebuilder.io
49+
kubebuilder init --domain tutorial.kubebuilder.io
5050
```
5151

5252
<aside class="note">

docs/book/src/cronjob-tutorial/gvks.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ a package.
4646
Now that we have our terminology straight, we can *actually* create our
4747
API!
4848

49+
## So, how can we create our API?
50+
51+
In the next section, [Adding a new API](./cronjob-tutorial/new-api.html) we will check how the tool help us to create our own API's with the command `kubebuilder create api`.
52+
53+
The goal of this command is to create Custom Resource (CR) and Custom Resource Definition (CRD) for our Kind(s). To check it further see; [Extend the Kubernetes API with CustomResourceDefinitions][kubernetes-extend-api].
54+
55+
## But, why create APIs at all?
56+
57+
New APIs are how we teach Kubernetes about our custom objects. The Go structs are used to generate a Custom Resource Definition (CRD) which includes the schema for our data as well as tracking data like what our new type is called. We can then create instances of our custom objects which will be managed by our [controllers][controllers].
58+
59+
Our APIs and resouces represent our solutions on the clusters. Basically, the CRDs are a definition of our customized Objects, and the CRs are an instance of it.
60+
61+
## Ah, do you have an example?
62+
63+
Let’s think about the classic scenario where the goal is to have an application and its database running on the platform with Kubernetes. Then, one CRD could represent the App, and another one could represent the DB. By having one CRD to describe the App and another one for the DB, we will not be hurting concepts such as encapsulation, the single responsibility principle, and cohesion. Damaging these concepts could cause unexpected side effects, such as difficulty in extending, reuse, or maintenance, just to mention a few.
64+
65+
In this way, we can create the App CRD which will have its controller and which would be responsible for things like creating Deployments that contain the App and creating Services to access it and etc. Similarly, we could create a CRD to represent the DB, and deploy a controller that would manage DB instances.
66+
4967
## Err, but what's that Scheme thing?
5068

5169
The `Scheme` we saw before is simply a way to keep track of what Go type
@@ -70,3 +88,6 @@ API server that says
7088

7189
or properly look up the group-version when we go to submit a `&CronJob{}`
7290
in an update.
91+
92+
[kubernetes-extend-api]: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/
93+
[controllers]: ../cronjob-tutorial/controller-overview.md

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 (

0 commit comments

Comments
 (0)