-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Swapnil Bobade <[email protected]>
- Loading branch information
1 parent
850f7b0
commit 604086e
Showing
17 changed files
with
595 additions
and
4 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
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,11 @@ | ||
--- | ||
nmstate_enabled: false | ||
nmstate_install_operator: true | ||
nmstate_catalogsource_image: "" | ||
nmstate_upgrade_channel: "stable" | ||
nmstate_directory: "/tmp/nmstate" | ||
nmstate_golang_tarball: "https://go.dev/dl/go1.18.6.linux-ppc64le.tar.gz" | ||
nmstate_e2e: false | ||
nmstate_e2e_git_repository: "https://github.com/openshift/kubernetes-nmstate.git" | ||
nmstate_git_branch: "master" | ||
nmstate_cleanup: true |
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,5 @@ | ||
--- | ||
- name: Start cronjob | ||
hosts: bastion | ||
roles: | ||
- ocp-cronjob |
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: Installation of the NMState Operator and run e2e | ||
hosts: bastion | ||
tasks: | ||
- name: Deploy NMState Operator | ||
include_role: | ||
name: ocp-nmstate-operator |
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,66 @@ | ||
OCP Cronjob creation | ||
======================================= | ||
|
||
The role *"roles/ocp-cronjob"* provides automated creation of cronjobs. User can add cronjob value in the role variables for creation **Role Variables** section. | ||
This role will create the cronjob and we can monitor the jobs usig oc commands | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
- Running OCP 4.x cluster. | ||
|
||
|
||
Role Variables | ||
-------------- | ||
|
||
| Variable | Required | Default |Comments | | ||
|-------------------------------------|----------|---------------------------|---------------------------------------------------------------------------------------------------------------------------------| | ||
| enable_cronjob | no | false | Flag to be set to true to enable cronjob | | ||
| cronjob_schedule | no | * * * * * | schedule field for the job is specified in cron format. Here, the job run every minute | | ||
| cronjob_concurrencyPolicy | no | Allow | specifies how the job controller treats concurrent jobs within a cron job, values can be - ["Allow","forbid","replace"] | | ||
| cronjob_startingDeadlineSeconds | no | 200 | starting deadline specifies a deadline (in seconds) for starting the job | | ||
| cronjob_suspend | no | false | prevent subsequent runs of the cron job | | ||
| cronjob_successfulJobsHistoryLimit | no | 3 | store the successful jobs history limit | | ||
| cronjob_failedJobsHistoryLimit | no | 2 | store the failed jobs history limit | | ||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
|
||
|
||
Dependencies | ||
------------ | ||
|
||
- None | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
- name: Start cronjob | ||
hosts: bastion | ||
roles: | ||
- ocp-cronjob | ||
|
||
|
||
Steps to run playbook | ||
---------------------- | ||
|
||
- Copy the ocp4-playbooks-extras/examples/inventory to the home/working directory | ||
- To execute the playbook run the below sample command | ||
|
||
|
||
Sample Command | ||
--------------- | ||
|
||
ansible-playbook -i inventory -e @examples/all.yaml ~/ocp4-playbooks-extras/playbooks/ocp-cronjob.yml | ||
|
||
|
||
License | ||
------- | ||
|
||
See LICENCE.txt | ||
|
||
|
||
Author Information | ||
------------------ | ||
|
||
Swapnil Bobade ([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,15 @@ | ||
--- | ||
# defaults file for playbooks/roles/ocp-cronjob | ||
# all these values can be updated as needed | ||
container_name: "busybox" | ||
container_image: "busybox" | ||
cronjob_namespace: "openshift-cronjob" | ||
delete_cronjob: false | ||
job_name: "cronjob" | ||
enable_cronjob: false | ||
cronjob_schedule: "*/1 * * * *" | ||
cronjob_concurrencyPolicy: "Allow" | ||
cronjob_startingDeadlineSeconds: 200 | ||
cronjob_suspend: false | ||
cronjob_successfulJobsHistoryLimit: 4 | ||
cronjob_failedJobsHistoryLimit: 2 |
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,70 @@ | ||
--- | ||
# Creating namespace for cronjob | ||
- name: Create namespace for cronjob | ||
k8s: | ||
state: present | ||
definition: | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: "{{ cronjob_namespace }}" | ||
|
||
# create cronjobs | ||
- name: Create Cronjobs | ||
block: | ||
- name: Create Cronjob | ||
template: | ||
src: "{{ role_path }}/templates/cron-job.yml.j2" | ||
dest: "{{ role_path }}/files/cronjob.yml" | ||
|
||
- name: Apply the cronjob | ||
shell: oc apply -f "{{ role_path }}/files/cronjob.yml" | ||
|
||
- name: Check if pods are created | ||
shell: oc get pods -n {{ cronjob_namespace }} --no-headers | wc -l | ||
register: pod_count | ||
until: pod_count.stdout|int > 0 | ||
retries: 3 | ||
delay: 30 | ||
|
||
- name: Check pod status | ||
shell: oc wait -l parent=cronjobpi --for=condition=Ready pods | ||
register: pod_status | ||
|
||
- debug: | ||
msg: "{{ pod_status.stdout_lines }}" | ||
|
||
- name: Check if jobs are getting created | ||
shell: oc get jobs -n {{ cronjob_namespace }} --no-headers | wc -l | ||
register: job_count | ||
until: job_count.stdout|int > 0 | ||
retries: 3 | ||
delay: 30 | ||
|
||
- name: Check if jobs are running | ||
shell: oc get jobs -n {{ cronjob_namespace }} | ||
register: output_jobs | ||
|
||
- name: Check if pods are running | ||
shell: oc get pods -n {{ cronjob_namespace }} | grep "Completed\|Running" | ||
register: output_pods | ||
|
||
- name: Fail if pods are not getting created | ||
fail: | ||
msg: "Pods are not getting created !" | ||
when: pod_count.stdout|int == 0 | ||
|
||
- name: Fail if jobs are not getting created | ||
fail: | ||
msg: "Jobs are not getting created !" | ||
when: job_count.stdout|int == 0 | ||
|
||
- debug: | ||
msg: "{{ output_jobs.stdout_lines }}" | ||
|
||
- debug: | ||
msg: "{{ output_pods.stdout_lines }}" | ||
|
||
- name: Delete cronjob if requested | ||
shell: oc delete -f "{{ role_path }}/files/cronjob.yml" | ||
when: delete_cronjob |
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,29 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ job_name }} | ||
namespace: "{{ cronjob_namespace }}" | ||
spec: | ||
schedule: "{{ cronjob_schedule }}" | ||
concurrencyPolicy: "{{ cronjob_concurrencyPolicy }}" | ||
startingDeadlineSeconds: {{ cronjob_startingDeadlineSeconds }} | ||
suspend: {{ cronjob_suspend }} | ||
successfulJobsHistoryLimit: {{ cronjob_successfulJobsHistoryLimit }} | ||
failedJobsHistoryLimit: {{ cronjob_failedJobsHistoryLimit }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
parent: "cronjobpi" | ||
spec: | ||
containers: | ||
- name: {{ container_name }} | ||
image: {{ container_image }} | ||
{% if cronjob_concurrencyPolicy or cronjob_startingDeadlineSeconds %} | ||
command: ["sleep", "80"] | ||
{% else %} | ||
command: ["echo", "Hello Openshift !!"] | ||
{% endif %} | ||
restartPolicy: Never |
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,56 @@ | ||
ocp-nmstate-operator | ||
========= | ||
|
||
This role is used to deploy Kubernetes NMState Operator and run e2e tests. | ||
|
||
Requirements | ||
------------ | ||
|
||
- OCP 4.x healthy cluster on PowerVC. | ||
- To run e2e, attach two additional networks to the worker nodes. | ||
- OCP secret with name ***podman-secret*** in the default namespace which is used for global secret update and has following keys: | ||
***username***, ***password*** and ***registry*** | ||
|
||
Role Variables | ||
-------------- | ||
|
||
| Variable | Required | Default | Comments | | ||
|------------------------------|----------|----------------|-----------------------------------------------------------| | ||
| nmstate_enabled | no | false | Set it to true to run this playbook | | ||
| nmstate_install_operator | no | true | Set it to true to install the Kubernetes NMState Operator | | ||
| nmstate_catalogsource_image | no | "" | Custom catalog source index image for Kubernetes NMState Operator. If not defined, default `redhat-operators` catalog source will be used | | ||
| nmstate_upgrade_channel | no | stable | Operator upgrade channel | | ||
| nmstate_directory | no | `/tmp/nmstate` | Working directory for Kubernetes NMState Operator | | ||
| nmstate_golang_tarball | no | https://go.dev/dl/go1.18.6.linux-ppc64le.tar.gz | HTTPS URL for golang tarball | | ||
| nmstate_e2e | no | false | Set it to true to run e2e | | ||
| nmstate_e2e_git_repository | no | https://github.com/openshift/kubernetes-nmstate.git | Git respository for e2e tests | | ||
| nmstate_git_branch | no | master | Git branch for e2e | | ||
| nmstate_cleanup | no | true | Flag is used to clean Kubernetes NMState Operator resources | | ||
|
||
|
||
Dependencies | ||
------------ | ||
|
||
- None | ||
|
||
Example Playbook | ||
---------------- | ||
``` | ||
--- | ||
- name: Installation of the NMState Operator and run e2e | ||
hosts: bastion | ||
tasks: | ||
- name: Deploy NMState Operator | ||
include_role: | ||
name: ocp-nmstate-operator | ||
``` | ||
|
||
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,13 @@ | ||
--- | ||
# defaults file for playbooks/roles/ocp-nmstate-operator | ||
nmstate_enabled: false | ||
nmstate_install_operator: true | ||
nmstate_catalogsource_image: "" | ||
nmstate_catalogsource: "redhat-operators" | ||
nmstate_upgrade_channel: "stable" | ||
nmstate_directory: "/tmp/nmstate" | ||
nmstate_golang_tarball: "https://go.dev/dl/go1.18.6.linux-ppc64le.tar.gz" | ||
nmstate_e2e: false | ||
nmstate_e2e_git_repository: "https://github.com/openshift/kubernetes-nmstate.git" | ||
nmstate_git_branch: "master" | ||
nmstate_cleanup: true |
Oops, something went wrong.