Quickstart for Helm-based Operators
A simple set of instructions to set up and run a Helm-based operator.
This guide walks through an example of building a simple nginx-operator powered by Helm using tools and libraries provided by the Operator SDK.
Prerequisites
- Go through the installation guide.
- User authorized with
cluster-admin
permissions.
Steps
- Create a project directory for your project and initialize the project:
mkdir nginx-operator
cd nginx-operator
operator-sdk init --domain example.com --plugins helm
- Create a simple nginx API using Helm’s built-in chart boilerplate (from
helm create
):
operator-sdk create api --group demo --version v1alpha1 --kind Nginx
- Use the built-in Makefile targets to build and push your operator. Make sure to define
IMG
when you callmake
:
export OPERATOR_IMG="quay.io/example/nginx-operator:v0.0.1"
make docker-build docker-push IMG=$OPERATOR_IMG
OLM deployment
- Install OLM:
operator-sdk olm install
- Bundle your operator and push the bundle image:
make bundle IMG=$OPERATOR_IMG
# Note the "-bundle" component in the image name below.
export BUNDLE_IMG="quay.io/example/nginx-operator-bundle:v0.0.1"
make bundle-build BUNDLE_IMG=$BUNDLE_IMG
make docker-push IMG=$BUNDLE_IMG
- Run your bundle:
operator-sdk run bundle $BUNDLE_IMG
- Create a sample Nginx custom resource:
$ kubectl apply -f config/samples/demo_v1alpha1_nginx.yaml
nginx.demo.example.com/nginx-sample created
- Uninstall the operator:
operator-sdk cleanup nginx-operator
Direct deployment
- Deploy your operator:
make deploy IMG=$OPERATOR_IMG
- Create a sample Nginx custom resource:
$ kubectl apply -f config/samples/demo_v1alpha1_nginx.yaml
nginx.demo.example.com/nginx-sample created
- Uninstall the operator:
make undeploy
Next Steps
Read the full tutorial for an in-depth walkthough of building a Helm operator.
Last modified January 13, 2021: Align tutorial imports with test samples (#4393) (4209b568)
当前内容版权归 Operator SDK 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Operator SDK .