Skip to content

Commit a2f2edd

Browse files
Shawn Hurleyhasbro17
authored andcommitted
doc/proposal: Ansible Operator proposal (#430)
* proposal: ansible operator proposal * Describes how the library packages of ansible operator will be layed out * New commands to manage ansible operators. * updating command to generate a "source" version of ansible operator. * Update ansible-operator.md Adds clarification about the `--source` command. * Changing proposal based on feedback from offline meeting. * adding project to the new command
1 parent b6c3c89 commit a2f2edd

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

doc/proposals/ansible-operator.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
## Ansible Operator Proposal
2+
3+
### Background
4+
5+
Not everyone is a golang developer, and therefore gaining adoption for the operator-sdk is capped by the number of golang developers. Also, tooling for kubernetes in other languages is lacking support for things such as informers, caches, and listers.
6+
7+
Operators purpose is to codify the operations of an application on kubernetes. [Ansible](https://www.ansible.com/) is already an industry standard tool for automation and is a good fit for the kind of work that kubernetes operators need to do. Adding the ability for users of the SDK to choose which between ansible and golang to follow will increase the number of potential users, and will grant existing users even more behavior.
8+
9+
### Goals
10+
11+
The goal of the Ansible Operator will be to create a fully functional framework for Ansible developers to create operators. It will also expose a library for golang users to use ansible in their operator if they so choose. These two goals in conjunction will allow users to select the best technology for their project or skillset.
12+
13+
### New Operator Type
14+
15+
This proposal creates a new type of operator called `ansible`. The new type is used to tell the tooling to act on that type of operator.
16+
17+
### Package Structure
18+
Packages will be added to the operator-sdk. These packages are designed to be usable by the end user if they choose to and should have a well documented public API. The proposed packages are:
19+
* /operator-sdk/pkg/ansible/controller
20+
* Will contain the ansible operator controller.
21+
* Will contain a exposed reconciler. But the default `Add` method will use this reconciler.
22+
* /operator-sdk/pkg/ansible/runner
23+
* Contains the runner types and interfaces
24+
* Implementation is behind an internal package (/operator-sdk/pkg/ansible/runner/internal)
25+
* New Methods are exposed and are the main way a user interacts with the package
26+
* Runner interface for running ansible from the operator.
27+
* NewForWatchers - the method that returns a map of GVK to Runner types based on the watchers file.
28+
* NewPlaybookRunner - the method that returns a new Runner for a playbook.
29+
* NewRoleRunner - the method that returns a new Runner for a role.
30+
* This contains the events API code and public methods. Implementation should probably be in the internal package. The events API is used for recieving events from ansible runner.
31+
32+
* /operator-sdk/pkg/ansible/proxy
33+
* This is a reverse proxy for the kubernetes API that is used for owner reference injection.
34+
* /operator-sdk/pkg/ansible/proxy/kubeconfig
35+
* Code needed to generate the kubeconfig for the proxy.
36+
* /operator-sdk/pkg/ansible/events
37+
* Package for event handlers from ansible runner events.
38+
* Default has only the event logger.
39+
40+
41+
### Commands
42+
We are adding and updating existing commands to accommodate the ansible operator. Changes to the `cmd` package as well as changes to the generator are needed.
43+
44+
`operator-sdk new <project-name> --type ansible --kind <kind> --api-version <group/version>` This will be a new generation command under the hood. We will:
45+
* Create a new ansible role in the roles directory
46+
* Create a new watchers file. The role and GVK are defaulted based on input to the command.
47+
* A CRD is generated. This CRD does not have any validations defined.
48+
* A dockerfile is created using the watchers file and the ansible role with the base image being the ansible operator base image.
49+
50+
The resulting structure should be
51+
```
52+
|- Dockerfile
53+
|
54+
|- roles
55+
\ | - <kind>
56+
| \ | - generated ansible role
57+
|
58+
| - watchers.yaml
59+
|
60+
| - deploy
61+
\ | - <kind>-CRD.yaml
62+
| | - rbac.yaml
63+
| | - operator.yaml
64+
| | - cr.yaml
65+
```
66+
67+
`operator-sdk generate crd <api-version> <kind> ` This will be used to generate new CRDs based on ansible code. The command helps when a user wants to watch more than one CRD for their operator.
68+
Args:
69+
Required kind - the kind for the object.
70+
Required api-version - the <group>/<version> for the CRD.
71+
Flags:
72+
Optional: --defaults-file - A path to the defaults file to use to generate a new CRD.yaml. If this is not defined, then an empty CRD is created.
73+
74+
`operator-sdk up local` - This should use the known structure and the ansible operator code to run the operator from this location. This will need to be changed to determine if it is an ansible operator or a golang operator. The command works by running the operator-sdk binary, which includes the ansible operator code, as the operator process. This is slightly different than the current up local command.
75+
76+
`operator-sdk build <image-name>` - This builds the operator image. This will need to be changed to determine if ansbile operator or golang operator.
77+
78+

0 commit comments

Comments
 (0)