https://coreos.com/blog/introducing-operators.html
concepts
- 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.
Stateless is Easy, Stateful is Hard
- A larger challenge is managing stateful applications, like databases, caches, and monitoring systems.
- These systems require application domain knowledge to correctly scale, upgrade, and reconfigure while protecting against data loss or unavailability.
- Operator manages multiple instances across the cluster.
- An Operator is software that encodes this domain knowledge and extends the Kubernetes API through the third party resources mechanism, enabling users to create, configure, and manage applications.
operator example
-
The etcd Operator creates, configures, and manages etcd clusters. etcd is a reliable, distributed key-value store introduced by CoreOS for sustaining the most critical data in a distributed system, and is the primary configuration datastore of Kubernetes itself.
-
The Prometheus Operator creates, configures, and manages Prometheus monitoring instances. Prometheus is a powerful monitoring, metrics, and alerting tool.
How is an Operator Built?
- when scaling an etcd cluster manually, a user has to perform a number of steps: create a DNS name for the new etcd member, launch the new etcd instance, and then use the etcd administrative tools (etcdctl member add) to tell the existing cluster about this new member. Instead with the etcd Operator a user can simply increase the etcd cluster size field by 1.
How can you create an Operator?
- the hard work is going to be encoding all of the application operational domain knowledge into a reasonable configuration resource and control loop.
- important points
- 部署简单
- 向后兼容
- operator被删除,operator对应的应用不受影响
- 版本升级
- 应对pod、配置、网络的错误
future of Operators
- We envision a future where users install Postgres Operators, Cassandra Operators, or Redis Operators on their Kubernetes clusters, and operate scalable instances of these programs as easily they deploy replicas of their stateless web applications today.
FAQ
StatefulSets
- “stateful resources” like static IPs and storage