docs: Add a user guide for using an Ansible Operator#559
Conversation
|
Hi @dymurray. Thanks for your PR. I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
leifmadsen
left a comment
There was a problem hiding this comment.
General comment: please wrap text to 80 chars
|
|
||
| ## Customize the operator logic | ||
|
|
||
| For this example the memcached-operator will execute the following reconciliation logic for each `Memcached` CR: |
There was a problem hiding this comment.
Could you call out CR fully? (custom resource?)
|
|
||
| For this example the memcached-operator will execute the following reconciliation logic for each `Memcached` CR: | ||
| - Create a memcached Deployment if it doesn't exist | ||
| - Ensure that the Deployment size is the same as specified by the `Memcached` CR spec |
There was a problem hiding this comment.
This actually refers to the spec field on the Custom Resource. I will remove spec for simplicity.
|
|
||
| Once this is done, there are two ways to run the operator: | ||
|
|
||
| - As pod inside Kubernetes cluster |
There was a problem hiding this comment.
As a pod inside a Kubernetes cluster
| Once this is done, there are two ways to run the operator: | ||
|
|
||
| - As pod inside Kubernetes cluster | ||
| - As go program outside cluster using `operator-sdk` |
There was a problem hiding this comment.
As a Go program outside the cluster...
| - As pod inside Kubernetes cluster | ||
| - As go program outside cluster using `operator-sdk` | ||
|
|
||
| #### 1. Run as pod inside a Kubernetes cluster |
|
|
||
| #### 1. Run as pod inside a Kubernetes cluster | ||
|
|
||
| Run as pod inside a Kubernetes cluster is preferred for production use. |
|
|
||
| #### 2. Run outside the cluster | ||
|
|
||
| This method is preferred during development cycle to deploy and test faster. |
There was a problem hiding this comment.
This method is preferred during the development cycle to speed up deployment and testing.
| spec: | ||
| size: 4 | ||
|
|
||
| $ kubectl apply -f deploy/cr.yaml |
There was a problem hiding this comment.
You could just use the kubectl patch command here to make things simpler I think?
There was a problem hiding this comment.
In the user-guide that is at the top-level they seem to suggest using apply. Any idea what the advantages using kubectl patch provides?
|
Depends on #486 |
|
Also depends on: #565 |
| Build the memcached-operator image and push it to a registry: | ||
| ``` | ||
| $ operator-sdk build quay.io/example/memcached-operator:v0.0.1 | ||
| $ sed -i 's|REPLACE_IMAGE|quay.io/example/memcached-operator:v0.0.1|g' deploy/operator.yaml |
There was a problem hiding this comment.
NIT @dymurray I was thinking it may be better if this step was done just before doing the kubectl create -f deploy/operator.yam below, with a short description of what and why it's being done.
|
I have no idea why Travis is failing... it can't be related to my documentation changes so must be transient. I'm unsure how to kick off a rebuild. |
|
Due to the way that travis and github handle merging for tests, there's currently an issue where if your branch is behind the master, that could cause the tests to fail (depending on what has changed). I merged a change to the test framework yesterday, so that's out of sync now. To fix this, rebase your branch to the latest master, or merge the latest master into your branch. |
|
@dymurray It's not related to your changes. Currently the e2e tests have to vendor the SDK from the contributor's PR branch so that any transitive dependencies from changing the core SDK pkgs are resolved by dep as well. This is a workaround for dep's inability to source from local repos. Since it's just doc changes we can technically disregard the CI but I think you should be able to rebase from the master as well. |
mhrivnak
left a comment
There was a problem hiding this comment.
I made some minor suggestions, but this looks great!
One other suggestion, that I think someone else already made: It's maybe a matter of preference, but I find it much easier to edit markdown that has a reasonably-limited line length. 80 characters is fine, especially since it's a default for vim. Speaking of, here's how I do the wrapping super-quickly:
- highlight several lines by hitting
Vfollowed by appropriate up or down keys - hit
gqto auto-wrap. Vim does a nice job of it, and it even handles inline code comments well.
|
|
||
| #### Options | ||
| **Role** | ||
| Specifying a `role` option in `watches.yaml` will configure the operator to use this specified path when launching `ansible-runner` with an Ansible Role. This is the default. |
There was a problem hiding this comment.
re: "This is the default", I think it would help to be more specific and say something like "By default, the new command will fill in an absolute path to where your role should go." That helps clarify that "default" does not imply that there is a default value in case role is left empty in this file.
|
|
||
| ``` | ||
|
|
||
| It is important to note that we used the `size` variable to control how many replicas of the Memcached deployment we want. We set the default to `1` but any user can create a Custom Resource which overwrites the default. |
There was a problem hiding this comment.
Add a comma before "but" since there are two independent clauses.
Also s/which/that/ since the ending clause is important to the meaning of the sentence.
| Once this is done, there are two ways to run the operator: | ||
|
|
||
| - As a pod inside a Kubernetes cluster | ||
| - As a go program outside cluster using `operator-sdk` |
|
|
||
| This guide walks through an example of building a simple memcached-operator using tools and libraries provided by the Operator SDK. | ||
|
|
||
| This guide covers the workflow of creating and deploying an operator written in Go. To read about the Ansible Operator, see the [Ansible Operator User Guide][ansible_user_guide]. |
There was a problem hiding this comment.
I would put the word "Ansible" as close as possible to the beginning of the paragraph for people who are visually scanning the document for this section and link. Also as we discussed earlier today, it might be better to avoid calling it the "Ansible Operator". Maybe:
"To learn how to use Ansible to create a memcached operator, see [Ansible Operator User Guide][ansible_user_guide]. The rest of this document will show how to program an operator in Go."
|
Thanks a lot for that information about Travis @hasbro17 and @AlexNPavel. And thank you for reviewing @mhrivnak that was great feedback. I had no idea about that autowrap feature in vim that is awesome! |
| - -o | ||
| - modern | ||
| - -v | ||
| image: "memcached:1.4.36-alpine" |
There was a problem hiding this comment.
Sorry, one more thing. This should be fully qualified so it will work with non-docker runtimes. I think just prefixing it with docker.io/ will work.
Uh oh!
There was an error while loading. Please reload this page.