How do I deploy multiple flavours of an operator?

9/13/2021

I need to deploy the same operator multiple times and somehow ensure the right operator is called.

For example the first operator should be deployed with a given "flavour"/selector 'foo' the second with the "flavour" 'bar'.

When users need to access the operator how can they select which operator they are accessing?

---
apiVersion: my.domain/v1alpha1
kind: Traveller
metadata:
  name: some-traveller-sample
spec:
  cluster: "foo"
  databases:
    - "toto1"
    - "toto-golf"
---
apiVersion: my.domain/v1alpha1
kind: Traveller
metadata:
  name: some-traveller-sample
spec:
  cluster: "bar"
  databases:
    - "toto1"
    - "toto-wolf"

could it be possible to ensure the changes to reconcile are dispatched to the right operator.

-- Coyote
kubernetes
operator-sdk

1 Answer

9/29/2021

I have worked out how to achieve running multiple operators with some caveats.

I build my binary and setup 2 deployments each with a different flag, ie OPERATOR_CLUSTER_ID=foo on the first one and OPERATOR_CLUSTER_ID=bar on the second one..

The flag is used to setup a predicate which will check if the object received has the cluster field the instance is supposed to handle.

The down side is that unhandled cluster ids (manual input error, or missing field) do not report errors and will get ignored for ever.

It is a sub optimal way to run an operator, and against the operator best practices, but it works for my edge-case.

-- Coyote
Source: StackOverflow