Skip to content

Commit

Permalink
Merge branch 'kubernetes-sigs:master' into yash-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
yashsingh74 committed Mar 13, 2023
2 parents e6e0851 + 1dc75e3 commit a59746c
Show file tree
Hide file tree
Showing 120 changed files with 488 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/apidiff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
go-version: "1.19"
- name: Execute go-apidiff
uses: joelanford/go-apidiff@v0.5.0
uses: joelanford/go-apidiff@v0.6.0
with:
compare-imports: true
print-compatible: true
Expand Down
1 change: 1 addition & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ aliases:
- joelanford
- rashmigottipati
- everettraven
- Kavinjsir

# folks who may have context on ancient history,
# but are no longer directly involved
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,7 @@ supporting Windows are welcome.

### Apple Silicon

Apple Silicon (`darwin/arm64`) is supported using the `go/v4-alpha` plugin which provides support for this platform.

```bash
kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4-alpha
```

**Note**: The `go/v4-alpha` plugin is an unstable version and can have breaking changes in future releases. The previous kustomize
version (`v3.Y.Z`) used in the `go/v3` has no available binaries for this
platform [kubernetes-sigs/kustomize/issues/4612](https://github.com/kubernetes-sigs/kustomize/issues/4612)
Because of this, we cannot support this `darwin/arm64` on the stable scaffold done by default with the Kubebuilder with the `go/v3` plugin.
Apple Silicon (`darwin/arm64`) support begins with the `go/v4` plugin.

## Community Meetings

Expand Down
5 changes: 2 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ import (
cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
"sigs.k8s.io/kubebuilder/v3/pkg/model/stage"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1"
kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha"
kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
declarativev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1"
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1"
Expand All @@ -46,7 +45,7 @@ func main() {
golangv3.Plugin{},
)
// Bundle plugin which built the golang projects scaffold by Kubebuilder go/v4 with kustomize alpha-v2
gov4Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 4, Stage: stage.Alpha},
gov4Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 4},
kustomizecommonv2alpha.Plugin{},
golangv4.Plugin{},
)
Expand Down
2 changes: 1 addition & 1 deletion designs/extensible-cli-and-scaffolding-plugins-phase-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ plugins:
- domain: testproject.org
group: crew
kind: Captain
version: v2-alpha
version: v2
declarative.go.kubebuilder.io/v1:
resources:
- domain: testproject.org
Expand Down
4 changes: 2 additions & 2 deletions designs/helper_to_upgrade_projects_by_rescaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ to be addressed and maintained.

We could use it to do cool future features such as creating a GitHub action which would push-pull requests against the project repositories to help users be updated with, for example, minor changes. By using this command, we might able to git clone the project and to do a new scaffold and then use some [git strategy merge](https://www.geeksforgeeks.org/merge-strategies-in-git/) to result in a PR to purpose the required changes.

We probably need to store the CLI tool tag release used to do the scaffold to persuade this idea. So that we can know if the project requires or not updates.
We probably need to store the CLI tool tag release used to do the scaffold to persuade this idea. So that we can know if the project requires updates or not.

[project-config]: https://book.kubebuilder.io/reference/project-config.html
[project-config]: https://book.kubebuilder.io/reference/project-config.html
2 changes: 1 addition & 1 deletion docs/book/install-and-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ${cmd} /tmp/mdbook.${ext}
chmod +x /tmp/mdbook

echo "grabbing the latest released controller-gen"
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.1
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3

# make sure we add the go bin directory to our path
gobin=$(go env GOBIN)
Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
- [Migration Guide](migration/legacy/migration_guide_v2tov3.md)
- [Migration by updating the files](migration/legacy/manually_migration_guide_v2_v3.md)
- [From v3.0.0 with plugins](./migration/v3-plugins.md)
- [go/v3 vs go/v4-alpha](migration/v3vsv4.md)
- [go/v3 vs go/v4](migration/v3vsv4.md)

- [Migration Guide](migration/migration_guide_gov3_to_gov4.md)
- [Migration by updating the files](migration/manually_migration_guide_gov3_to_gov4.md)
Expand Down Expand Up @@ -117,7 +117,7 @@
- [To scaffold a project](./plugins/to-scaffold-project.md)
- [go/v2 (Deprecated)](./plugins/go-v2-plugin.md)
- [go/v3 (Default init scaffold)](./plugins/go-v3-plugin.md)
- [go/v4-alpha](./plugins/go-v4-plugin.md)
- [go/v4](./plugins/go-v4-plugin.md)
- [To add optional features](./plugins/to-add-optional-features.md)
- [declarative/v1](./plugins/declarative-v1.md)
- [grafana/v1-alpha](./plugins/grafana-v1-alpha.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/component-config-tutorial/api-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ steps](/quick-start.md#installation) before continuing.
kubebuilder init --domain tutorial.kubebuilder.io --component-config
```

## Setting up an exising project
## Setting up an existing project

If you've previously generated a project we can add support for parsing the
config file by making the following changes to `main.go`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The basic logic of our CronJob controller is this:
7. Requeue when we either see a running job (done automatically) or it's
time for the next scheduled run.

{{#literatego ./testdata/project/controllers/cronjob_controller.go}}
{{#literatego ./testdata/project/internal/controller/cronjob_controller.go}}

That was a doozy, but now we've got a working controller. Let's test
against the cluster, then, if we don't have any issues, deploy it!
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/main-revisited.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ But first, remember how we said we'd [come back to `main.go`
again](/cronjob-tutorial/empty-main.md)? Let's take a look and see what's
changed, and what we need to add.

{{#literatego ./testdata/project/main.go}}
{{#literatego ./testdata/project/cmd/main.go}}

*Now* we can implement our controller.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function gen_cronjob_tutorial {
mkdir project
cd project
header_text "creating tutorial.kubebuilder.io base ..."
kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder init --plugins=go/v4 --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder create api --group batch --version v1 --kind CronJob --resource --controller
kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation
go mod tidy
Expand Down
6 changes: 3 additions & 3 deletions docs/book/src/cronjob-tutorial/testdata/project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/controller/ internal/controller/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
8 changes: 4 additions & 4 deletions docs/book/src/cronjob-tutorial/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run ./cmd/main.go

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
Expand Down Expand Up @@ -132,8 +132,8 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.11.1
KUSTOMIZE_VERSION ?= v5.0.0
CONTROLLER_TOOLS_VERSION ?= v0.11.3

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/testdata/project/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: tutorial.kubebuilder.io
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
projectName: project
repo: tutorial.kubebuilder.io/project
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

admissionv1beta1 "k8s.io/api/admission/v1beta1"
admissionv1 "k8s.io/api/admission/v1"
//+kubebuilder:scaffold:imports
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -78,7 +78,7 @@ var _ = BeforeSuite(func() {
err = AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = admissionv1beta1.AddToScheme(scheme)
err = admissionv1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

//+kubebuilder:scaffold:scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package main
import (
"flag"
"os"
"tutorial.kubebuilder.io/project/internal/controller"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand All @@ -33,7 +34,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"

batchv1 "tutorial.kubebuilder.io/project/api/v1"
"tutorial.kubebuilder.io/project/controllers"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -109,7 +109,7 @@ func main() {

// +kubebuilder:docs-gen:collapse=old stuff

if err = (&controllers.CronJobReconciler{
if err = (&controller.CronJobReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
app.kubernetes.io/name: issuer
app.kubernetes.io/instance: selfsigned-issuer
app.kubernetes.io/name: certificate
app.kubernetes.io/instance: serving-cert
app.kubernetes.io/component: certificate
app.kubernetes.io/created-by: project
app.kubernetes.io/part-of: project
Expand All @@ -29,10 +29,10 @@ metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
namespace: system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- SERVICE_NAME.SERVICE_NAMESPACE.svc
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# This configuration is for teaching kustomize how to update name ref and var substitution
# This configuration is for teaching kustomize how to update name ref substitution
nameReference:
- kind: Issuer
group: cert-manager.io
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: cronjobs.batch.tutorial.kubebuilder.io
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
name: cronjobs.batch.tutorial.kubebuilder.io
Loading

0 comments on commit a59746c

Please sign in to comment.