-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Playbook for developing and testing sample helm, ansible and g…
…o based operator using operator-sdk Signed-off-by: SurajGudaji <[email protected]>
- Loading branch information
1 parent
a4886eb
commit b85bc7f
Showing
11 changed files
with
500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
op_api_role_enable: false | ||
helm_op: false | ||
ansible_op: false | ||
go_op: false | ||
op_cleanup: false | ||
OPERATOR_SDK_VERSION: "1.38.0" | ||
op_api_dir: "/tmp/operator-api" | ||
HELM_OP_IMAGE: "quay.io/{{quay_username}}/nginx-operator-helm:v1" | ||
ANSIBLE_OP_IMAGE: "quay.io/{{quay_username}}/memcached-operator-ansible:v1" | ||
GO_OP_IMAGE: "quay.io/{{quay_username}}/memcached-operator-go:v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: Validate Operator development and installation | ||
hosts: bastion | ||
tasks: | ||
- name: Validate Operator development and installation | ||
include_role: | ||
name: ocp-operator-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
ocp-operator-api | ||
========= | ||
|
||
This role is used to validate operator development using operator-sdk. | ||
|
||
Requirements | ||
------------ | ||
|
||
- OCP 4.x healthy cluster on Power. | ||
|
||
|
||
Role Variables | ||
-------------- | ||
|
||
| Variable | Required | Default | Comments | | ||
|--------------------------------------------|----------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | ||
| op_api_role_enable | no | false | Set it to true to run this playbook | | ||
| op_cleanup | no | false | Set it to true to do operator cleanup. | | ||
| helm_op | no | false | Set it to true to test helm based operator | | ||
| ansible_op | no | false | Set it to true to test ansible based operator | | ||
| go_op | no | false | Set it to true to test go based operator | | ||
| OPERATOR_SDK_VERSION | no | "1.38.0" | Version of operator-sdk to be installed. | | ||
| op_api_dir | no | "/tmp/operator-api" | Directory where the operator workspace are intialized. | | ||
| quay_username | yes | | quay account username where the operator images will be pushed | | ||
| quay_token | yes | | quay account token to push the operator images | | ||
|
||
|
||
|
||
|
||
Dependencies | ||
------------ | ||
|
||
- ansible-runner | ||
- ansible-runner-http | ||
- openshift | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
``` | ||
--- | ||
- name: Validate Operator development and installation | ||
hosts: bastion | ||
tasks: | ||
- name: Validate Operator development and installation | ||
include_role: | ||
name: ocp-operator-api | ||
``` | ||
|
||
|
||
License | ||
------- | ||
|
||
See LICENCE.txt | ||
|
||
Author Information | ||
------------------ | ||
|
||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
op_api_role_enable: false | ||
helm_op: false | ||
ansible_op: false | ||
go_op: false | ||
op_cleanup: false | ||
operator_sdk_version: "1.38.0" | ||
op_api_dir: "/tmp/operator-api" | ||
helm_op_image: "quay.io/{{quay_username}}/nginx-operator-helm:v1" | ||
ansible_op_image: "quay.io/{{quay_username}}/memcached-operator-ansible:v1" | ||
go_op_image: "quay.io/{{quay_username}}/memcached-operator-go:v1" |
24 changes: 24 additions & 0 deletions
24
playbooks/roles/ocp-operator-api/files/memcached-role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: start memcached | ||
k8s: | ||
definition: | ||
kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: '{{ ansible_operator_meta.name }}-memcached' | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
spec: | ||
replicas: "{{size}}" | ||
selector: | ||
matchLabels: | ||
app: memcached | ||
template: | ||
metadata: | ||
labels: | ||
app: memcached | ||
spec: | ||
containers: | ||
- name: memcached | ||
image: "docker.io/ppc64le/memcached" | ||
ports: | ||
- containerPort: 11211 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
|
||
- name: Cleanup | ||
block: | ||
- name: Delete Nginx instance | ||
command: oc delete -f "{{ op_api_dir }}/helm-op/config/samples/helm_v1_nginx.yaml" | ||
args: | ||
chdir: "{{ op_api_dir }}/helm-op" | ||
|
||
- name: Verify Nginx instance is deleted | ||
shell: oc get Nginx --no-headers | wc -l | ||
register: nginx_instance | ||
until: nginx_instance.stdout|int == 0 and nginx_instance.stderr == "No resources found in default namespace." | ||
retries: 10 | ||
delay: 10 | ||
|
||
- name: Nginx helm operator cleanup | ||
command: make undeploy IMG="{{ HELM_OP_IMAGE }}" | ||
args: | ||
chdir: "{{ op_api_dir }}/helm-op" | ||
|
||
- name: Delete Memcached instance | ||
command: oc delete -f "{{ op_api_dir }}/ansible-op/config/samples/cache_v1_memcached.yaml" | ||
args: | ||
chdir: "{{ op_api_dir }}/go-op" | ||
|
||
- name: Verify Memcached instance is deleted | ||
shell: oc get Memcached --no-headers | wc -l | ||
register: memcached_instance | ||
until: memcached_instance.stdout|int == 0 and memcached_instance.stderr == "No resources found in default namespace." | ||
retries: 10 | ||
delay: 10 | ||
|
||
- name: Memcached ansible operator cleanup | ||
command: make undeploy IMG="{{ ANSIBLE_OP_IMAGE }}" | ||
args: | ||
chdir: "{{ op_api_dir }}/ansible-op" | ||
|
||
- name: Delete MemcachedGo instance | ||
command: oc delete -f "{{ op_api_dir }}/go-op/config/samples/cache1_v1_memcachedgo.yaml" | ||
args: | ||
chdir: "{{ op_api_dir }}/go-op" | ||
|
||
- name: Verify Memcached instance is deleted | ||
shell: oc get MemcachedGo --no-headers | wc -l | ||
register: memcached_instance | ||
until: memcached_instance.stdout|int == 0 and memcached_instance.stderr == "No resources found in default namespace." | ||
retries: 10 | ||
delay: 10 | ||
|
||
- name: MemcachedGo operator cleanup | ||
command: make undeploy IMG="{{ GO_OP_IMAGE }}" | ||
args: | ||
chdir: "{{ op_api_dir }}/go-op" | ||
|
||
- name: Delete the workspace | ||
file: | ||
path: "{{ op_api_dir }}" | ||
state: "absent" | ||
when: op_cleanup |
Oops, something went wrong.