Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add a user guide for using an Ansible Operator #559

Merged
merged 14 commits into from
Oct 8, 2018

Conversation

dymurray
Copy link
Contributor

@dymurray dymurray commented Oct 2, 2018

  • Sdk-cli-reference updates
  • Ansible Operator User Guide
  • Ansible Operator Project Layout
  • Include link to Ansible Operator user guide from top level user guide

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 2, 2018
@openshift-ci-robot
Copy link

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions 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.

@dymurray dymurray changed the title Add a user guide for using an Ansible Operator [WIP] Add a user guide for using an Ansible Operator Oct 2, 2018
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 2, 2018
Copy link

@leifmadsen leifmadsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/CR spec/CRD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually refers to the spec field on the Custom Resource. I will remove spec for simplicity.

doc/ansible/user-guide.md Show resolved Hide resolved

Once this is done, there are two ways to run the operator:

- As pod inside Kubernetes cluster

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run as a pod...


#### 1. Run as pod inside a Kubernetes cluster

Run as pod inside a Kubernetes cluster is preferred for production use.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running as a pod ...


#### 2. Run outside the cluster

This method is preferred during development cycle to deploy and test faster.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is preferred during the development cycle to speed up deployment and testing.

spec:
size: 4

$ kubectl apply -f deploy/cr.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use the kubectl patch command here to make things simpler I think?

Copy link
Contributor Author

@dymurray dymurray Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@shawn-hurley shawn-hurley added the language/ansible Issue is related to an Ansible operator project label Oct 2, 2018
@leifmadsen
Copy link

Depends on #486

@dymurray
Copy link
Contributor Author

dymurray commented Oct 3, 2018

Also depends on: #565

@dymurray dymurray changed the title [WIP] Add a user guide for using an Ansible Operator Add a user guide for using an Ansible Operator Oct 3, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 3, 2018
@dymurray dymurray changed the title Add a user guide for using an Ansible Operator docs: Add a user guide for using an Ansible Operator Oct 3, 2018
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dymurray
Copy link
Contributor Author

dymurray commented Oct 4, 2018

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.

@AlexNPavel
Copy link
Contributor

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.

@hasbro17
Copy link
Contributor

hasbro17 commented Oct 4, 2018

@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.
#522 (comment)
#525

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.

Copy link
Member

@mhrivnak mhrivnak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 V followed by appropriate up or down keys
  • hit gq to 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/cluster/the cluster/

@@ -2,6 +2,8 @@

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].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

@dymurray
Copy link
Contributor Author

dymurray commented Oct 5, 2018

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks.

@shawn-hurley shawn-hurley merged commit b5dbae5 into operator-framework:master Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/ansible Issue is related to an Ansible operator project needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants