Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kubernetes-sigs/kubebuilder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2d60e804a6d0cab0324b933ccf77316a5290c4ae
Choose a base ref
..
head repository: kubernetes-sigs/kubebuilder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c8ab90ee6f9f4bf04ef93ef395e6bb3759a330a3
Choose a head ref
Showing with 3,670 additions and 67 deletions.
  1. +76 −0 .github/workflows/test-helm-samples.yml
  2. +15 −2 Makefile
  3. +2 −0 cmd/main.go
  4. +26 −5 docs/book/src/cronjob-tutorial/testdata/project/README.md
  5. +1 −1 docs/book/src/cronjob-tutorial/testdata/project/config/network-policy/allow-metrics-traffic.yaml
  6. +26 −5 docs/book/src/getting-started/testdata/project/README.md
  7. +1 −1 docs/book/src/getting-started/testdata/project/config/network-policy/allow-metrics-traffic.yaml
  8. +26 −5 docs/book/src/multiversion-tutorial/testdata/project/README.md
  9. +1 −1 .../book/src/multiversion-tutorial/testdata/project/config/network-policy/allow-metrics-traffic.yaml
  10. +92 −0 docs/book/src/plugins/available/helm-v1-alpha.md
  11. +7 −5 docs/book/src/plugins/to-add-optional-features.md
  12. +36 −0 pkg/cli/alpha/internal/generate.go
  13. +1 −1 ...s/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-metrics-traffic.go
  14. +1 −1 pkg/plugins/golang/v4/init.go
  15. +4 −2 pkg/plugins/golang/v4/scaffolds/init.go
  16. +28 −5 pkg/plugins/golang/v4/scaffolds/internal/templates/readme.go
  17. +37 −0 pkg/plugins/optional/helm/v1alpha/commons.go
  18. +90 −0 pkg/plugins/optional/helm/v1alpha/edit.go
  19. +63 −0 pkg/plugins/optional/helm/v1alpha/init.go
  20. +65 −0 pkg/plugins/optional/helm/v1alpha/plugin.go
  21. +448 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/init.go
  22. +105 −0 ...ns/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/cert-manager/certificate.go
  23. +105 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/helpers_tpl.go
  24. +144 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/manager/manager.go
  25. +62 −0 ...ins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/metrics/metrics_service.go
  26. +83 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/prometheus/monitor.go
  27. +63 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/webhook/service.go
  28. +142 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/webhook/webhook.go
  29. +53 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart.go
  30. +70 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/helmignore.go
  31. +175 −0 pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/values.go
  32. +35 −0 pkg/plugins/optional/helm/webhookYAML.go
  33. +22 −0 test/e2e/alphagenerate/generate_test.go
  34. +52 −0 test/e2e/utils/test_context.go
  35. +47 −15 test/e2e/v4/plugin_cluster_test.go
  36. +6 −0 test/testdata/generate.sh
  37. +26 −5 testdata/project-v4-multigroup/README.md
  38. +1 −1 testdata/project-v4-multigroup/config/network-policy/allow-metrics-traffic.yaml
  39. +1 −0 testdata/project-v4-with-plugins/PROJECT
  40. +26 −5 testdata/project-v4-with-plugins/README.md
  41. +1 −1 testdata/project-v4-with-plugins/config/network-policy/allow-metrics-traffic.yaml
  42. +25 −0 testdata/project-v4-with-plugins/dist/chart/.helmignore
  43. +7 −0 testdata/project-v4-with-plugins/dist/chart/Chart.yaml
  44. +50 −0 testdata/project-v4-with-plugins/dist/chart/templates/_helpers.tpl
  45. +60 −0 testdata/project-v4-with-plugins/dist/chart/templates/certmanager/certificate.yaml
  46. +123 −0 testdata/project-v4-with-plugins/dist/chart/templates/crd/example.com.testproject.org_busyboxes.yaml
  47. +128 −0 ...data/project-v4-with-plugins/dist/chart/templates/crd/example.com.testproject.org_memcacheds.yaml
  48. +114 −0 ...ata/project-v4-with-plugins/dist/chart/templates/crd/example.com.testproject.org_wordpresses.yaml
  49. +79 −0 testdata/project-v4-with-plugins/dist/chart/templates/manager/manager.yaml
  50. +17 −0 testdata/project-v4-with-plugins/dist/chart/templates/metrics/metrics-service.yaml
  51. +27 −0 testdata/project-v4-with-plugins/dist/chart/templates/network-policy/allow-metrics-traffic.yaml
  52. +27 −0 testdata/project-v4-with-plugins/dist/chart/templates/network-policy/allow-webhook-traffic.yaml
  53. +38 −0 testdata/project-v4-with-plugins/dist/chart/templates/prometheus/monitor.yaml
  54. +28 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/busybox_admin_role.yaml
  55. +34 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/busybox_editor_role.yaml
  56. +30 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/busybox_viewer_role.yaml
  57. +41 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/leader_election_role.yaml
  58. +16 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/leader_election_role_binding.yaml
  59. +28 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/memcached_admin_role.yaml
  60. +34 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/memcached_editor_role.yaml
  61. +30 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/memcached_viewer_role.yaml
  62. +21 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/metrics_auth_role.yaml
  63. +16 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/metrics_auth_role_binding.yaml
  64. +13 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/metrics_reader_role.yaml
  65. +69 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/role.yaml
  66. +16 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/role_binding.yaml
  67. +9 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/service_account.yaml
  68. +28 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/wordpress_admin_role.yaml
  69. +34 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/wordpress_editor_role.yaml
  70. +30 −0 testdata/project-v4-with-plugins/dist/chart/templates/rbac/wordpress_viewer_role.yaml
  71. +16 −0 testdata/project-v4-with-plugins/dist/chart/templates/webhook/service.yaml
  72. +97 −0 testdata/project-v4-with-plugins/dist/chart/templates/webhook/webhooks.yaml
  73. +93 −0 testdata/project-v4-with-plugins/dist/chart/values.yaml
  74. +26 −5 testdata/project-v4/README.md
  75. +1 −1 testdata/project-v4/config/network-policy/allow-metrics-traffic.yaml
76 changes: 76 additions & 0 deletions .github/workflows/test-helm-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Helm Testdata Sample

on:
push:
paths:
- 'testdata/project-v4-with-plugins/**'
- '.github/workflows/test-helm-samples.yml'
pull_request:
paths:
- 'testdata/project-v4-with-plugins/**'
- '.github/workflows/test-helm-samples.yml'

jobs:
helm-test-project-v4-with-plugins:
runs-on: ubuntu-latest
strategy:
fail-fast: true
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '~1.22'

- name: Install the latest version of kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Verify kind installation
run: kind version

- name: Create kind cluster
run: kind create cluster

- name: Prepare project-v4-with-plugins
run: |
cd testdata/project-v4-with-plugins/
go mod tidy
make docker-build IMG=project-v4-with-plugins:v0.1.0
kind load docker-image project-v4-with-plugins:v0.1.0
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Verify Helm installation
run: helm version

- name: Lint Helm chart for project-v4-with-plugins
run: |
helm lint testdata/project-v4-with-plugins/dist/chart
- name: Install cert-manager via Helm
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
- name: Wait for cert-manager to be ready
run: |
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
- name: Install Helm chart for project-v4-with-plugins
run: |
helm install my-release testdata/project-v4-with-plugins/dist/chart --create-namespace --namespace project-v4-with-plugins-system
- name: Check Helm release status
run: |
helm status my-release --namespace project-v4-with-plugins-system
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -80,9 +80,14 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku
./test/testdata/generate.sh

.PHONY: generate-docs
generate-docs: ## Update/generate the docs in $GOPATH/src/sigs.k8s.io/kubebuilder
generate-docs: ## Update/generate the docs
./hack/docs/generate.sh

.PHONY: generate-charts
generate-charts: ## Re-generate the helm chart testdata only
rm -rf testdata/project-v4-with-plugins/dist/chart
(cd testdata/project-v4-with-plugins && kubebuilder edit --plugins=helm/v1-alpha)

.PHONY: check-docs
check-docs: ## Run the script to ensure that the docs are updated
./hack/docs/check.sh
@@ -97,7 +102,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes

.PHONY: yamllint
yamllint:
@files=$$(find testdata -name '*.yaml' ! -path 'testdata/*/dist/install.yaml'); \
@files=$$(find testdata -name '*.yaml' ! -path 'testdata/*/dist/*'); \
docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/yamllint:latest $$files -d "{extends: relaxed, rules: {line-length: {max: 120}}}" --no-warnings

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
@@ -171,3 +176,11 @@ test-spaces: ## Run the trailing spaces check
test-legacy: ## Run the tests to validate legacy path for webhooks
rm -rf ./testdata/**legacy**/
./test/testdata/legacy-webhook-path.sh

.PHONY: install-helm
install-helm: ## Install the latest version of Helm locally
@curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

.PHONY: helm-lint
helm-lint: install-helm ## Lint the Helm chart in testdata
helm lint testdata/project-v4-with-plugins/dist/chart
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ import (
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1"
golangv4 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/v4"
grafanav1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha"
helmv1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha"
)

func init() {
@@ -61,6 +62,7 @@ func main() {
&kustomizecommonv2.Plugin{},
&deployimagev1alpha1.Plugin{},
&grafanav1alpha1.Plugin{},
&helmv1alpha1.Plugin{},
),
cli.WithPlugins(externalPlugins...),
cli.WithDefaultPlugins(cfgv3.Version, gov4Bundle),
31 changes: 26 additions & 5 deletions docs/book/src/cronjob-tutorial/testdata/project/README.md
Original file line number Diff line number Diff line change
@@ -68,27 +68,48 @@ make undeploy

## Project Distribution

Following are the steps to build the installer and distribute this project to users.
Following the options to release and provide this solution to the users.

### By providing a bundle with all YAML files

1. Build the installer for the image built and published in the registry:

```sh
make build-installer IMG=<some-registry>/project:tag
```

NOTE: The makefile target mentioned above generates an 'install.yaml'
**NOTE:** The makefile target mentioned above generates an 'install.yaml'
file in the dist directory. This file contains all the resources built
with Kustomize, which are necessary to install this project without
its dependencies.
with Kustomize, which are necessary to install this project without its
dependencies.

2. Using the installer

Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:
Users can just run 'kubectl apply -f <URL for YAML BUNDLE>' to install
the project, i.e.:

```sh
kubectl apply -f https://raw.githubusercontent.com/<org>/project/<tag or branch>/dist/install.yaml
```

### By providing a Helm Chart

1. Build the chart using the optional helm plugin

```sh
kubebuilder edit --plugins=helm/v1-alpha
```

2. See that a chart was generated under 'dist/chart', and users
can obtain this solution from there.

**NOTE:** If you change the project, you need to update the Helm Chart
using the same command above to sync the latest changes. Furthermore,
if you create webhooks, you need to use the above command with
the '--force' flag and manually ensure that any custom configuration
previously added to 'dist/chart/values.yaml' or 'dist/chart/manager/manager.yaml'
is manually re-applied afterwards.

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This NetworkPolicy allows ingress traffic
# with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those
# namespaces are able to gathering data from the metrics endpoint.
# namespaces are able to gather data from the metrics endpoint.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
31 changes: 26 additions & 5 deletions docs/book/src/getting-started/testdata/project/README.md
Original file line number Diff line number Diff line change
@@ -68,27 +68,48 @@ make undeploy

## Project Distribution

Following are the steps to build the installer and distribute this project to users.
Following the options to release and provide this solution to the users.

### By providing a bundle with all YAML files

1. Build the installer for the image built and published in the registry:

```sh
make build-installer IMG=<some-registry>/project:tag
```

NOTE: The makefile target mentioned above generates an 'install.yaml'
**NOTE:** The makefile target mentioned above generates an 'install.yaml'
file in the dist directory. This file contains all the resources built
with Kustomize, which are necessary to install this project without
its dependencies.
with Kustomize, which are necessary to install this project without its
dependencies.

2. Using the installer

Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:
Users can just run 'kubectl apply -f <URL for YAML BUNDLE>' to install
the project, i.e.:

```sh
kubectl apply -f https://raw.githubusercontent.com/<org>/project/<tag or branch>/dist/install.yaml
```

### By providing a Helm Chart

1. Build the chart using the optional helm plugin

```sh
kubebuilder edit --plugins=helm/v1-alpha
```

2. See that a chart was generated under 'dist/chart', and users
can obtain this solution from there.

**NOTE:** If you change the project, you need to update the Helm Chart
using the same command above to sync the latest changes. Furthermore,
if you create webhooks, you need to use the above command with
the '--force' flag and manually ensure that any custom configuration
previously added to 'dist/chart/values.yaml' or 'dist/chart/manager/manager.yaml'
is manually re-applied afterwards.

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This NetworkPolicy allows ingress traffic
# with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those
# namespaces are able to gathering data from the metrics endpoint.
# namespaces are able to gather data from the metrics endpoint.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
31 changes: 26 additions & 5 deletions docs/book/src/multiversion-tutorial/testdata/project/README.md
Original file line number Diff line number Diff line change
@@ -68,27 +68,48 @@ make undeploy

## Project Distribution

Following are the steps to build the installer and distribute this project to users.
Following the options to release and provide this solution to the users.

### By providing a bundle with all YAML files

1. Build the installer for the image built and published in the registry:

```sh
make build-installer IMG=<some-registry>/project:tag
```

NOTE: The makefile target mentioned above generates an 'install.yaml'
**NOTE:** The makefile target mentioned above generates an 'install.yaml'
file in the dist directory. This file contains all the resources built
with Kustomize, which are necessary to install this project without
its dependencies.
with Kustomize, which are necessary to install this project without its
dependencies.

2. Using the installer

Users can just run kubectl apply -f <URL for YAML BUNDLE> to install the project, i.e.:
Users can just run 'kubectl apply -f <URL for YAML BUNDLE>' to install
the project, i.e.:

```sh
kubectl apply -f https://raw.githubusercontent.com/<org>/project/<tag or branch>/dist/install.yaml
```

### By providing a Helm Chart

1. Build the chart using the optional helm plugin

```sh
kubebuilder edit --plugins=helm/v1-alpha
```

2. See that a chart was generated under 'dist/chart', and users
can obtain this solution from there.

**NOTE:** If you change the project, you need to update the Helm Chart
using the same command above to sync the latest changes. Furthermore,
if you create webhooks, you need to use the above command with
the '--force' flag and manually ensure that any custom configuration
previously added to 'dist/chart/values.yaml' or 'dist/chart/manager/manager.yaml'
is manually re-applied afterwards.

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This NetworkPolicy allows ingress traffic
# with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those
# namespaces are able to gathering data from the metrics endpoint.
# namespaces are able to gather data from the metrics endpoint.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
Loading