169 points · by todsacerdoti · 3y ago · 74 comments
> An Operator is an application-specific controller that extends the Kubernetes API to create, configure, and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and controller concepts but includes domain or application-specific knowledge to automate common tasks.
This is the original definition of an operator [1]. People no use them for stateless things and domain specific work has taken off.
You can look at the Kubernetes docs [2] to see refinements on it...
> Kubernetes' operator pattern concept lets you extend the cluster's behaviour without modifying the code of Kubernetes itself by linking controllers to one or more custom resources. Operators are clients of the Kubernetes API that act as controllers for a Custom Resource.
[1] https://web.archive.org/web/20190113035722/https://coreos.co...
[2] https://kubernetes.io/docs/concepts/extend-kubernetes/operat...
mind clarifying?
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.
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 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.
- 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!
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.
Also it's important for people reading this article - an apiservice (which this article talks about) is very rarely something that should be done. An operator is more appropriate for nearly all cases except for when you truly need your state stored outside of the internal Kubernetes etcd datastore.
> Operators are clients of the Kubernetes API that act as controllers for a Custom Resource.
In the mean time, one of the creators of the Operator Framework[0] built a bunch of useful patterns using generics that we used to build the SpiceDB Operator[1] called controller-idioms[2].
Does anyone know of other efforts to improve the status quo?
[0]: https://operatorframework.io
I'm hoping things are improving. Maybe I'll consider it for the next one I write.
It's frustrating to be a kubernetes admin but not have access to basic configuration options because the maintainers of even some very high-profile operators (looking at you, AWX) neglected to build in access to basic functionality.
In the latest release of the spicedb-operator[0], I added a feature that allows users to specify arbitrary patches over operator-managed resources directly in the API (examples in the link).
There are some other projects like Kyverno and Gatekeeper that try to do this generically with mutating webhooks, but embedding a `patches` API into the operator itself gives the operator a chance to ensure the changes are within some reasonable guardrails.
[0]: https://github.com/authzed/spicedb-operator/releases/tag/v1....
Operators are just the non-containerized daemons of the Kubernetes OS. We did all this work to run everything in neatly encapsulated containers, and then everyone wants to run stuff globally on the whole cluster. What's the point? Do we just containerize clusters and start over?
Migrations can be run in containers (and they are, even with the operator), but it's actually a lot of work to run them at the right time, only once, with the right flags, in the right order, waiting for SpiceDB to reach a specific spot in phased migrations, etc.
Moving from v1.13.0 to v1.14.0 of SpiceDB requires a multi-phase migration to avoid downtime[0], as could any phased migration for any stateful workload. The operator will walk you through them correctly, without intervention. Users who aren't running on Kubernetes or aren't using the operator often have problems running these steps correctly.
The value is in this automation, but also in the API interface itself. RDS is just some automation and an API on top of EC2, and I think RDS has value over running postgres on EC2 myself directly.
As for helm charts, this is just my opinion, but I don't think they're a good way to distribute software to end users. The interface for a helm chart becomes polluted over time in the same way that most operator APIs become polluted over time, as more and more configuration is pulled up to the top. I think helm is better suited to managing configuration you write yourself to deploy on your own clusters (I realize I'm in the minority here).
[0]: https://github.com/authzed/spicedb/releases/tag/v1.14.0
Just curious, is this a limitation of the Operators framework, or that of your system's implementation? My knee-jerk reaction is that any implementation should absolutely not require opening ticket. After all, Amazon's API mandate happened 20 years ago, and Netflix followed suit to achieve phenomenal productivity for their engineers. I have a hard time imagining why any engineer would think that gatekeeping configuration with PR is a good idea(a UI with proper automation and approval process that hides generated PR for specific use cases is a different matter)
An operator (or its custom resource) can be configured by Kubernetes YAML/API and its upto the creator of the operator to specify the kind of configuration. If the operator creator did not specify options to set cpu/memory limits on the pods managed by the operator, then you can't do anything. You have to add that feature into the operator and then make a pull request and wait for it to be upstreamed.
Or fork it instead. Same thing for helm charts (except forking and patching them is easier than forking an operator).
I've seen just as much if not more issues with debugging the operator logic itself as with the main pods/deployments it was trying to manage.
So just from a practical point of view, I think it should be a last resort after everything else fails (helm charts, etc).
There really is no magic, is all there and with go the images are usually what? like 10 mb?
It's essential to have a solid understanding of Kubernetes architecture, concepts such as custom resources and controllers, and the tools and APIs available for working with Operators.
Dont use rust though, use and sdk like the operator sdk or kubebuilder. Its native to k8s and you will have a much easier time too.
It should be helpful if you are new to the Operator concept.
Operators are generally useful for handling domain-specific actions - for example, performing database backups, installing plugins on Moodle/Wordpress, etc. If you are looking for application deployment then a Helm chart should be sufficient.
In my years of working with Kubernetes I cannot shake the feeling that it's, basically, an MLM. It carefully obscures it's functionality by hiding behind opaque definitions. It doesn't really work, when push comes to shove. And, most importantly, it survives in a parasitic kind of way: by piggybacking on those who develop all kinds of extensions, be it operators, custom networking or storage plugins, authentication and so on.
My problem is I cannot find who stands at the top of the pyramid. There's Cloudnative Foundation, but all it does is selling certifications nobody really needs... so, that cannot possibly be it. No big name doesn't really benefit from this in an obvious way...
So... anyways, when I hear people argue about how to implement this or another extension of Kubernetes, it rings the same as when people argue about styles of agile, or code readability etc. nonsense. There isn't a good way. There is not acceptance criteria. The whole system is flawed to no end.
Written by a co-worker to help manage our databricks projects across clusters. Works wonderfully!!
1. Write a provider/extension/whatever for a tool like Terraform or Pulumi. I live in a world where the infrastructure doesn't move underneath my feet. I am the source of truth. I feel like I only need to reconcile changes when I make changes to my IaC repositories.
2. I could write something that exists in a control plane, like Kubernetes operators or Crossplane. I live in a world where I look at the world, find the delta between current state and desired state, then try to reconcile. This is an endless loop.
I feel like these are different approaches with the same goal. Why should I decide either way beyond tossing a coin?
Some use cases:
- an internal enterprise DNS system which is not standards-compliant with the world at large
- an internal certificate authority and certificate issuing system.