Quickstart for Ansible-based Operators
A simple set of instructions to set up and run an Ansible-based operator.
This guide walks through an example of building a simple memcached-operator powered by Ansible using tools and libraries provided by the Operator SDK.
Prerequisites
- Go through the installation guide.
- User authorized with
cluster-admin
permissions. - An accessible image registry for various operator images (ex. hub.docker.com, quay.io) and be logged in in your command line environment.
example.com
is used as the registry Docker Hub namespace in these examples. Replace it with another value if using a different registry or namespace.- Authentication and certificates if the registry is private or uses a custom CA.
Steps
- Create a project directory for your project and initialize the project:
mkdir memcached-operator
cd memcached-operator
operator-sdk init --domain example.com --plugins ansible
- Create a simple Memcached API:
operator-sdk create api --group cache --version v1alpha1 --kind Memcached --generate-role
- Build and push your operator’s image:
make docker-build docker-push IMG="example.com/memcached-operator:v0.0.1"
OLM deployment
- Install OLM:
operator-sdk olm install
- Bundle your operator, then build and push the bundle image (defaults to
example.com/memcached-operator-bundle:v0.0.1
):
make bundle IMG="example.com/memcached-operator:v0.0.1"
make bundle-build bundle-push
- Run your bundle. If your bundle image is hosted in a registry that is private and/or has a custom CA, these configuration steps must be complete.
operator-sdk run bundle example.com/memcached-operator-bundle:v0.0.1
- Create a sample Memcached custom resource:
$ kubectl apply -f config/samples/cache_v1alpha1_memcached.yaml
memcached.cache.example.com/memcached-sample created
- Uninstall the operator:
operator-sdk cleanup memcached-operator
Direct deployment
- Deploy your operator:
make deploy IMG="example.com/memcached-operator:v0.0.1"
- Create a sample Memcached custom resource:
$ kubectl apply -f config/samples/cache_v1alpha1_memcached.yaml
memcached.cache.example.com/memcached-sample created
- Uninstall the operator:
make undeploy
Next Steps
Read the full tutorial for an in-depth walkthough of building a Ansible operator.
Last modified April 12, 2021: `run bundle(-upgrade)`: configure registry pod with root certificate secret (#4703) (7e43b470)
当前内容版权归 Operator SDK 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Operator SDK .