mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
70 lines
2.7 KiB
Plaintext
70 lines
2.7 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * operators/operator_sdk/osdk-getting-started.adoc
|
|
|
|
[id="osdk-architecture_{context}"]
|
|
= Architecture of the Operator SDK
|
|
|
|
The link:https://coreos.com/operators/[Operator Framework] is an open source
|
|
toolkit to manage Kubernetes native applications, called _Operators_, in an
|
|
effective, automated, and scalable way. Operators take advantage of Kubernetes'
|
|
extensibility to deliver the automation advantages of cloud services like
|
|
provisioning, scaling, and backup and restore, while being able to run anywhere
|
|
that Kubernetes can run.
|
|
|
|
Operators make it easy to manage complex, stateful applications on top of
|
|
Kubernetes. However, writing an Operator today can be difficult because of
|
|
challenges such as using low-level APIs, writing boilerplate, and a lack of
|
|
modularity, which leads to duplication.
|
|
|
|
The Operator SDK is a framework designed to make writing Operators easier by
|
|
providing:
|
|
|
|
- High-level APIs and abstractions to write the operational logic more intuitively
|
|
- Tools for scaffolding and code generation to quickly bootstrap a new project
|
|
- Extensions to cover common Operator use cases
|
|
|
|
[id="osdk-architecture-workflow_{context}"]
|
|
== Workflow
|
|
|
|
The Operator SDK provides the following workflow to develop a new Operator:
|
|
|
|
. Create a new Operator project using the Operator SDK command line interface (CLI).
|
|
. Define new resource APIs by adding Custom Resource Definitions (CRDs).
|
|
. Specify resources to watch using the Operator SDK API.
|
|
. Define the Operator reconciling logic in a designated handler and use the Operator SDK API to interact with resources.
|
|
. Use the Operator SDK CLI to build and generate the Operator deployment manifests.
|
|
|
|
.Operator SDK workflow
|
|
image::osdk-workflow.png[]
|
|
|
|
At a high level, an Operator using the Operator SDK processes events for watched
|
|
resources in an Operator author-defined handler and takes actions to reconcile
|
|
the state of the application.
|
|
|
|
[id="osdk-architecture-manager_{context}"]
|
|
== Manager file
|
|
|
|
The main program for the Operator is the manager file at `cmd/manager/main.go`.
|
|
The manager automatically registers the scheme for all Custom Resources (CRs)
|
|
defined under `pkg/apis/` and runs all controllers under `pkg/controller/`.
|
|
|
|
The manager can restrict the namespace that all controllers watch for resources:
|
|
|
|
[source,go]
|
|
----
|
|
mgr, err := manager.New(cfg, manager.Options{Namespace: namespace})
|
|
----
|
|
|
|
By default, this is the namespace that the Operator is running in. To watch all
|
|
namespaces, you can leave the namespace option empty:
|
|
|
|
[source,go]
|
|
----
|
|
mgr, err := manager.New(cfg, manager.Options{Namespace: ""})
|
|
----
|
|
|
|
////
|
|
TODO: Doc on manager options(Sync period, leader election, registering 3rd party types)
|
|
////
|