The deploy-image
plugin allows users to create controllers 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:
See the project-v4-with-plugins
directory under the 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:
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:
kubebuilder create api \
--group example.com \
--version v1alpha1 \
--kind Busybox \
--image=busybox:1.36.1 \
--plugins="deploy-image/v1-alpha"
When to use it?
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 guide before proceeding.
Create APIs: With this plugin, you can 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:
Example command:
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"
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:
export MEMCACHED_IMAGE="memcached:1.4.36-alpine"
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.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.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4