-
Notifications
You must be signed in to change notification settings - Fork 1.6k
📖 (doc) - refactory and clenup the Plugin section #4185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:master
from
camilamacedo86:cleanup-docs-plugin
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
docs/book/src/plugins/available/deploy-image-plugin-v1-alpha.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # Deploy Image Plugin (deploy-image/v1-alpha) | ||
|
|
||
| The `deploy-image` plugin allows users to create [controllers][controller-runtime] and custom resources that deploy and manage container images on the cluster, following Kubernetes best practices. It simplifies the complexities of deploying images while allowing users to customize their projects as needed. | ||
|
|
||
| By using this plugin, you will get: | ||
|
|
||
| - A controller implementation to deploy and manage an Operand (image) on the cluster. | ||
| - Tests to verify the reconciliation logic, using [ENVTEST][envtest]. | ||
| - Custom resource samples updated with the necessary specifications. | ||
| - Environment variable support for managing the Operand (image) within the manager. | ||
|
|
||
| <aside class="note"> | ||
| <h1>Examples</h1> | ||
|
|
||
| See the `project-v4-with-plugins` directory under the [testdata][testdata] | ||
| directory in the Kubebuilder project to check an example | ||
| of scaffolding created using this plugin. | ||
|
|
||
| The `Memcached` API and its controller was scaffolded | ||
| using the command: | ||
|
|
||
| ```shell | ||
| kubebuilder create api \ | ||
| --group example.com \ | ||
| --version v1alpha1 \ | ||
| --kind Memcached \ | ||
| --image=memcached:memcached:1.6.26-alpine3.19 \ | ||
| --image-container-command="memcached,--memory-limit=64,-o,modern,-v" \ | ||
| --image-container-port="11211" \ | ||
| --run-as-user="1001" \ | ||
| --plugins="deploy-image/v1-alpha" | ||
| ``` | ||
|
|
||
| The `Busybox` API was created with: | ||
|
|
||
| ```shell | ||
| kubebuilder create api \ | ||
| --group example.com \ | ||
| --version v1alpha1 \ | ||
| --kind Busybox \ | ||
| --image=busybox:1.36.1 \ | ||
| --plugins="deploy-image/v1-alpha" | ||
| ``` | ||
| </aside> | ||
|
|
||
|
|
||
| ## When to use it? | ||
|
|
||
| - This plugin is ideal for users who are just getting started with Kubernetes operators. | ||
| - It helps users deploy and manage an image (Operand) using the [Operator pattern][operator-pattern]. | ||
| - If you're looking for a quick and efficient way to set up a custom controller and manage a container image, this plugin is a great choice. | ||
|
|
||
| ## How to use it? | ||
|
|
||
| 1. **Initialize your project**: | ||
| After creating a new project with `kubebuilder init`, you can use this | ||
| plugin to create APIs. Ensure that you've completed the | ||
| [quick start][quick-start] guide before proceeding. | ||
|
|
||
| 2. **Create APIs**: | ||
| With this plugin, you can [create APIs][create-apis] to specify the image (Operand) you want to deploy on the cluster. You can also optionally specify the command, port, and security context using various flags: | ||
camilamacedo86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Example command: | ||
| ```sh | ||
| kubebuilder create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:1.6.15-alpine --image-container-command="memcached,--memory-limit=64,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" | ||
| ``` | ||
|
|
||
| <aside class="warning"> | ||
| <h1>Note on make run:</h1> | ||
|
|
||
| When running the project locally with `make run`, the Operand image | ||
| provided will be stored as an environment variable in the | ||
| `config/manager/manager.yaml` file. | ||
|
|
||
| Ensure you export the environment variable before running the project locally, such as: | ||
|
|
||
| ```shell | ||
| export MEMCACHED_IMAGE="memcached:1.4.36-alpine" | ||
| ``` | ||
|
|
||
| </aside> | ||
|
|
||
| ## Subcommands | ||
|
|
||
| The `deploy-image` plugin includes the following subcommand: | ||
|
|
||
| - `create api`: Use this command to scaffold the API and controller code to manage the container image. | ||
|
|
||
| ## Affected files | ||
|
|
||
| When using the `create api` command with this plugin, the following | ||
| files are affected, in addition to the existing Kubebuilder scaffolding: | ||
|
|
||
| - `controllers/*_controller_test.go`: Scaffolds tests for the controller. | ||
| - `controllers/*_suite_test.go`: Scaffolds or updates the test suite. | ||
| - `api/<version>/*_types.go`: Scaffolds the API specs. | ||
| - `config/samples/*_.yaml`: Scaffolds default values for the custom resource. | ||
| - `main.go`: Updates the file to add the controller setup. | ||
| - `config/manager/manager.yaml`: Updates to include environment variables for storing the image. | ||
|
|
||
| ## Further Resources: | ||
|
|
||
| - Check out this [video][video] to see how it works. | ||
|
|
||
| [video]: https://youtu.be/UwPuRjjnMjY | ||
| [operator-pattern]: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ | ||
| [controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime | ||
| [testdata]: ./.././../../../../testdata/project-v4-with-plugins | ||
| [envtest]: ./../../reference/envtest.md | ||
| [quick-start]: ./../../quick-start.md | ||
| [create-apis]: ../../cronjob-tutorial/new-api.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # go/v4 (go.kubebuilder.io/v4) | ||
|
|
||
| **(Default Scaffold)** | ||
|
|
||
| Kubebuilder will scaffold using the `go/v4` plugin only if specified when initializing the project. | ||
| This plugin is a composition of the `kustomize.common.kubebuilder.io/v2` and `base.go.kubebuilder.io/v4` plugins | ||
| using the [Bundle Plugin][bundle]. It scaffolds a project template | ||
| that helps in constructing sets of [controllers][controller-runtime]. | ||
|
|
||
| By following the [quickstart][quickstart] and creating any project, | ||
| you will be using this plugin by default. | ||
|
|
||
| <aside class="note"> | ||
| <h1>Examples</h1> | ||
|
|
||
| You can check samples using this plugin by looking at the `project-v4-<options>` projects under the [testdata][testdata] | ||
| directory on the root directory of the Kubebuilder project. | ||
|
|
||
| </aside> | ||
|
|
||
| ## How to use it ? | ||
|
|
||
| To create a new project with the `go/v4` plugin the following command can be used: | ||
|
|
||
| ```sh | ||
| kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v4 | ||
| ``` | ||
|
|
||
| ## Subcommands supported by the plugin | ||
|
|
||
| - Init - `kubebuilder init [OPTIONS]` | ||
| - Edit - `kubebuilder edit [OPTIONS]` | ||
| - Create API - `kubebuilder create api [OPTIONS]` | ||
| - Create Webhook - `kubebuilder create webhook [OPTIONS]` | ||
|
|
||
| ## Further resources | ||
|
|
||
| - To see the composition of plugins, you can check the source code for the Kubebuilder [main.go][plugins-main]. | ||
| - Check the code implementation of the [base Golang plugin `base.go.kubebuilder.io/v4`][v4-plugin]. | ||
| - Check the code implementation of the [Kustomize/v2 plugin][kustomize-plugin]. | ||
| - Check [controller-runtime][controller-runtime] to know more about controllers. | ||
|
|
||
| [controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime | ||
| [quickstart]: ./../../quick-start.md | ||
| [testdata]: ./../../../../../testdata | ||
| [plugins-main]: ./../../../../../cmd/main.go | ||
| [kustomize-plugin]: ./../../plugins/avaialable/kustomize-v2.md | ||
| [kustomize]: https://github.com/kubernetes-sigs/kustomize | ||
| [standard-go-project]: https://github.com/golang-standards/project-layout | ||
| [v4-plugin]: ./../../../../../pkg/plugins/golang/v4 | ||
| [migration-guide-doc]: ./../../migration/migration_guide_gov3_to_gov4.md | ||
| [project-doc]: ./../../reference/project-config.md | ||
| [bundle]: ./../../../../../pkg/plugin/bundle.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.