by debarshri · 3y ago · 0 comments
My complaint is that I have seen orgs write operators for random stuff, often reinventing the wheel. Lot of operators in orgs are result of resume driven development. Having said that it often comes handy for complex orchestration.
Normally you would have a CI/CD pipeline setup that shit before deployment.
But thats super brittle and against GitOps. So you write custom CRDs you can store in repo that abstract away the complexity of the setup but still provide devs with srlf-service approaches to configure their app monitoring for them.
If you start thinking about self-service and gitops - operators become very useful for many things.
An operator is needed when you can't just deploy and forget about it. An example is the Prometheus operator, which will track annotations created by users to configure the scraping configuration of your Prometheus instances. Another example is cert-manager, which gets certificates into secrets based on Certificate and Ingress objects, renews them automatically before expiry, and does that by creating ingresses picked up by your ingress controller.
The advantage of an operator is that it will react to stuff happening in the cluster. The drawback is that it reacts to stuff happening, potentially doing unexpected things because changes happen at any time and you can't dry-run them. Another drawback is that they are usually global, so you can't run multiple versions at the same time for different namespaces (mainly because custom resource definitions are global).
Unfortunately many people think packaging an application = creating an operator, and that operator does nothing a chart couldn't do.
Edit: maybe we could shift left and ask the app developers to add certificate acquisition directly into the app source.
A certificate for service to service communication does not have to correspond to a public endpoint.
Or is can be actively harmful when they don't do any error checking whatsoever, causing it to be less accurate that `helm template` would be. Related, it's also one more thing to monitor because it can decide to start vomiting errors for whatever random reason
The main point of Prometheus operator is to federate access to Prometheus configuration so teams can manage configuration that the built-in Kubernetes service discovery doesn't let you control from an application side. Things like scrape interval, recording rules and alerts, etc. ServiceMonitors, PrometheusRule CRDs basically let app owners ship these aspects of monitoring with their applications, instead of having to have a hand-off between the service owners and the SRE teams managing the monitoring infrastructure.
So yes -> you need an operator to dynamically change config of prometheus. If not -> all your changes wont matter because they will be not reflected in prom.
The operator will do this for you, you just update the version of the broker in the CR spec, it notices, and then applies the change.
Likewise, some configuration options can be applied at runtime, some need the broker to be restarted to be applied, the operator knows which are which, and will again manage the process of a rolling restart if needed to apply the change.
You can also define topics and users as custom resources, so have a nice Gitops approach to declaring resources.
Disclaimer: In my past job, I've worked at Red Hat, who are sponsoring Strimzi
- scaling up and down applications because of time instead of demand. or based on non metric based actions
- Extending kubernetes to understand your workload
- Automating configuration and management of complex applications
- Managing legacy applications that cannot be easily containerized or migrated to the cloud.
if you love k8s youll love operators
the list is endless!
Kubernetes is more like a way of doing things than a technology. Basically APIs all the way down. and thus the operators and controllers do deserve love.
Im not saying that you need an operator to change the dipers of a baby, but as far as a stack goes, k8s is the best i have ever worked with.
The only moderately justifiable operator I've ever seen is cert-manager. Even then, one wonders what it would be like if it just updated a Secret every 3 months based on a hard-coded config passed to it, and skipped the CRDs.
An example that has come up for me is an operator for a Kafka Schema Registry. This is a service that needs some credentials in a somewhat obscure format so it can communicate very directly with a Kafka broker. If the broker's certificates (or CA) are modified, then the Schema Registry needs to have new credentials generated, and needs to be restarted. But the registry shouldn't (obviously) have direct access to the broker's certificates. Instead, there's a more-privileged subsystem which orchestrates that dance; that's the operator.