-
Notifications
You must be signed in to change notification settings - Fork 28
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: Pavan Sadhana <[email protected]>
- Loading branch information
1 parent
7cd310f
commit c802d9c
Showing
11 changed files
with
613 additions
and
1 deletion.
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,16 @@ | ||
--- | ||
# ocp-cmo vars | ||
cost_management_enabled: false | ||
cost_management_directory: "/tmp/compliance" | ||
cost_management_catalogsource_image: "" # "brew.registry.redhat.io/rh-osbs/iib:327237" | ||
cost_management_upgrade_channel: "stable" | ||
cost_management_e2e: false | ||
cost_management_e2e_github_repo: "" | ||
cost_management_e2e_github_branch: "" | ||
cost_management_github_username: "" | ||
cost_management_github_token: "" | ||
cost_management_cleanup: true | ||
cost_management_setup: false | ||
cost_management_test: false | ||
openshift_console_password: "" | ||
|
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 Compliance Operator and run e2e | ||
hosts: bastion | ||
tasks: | ||
- name: Deploy Cost Management Operator | ||
include_role: | ||
name: ocp-cost-management |
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,103 @@ | ||
ocp-cost-management-operator | ||
========= | ||
|
||
This role is used to deploy Cost Management Operator. | ||
|
||
Requirements | ||
------------ | ||
|
||
- OCP 4.x healthy cluster on PowerVS. | ||
- Need to connect to Sgnvpn and Redhat VPN on your machine. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
| Variable | Required | Default | Comments | | ||
|--------------------------------------------|----------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | ||
| cost_management_enabled | yes | false | | | ||
| cost_management_directory | yes | /tmp/compliance | cost management temporary directory | | ||
| cost_management_catalogsource_image | yes | "" | index image build id | | ||
| cost_management_upgrade_channel | no | stable | channel | | ||
| cost_management_e2e | yes | false | | | ||
| cost_management_e2e_github_repo | yes |"" | | | ||
| cost_management_e2e_github_branch | yes |master | | | | ||
| cost_management_github_username | yes |"" | | | ||
| cost_management_github_token | yes |"" | | | ||
| cost_management_cleanup | yes | true | to run cleanup playbook | | ||
| cost_management_setup | yes | false | to run cost management setup | | ||
| cost_management_test | yes | false | to run cost management test | | ||
| openshift_console_password | yes | "" | oc login command password | | ||
|
||
|
||
Dependencies | ||
------------ | ||
|
||
- None | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
``` | ||
--- | ||
- name: Installation of the cost management operator and run e2e | ||
hosts: bastion | ||
roles: | ||
- ocp-cost-management | ||
``` | ||
|
||
Execution process | ||
----------------- | ||
|
||
there are 4 playbooks available on tasks folder | ||
- main.yml | ||
- cmo-setup.yml | ||
- cmo-test.yml | ||
- cmo-cleanup.yml | ||
|
||
**var filepath:** | ||
examples/ocp_cost_management_vars.yaml | ||
|
||
**main.yml** | ||
This is the main yaml file which is used to install,verify and validate cost managemenent operator. | ||
|
||
**cmo-setup.yml** | ||
This file is responsible for install iqe cost management plugin and dependencies on your machine, | ||
inorder to execute this we have to enable the cost_management_setup in var file. | ||
`cost_management_setup: true` | ||
|
||
**cmo-test.yml** | ||
After plugin installation is successful,we have to execute this file to run tests. | ||
inorder to execute this we have to enable the cost_management_test in var file. | ||
`cost_management_test: true` | ||
Also we have to pass the kubeadmin password to this variable `openshift_console_password` in var file. | ||
|
||
**cmo-cleanup.yml** | ||
This file is use to cleanup all resources involved with this operator. | ||
inorder to execute this we have to enable the cost_management_cleanup in var file. | ||
`cost_management_cleanup: true` | ||
|
||
Run Playbook | ||
------------ | ||
|
||
To set up variables for specific playbook make use of the sample file at examples/<playbook_vars.yaml>. Modify the values as per your cluster. For more information refer to examples. | ||
|
||
``` | ||
cp examples/ocp_cost_management_vars.yaml | ||
``` | ||
Once you have configured the vars & inventory file, run the specific playbook using: | ||
|
||
``` | ||
ansible-playbook -i inventory -e @ocp_cost_management_vars.yaml playbooks/main.yml | ||
``` | ||
|
||
|
||
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,15 @@ | ||
--- | ||
# defaults file for playbooks/roles/ocp-cost-management | ||
cost_management_enabled: false | ||
cost_management_directory: "/tmp/costmanagement" | ||
cost_management_catalogsource_image: "" # "brew.registry.redhat.io/rh-osbs/iib:327237" | ||
cost_management_upgrade_channel: "stable" | ||
cost_management_e2e: false | ||
cost_management_e2e_github_repo: "" | ||
cost_management_e2e_github_branch: "master" | ||
cost_management_github_username: "" | ||
cost_management_github_token: "" | ||
cost_management_cleanup: true | ||
cost_management_setup: false | ||
cost_management_test: false | ||
openshift_console_password: "" |
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,16 @@ | ||
re_run_count=0 | ||
max_re_runs=1 | ||
echo -e "\ne2e summary:" > $COST_MANAGEMENT_WORKDIR/e2e-summary.txt | ||
cat "${COST_MANAGEMENT_WORKDIR}/e2e-output.txt" | tail -n 1 >> $COST_MANAGEMENT_WORKDIR/e2e-summary.txt | ||
sed -e 's/\"/\\"/g;s/.*/\"&\"/' "${COST_MANAGEMENT_WORKDIR}/e2e-output.txt" | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -2 > $COST_MANAGEMENT_WORKDIR/failed_tests.txt | ||
while [ $re_run_count -lt $max_re_runs ] && [ "0" -ne "$(wc -l < "${COST_MANAGEMENT_WORKDIR}/failed_tests.txt")" ] | ||
do | ||
re_run_count=$(( $re_run_count + 1 )) | ||
./bin/extended-platform-tests run -f $COST_MANAGEMENT_WORKDIR/failed_tests.txt -o $COST_MANAGEMENT_WORKDIR/e2e-re-run-output-${re_run_count}.txt | ||
sed -e 's/\"/\\"/g;s/.*/\"&\"/' "${COST_MANAGEMENT_WORKDIR}/e2e-re-run-output-${re_run_count}.txt" | awk '/Failing tests:/,EOF' | tail -n +3 | head -n -2 > $COST_MANAGEMENT_WORKDIR/failed_tests.txt | ||
done | ||
if [ $re_run_count -ne 0 ]; then | ||
echo -e "\n\ne2e summary after re-running:" >> $COST_MANAGEMENT_WORKDIR/e2e-summary.txt | ||
cat $COST_MANAGEMENT_WORKDIR/failed_tests.txt >> $COST_MANAGEMENT_WORKDIR/e2e-summary.txt | ||
cat "${COST_MANAGEMENT_WORKDIR}/e2e-re-run-output-${re_run_count}.txt" | tail -n 2 >> $COST_MANAGEMENT_WORKDIR/e2e-summary.txt | ||
fi |
141 changes: 141 additions & 0 deletions
141
playbooks/roles/ocp-cost-management/tasks/cmo-cleanup.yml
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,141 @@ | ||
--- | ||
# this file is used for cleaning up the compliance operator resources | ||
|
||
- name: Check if ScanSettingBinding exists | ||
shell: oc get ScanSettingBinding -n costmanagement-metrics-operator --no-headers | awk '{print $1}' | ||
register: scan_setting_binding | ||
|
||
- name: Delete the ScanSettingBinding if exists | ||
kubernetes.core.k8s: | ||
api_version: compliance.openshift.io/v1alpha1 | ||
state: absent | ||
kind: ScanSettingBinding | ||
name: "{{ item }}" | ||
namespace: costmanagement-metrics-operator | ||
loop: "{{ scan_setting_binding.stdout_lines }}" | ||
when: scan_setting_binding.stdout_lines|length > 0 | ||
|
||
- name: Check if ScanSetting exists | ||
shell: oc get ScanSetting -n costmanagement-metrics-operator --no-headers | awk '{print $1}' | ||
register: scan_setting | ||
|
||
- name: Delete the ScanSetting if exists | ||
kubernetes.core.k8s: | ||
api_version: compliance.openshift.io/v1alpha1 | ||
state: absent | ||
kind: ScanSetting | ||
name: "{{ item }}" | ||
namespace: costmanagement-metrics-operator | ||
loop: "{{ scan_setting.stdout_lines }}" | ||
when: scan_setting.stdout_lines|length > 0 | ||
|
||
- name: Check if ComplianceSuite exists | ||
shell: oc get ComplianceSuite -n costmanagement-metrics-operator --no-headers | awk '{print $1}' | ||
register: compliance_suite | ||
|
||
- name: Delete the ComplianceSuite if exists | ||
kubernetes.core.k8s: | ||
api_version: compliance.openshift.io/v1alpha1 | ||
state: absent | ||
kind: ComplianceSuite | ||
name: "{{ item }}" | ||
namespace: costmanagement-metrics-operator | ||
loop: "{{ compliance_suite.stdout_lines }}" | ||
when: compliance_suite.stdout_lines|length > 0 | ||
|
||
- name: Get the name of cluster service version for Compliance Operator | ||
shell: oc get csv -n costmanagement-metrics-operator --no-headers | awk '{ if ($1 ~ /^compliance-operator/) print $1 }' | ||
register: compliance_csv | ||
|
||
- name: Delete the profile bundle if exists | ||
kubernetes.core.k8s: | ||
api_version: compliance.openshift.io/v1alpha1 | ||
state: absent | ||
kind: ProfileBundle | ||
name: "{{ item }}" | ||
namespace: costmanagement-metrics-operator | ||
loop: | ||
- "ocp4" | ||
- "rhcos4" | ||
when: compliance_csv.stdout|length > 0 | ||
|
||
- name: Get the subscription name | ||
shell: oc get subscription -n costmanagement-metrics-operator --no-headers | awk '{print $1}' | ||
register: compliance_subscription | ||
|
||
- name: Delete the subscription if exists | ||
kubernetes.core.k8s: | ||
api_version: operators.coreos.com/v1alpha1 | ||
state: absent | ||
kind: Subscription | ||
name: "{{ compliance_subscription.stdout }}" | ||
namespace: costmanagement-metrics-operator | ||
when: compliance_subscription.stdout|length > 0 | ||
|
||
- name: Get the operator group name | ||
shell: oc get operatorgroup -n costmanagement-metrics-operator --no-headers | awk '{print $1}' | ||
register: compliance_operator_group | ||
|
||
- name: Delete the operator group if exists | ||
kubernetes.core.k8s: | ||
api_version: operators.coreos.com/v1 | ||
state: absent | ||
kind: OperatorGroup | ||
name: "{{ compliance_operator_group.stdout }}" | ||
namespace: costmanagement-metrics-operator | ||
when: compliance_operator_group.stdout|length > 0 | ||
|
||
- name: Delete the cluster service version if exists | ||
kubernetes.core.k8s: | ||
api_version: operators.coreos.com/v1alpha1 | ||
state: absent | ||
kind: ClusterServiceVersion | ||
name: "{{ compliance_csv.stdout }}" | ||
namespace: costmanagement-metrics-operator | ||
when: compliance_csv.stdout|length > 0 | ||
|
||
- name: Check if all the pods has been deleted | ||
shell: oc get pods -n costmanagement-metrics-operator --no-headers | ||
register: compliance_pods | ||
until: compliance_pods.stdout|int == 0 | ||
retries: 15 | ||
delay: 60 | ||
|
||
- name: Get custom resource definitions | ||
shell: oc get crd | awk '{print $1}'| grep compliance | ||
register: compliance_crds | ||
ignore_errors: true | ||
|
||
- name: Delete the custom resource definition if exists | ||
shell: oc delete crd {{ item }} | ||
loop: "{{ compliance_crds.stdout_lines }}" | ||
when: compliance_crds.stdout_lines|length > 0 | ||
|
||
- name: Check if all the custom resource definitions has been deleted | ||
shell: oc get crd | awk '{print $1}'| grep compliance | ||
register: compliance_crds | ||
failed_when: compliance_crds.stdout_lines|length != 0 | ||
|
||
- name: Delete the Cost Management Operator if exists | ||
kubernetes.core.k8s: | ||
state: absent | ||
kind: Operator | ||
name: cost-management-operator.costmanagement-metrics-operator | ||
|
||
- name: Delete the namespace if exists | ||
kubernetes.core.k8s: | ||
state: absent | ||
kind: Namespace | ||
name: costmanagement-metrics-operator | ||
|
||
- name: Check if the namespace gets deleted | ||
shell: oc get namespace --no-headers | grep compliance | wc -l | ||
register: compliance_namespace | ||
until: compliance_namespace.stdout|int == 0 | ||
retries: 15 | ||
delay: 30 | ||
|
||
- name: Delete the workplace | ||
file: | ||
state: absent | ||
path: "{{ cost_management_directory }}" |
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 @@ | ||
--- | ||
- name: Setup and Test Cost Management Metrics Operator | ||
tasks: | ||
- name: Create workspace directory | ||
file: | ||
path: "~/iqe-workspace-dev" | ||
state: directory | ||
|
||
- name: Clone IQE Core repository | ||
git: | ||
repo: "[email protected]:insights-qe/iqe-core.git" | ||
dest: "~/iqe-workspace-dev/iqe-core" | ||
|
||
- name: Create Python virtual environment | ||
command: python3 -m venv .iqe-venv | ||
args: | ||
chdir: "~/iqe-workspace-dev/iqe-core" | ||
|
||
- name: Activate virtual environment and install dependencies | ||
shell: | | ||
source .iqe-venv/bin/activate | ||
pip install -U pip setuptools wheel | ||
args: | ||
chdir: "~/iqe-workspace-dev/iqe-core" | ||
|
||
- name: Set PIP global index URL | ||
shell: | | ||
pip config set global.index-url https://repository.engineering.redhat.com/nexus/repository/insights-qe/simple --site | ||
pip config set global.index https://repository.engineering.redhat.com/nexus/repository/insights-qe-search/pypi --site | ||
args: | ||
chdir: "~/iqe-workspace-dev/iqe-core" | ||
|
||
- name: Install IQE core with constraints | ||
shell: | | ||
source .iqe-venv/bin/activate | ||
pip install -e . -c iqe/data/all_external_constraints.linux.python3.11.txt | ||
args: | ||
chdir: "~/iqe-workspace-dev/iqe-core" | ||
|
||
- name: Create plugin directory | ||
file: | ||
path: "~/iqe-workspace-dev/iqe-cost-management-plugin" | ||
state: directory | ||
|
||
- name: Check if IQE Cost Management Plugin is already cloned | ||
stat: | ||
path: ~/iqe-workspace-dev/iqe-cost-management-plugin/.git | ||
register: git_repo | ||
|
||
- name: Clone IQE Cost Management Plugin with SSL verification disabled | ||
shell: git -c http.sslVerify=false clone https://gitlab.cee.redhat.com/insights-qe/iqe-cost-management-plugin ~/iqe-workspace-dev/iqe-cost-management-plugin | ||
when: not git_repo.stat.exists | ||
|
||
- name: Install IQE Cost Management Plugin | ||
shell: | | ||
source .iqe-venv/bin/activate | ||
iqe plugin install --editable . | ||
args: | ||
chdir: "~/iqe-workspace-dev/iqe-cost-management-plugin" |
Oops, something went wrong.