Skip to content

Commit 0f21612

Browse files
Merge pull request #124 from Jeevaann/new-log
Create IDMS/ICSP based on OCP version
2 parents 25f210a + 2ae3620 commit 0f21612

File tree

4 files changed

+98
-6
lines changed

4 files changed

+98
-6
lines changed

playbooks/roles/ocp-cluster-logging/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ Role Variables
7575
| cluster_log_forwarder | no | false | Flag to be set to true to forward logs to external third-party systems and to default internal Elasticsearch log store. Logs at external system will be cleaned up automatically. |
7676
| elastic_search_channel | yes | "" | It is used to set subscription channel for ElasticSearch |
7777
| cluster_logging_channel | yes | "" | It is used to set subscription channel for Cluster Logging |
78+
| loki_channel | yes | "" | It is used to set subscription channel for Loki |
7879
| elasticsearch_clf_cs | no | redhat-operators | It is used to set Index-Image of Elasticsearch in the CatalogSource |
7980
| clusterlogging_clf_cs | no | redhat-operators | It is used to set Index-Image of Cluster Logging in the CatalogSource |
81+
| loki_clf_cs | no | redhat-operators | It is used to set Index-Image of Loki operator in the CatalogSource |
8082
| log_label | no| test-clf | It is used to identify logs |
8183
| elasticsearch_url | no | "" | It is used to set URL of external ElasticSearch instance. It uses insecure connection(HTTP). |
8284
| syslog_url | no | "" | It is used to set URL of external Syslog instance. It uses secure connection (TLS). |
@@ -88,9 +90,10 @@ Role Variables
8890
| log_dir_path | no | */root/clf_logs* | Path on bastion node to save the fetched logs from external system.|
8991
| kibana_ldap_validation | no | false | Set it to true for validating Kibana as LDAP user |
9092
| log_collector_type | no | `fluentd` | Log collector type. It can be `fluentd` or `vector` |
91-
| clf_clean_up | no | false | It is used only for cleaning up Cluster Logging Operators, insatnces, Catalogsource, etc. from bastion. Playbook will skip remaining all other tasks.|
93+
| clf_clean_up | no | false | It is used only for cleaning up Cluster Logging Operators, instances, Catalogsource, etc. from bastion. Playbook will skip remaining all other tasks.|
9294

9395
#### Note:
96+
- The Elasticsearch is used as a default log store for Logging versions below 5.9. For logging versions greater than or equal to 5.9, Lokistack is used as a default log store.
9497
- To send logs to particular external systems set only URL/secret varibables for that external system.
9598
- For the internal Elasticsearch and external loki logs will not be deleted.
9699
- ClusterLogForwarder instance always forwards logs to the default internal ElasticSearch.
@@ -112,14 +115,17 @@ syslog_url: tls://rsyslogserver.east.example.com:514
112115
# To set Index images set variables as:
113116
elasticsearch_clf_cs: brew.registry.redhat.io/rh-osbs/iib:11111
114117
clusterlogging_clf_cs: brew.registry.redhat.io/rh-osbs/iib:11111
118+
loki_clf_cs: brew.registry.redhat.io/rh-osbs/iib:11111
115119

116120
# To use default Openshift CatalogSource:
117121
elasticsearch_clf_cs: ""
118122
clusterlogging_clf_cs: ""
123+
loki_clf_cs: ""
119124

120125
# To set channels for Elasticsearch and Cluster Logging
121-
elastic_search_channel: "5.0"
122-
cluster_logging_channel: "5.0"
126+
elastic_search_channel: "stable-5.9"
127+
cluster_logging_channel: "stable-5.9"
128+
loki_channel: "stable-5.9"
123129

124130
# To set URL of external Kafka instance
125131
kafka_url: tcp://{ip}:{port}

playbooks/roles/ocp-cluster-logging/files/clf-cleanup.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
shell: oc get ImageContentSourcePolicy | grep brew-registry | wc -l
1616
register: icsp_cnt
1717

18+
- name: Check if the ImageDigestMirrorSet exists
19+
shell: oc get ImageDigestMirrorSet | grep fbc-clo-testing-idms | wc -l
20+
register: idms
21+
1822
- name: Check if the CatalogSource exists
1923
shell: oc get CatalogSource -n openshift-marketplace | grep "cluster-logging\|elasticsearch\|loki" | awk 'NR==1{print $1}''NR==2{print $1}''NR==3{print $1}' | xargs
2024
register: catalog_src
@@ -23,6 +27,10 @@
2327
shell: oc delete ImageContentSourcePolicy brew-registry
2428
when: icsp_cnt.stdout|int == 1
2529

30+
- name: Delete ImageDigestMirrorSet if it exists
31+
shell: oc delete ImageDigestMirrorSet fbc-clo-testing-idms
32+
when: idms.stdout|int == 1
33+
2634
- name: Delete CatalogSource if it exists
2735
shell: oc delete CatalogSource -n openshift-marketplace {{ catalog_src.stdout }}
2836
when: catalog_src.stdout|length > 0

playbooks/roles/ocp-cluster-logging/tasks/main.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
- set_fact:
44
log_labels: "{{ log_label | default('test-clf', true) }}"
55
clo_version: "{{ cluster_logging_channel | regex_search('\\d+\\.\\d+') | float }}"
6+
logging_version: "{{ cluster_logging_channel.split('-')[1].replace('.', '-') }}"
7+
8+
9+
- name: Get the ocp server version
10+
shell: oc version | grep "Server Version" | awk '{print $3}' | cut -d . -f 1,2
11+
register: ocp_version
612

713
- name: Check channel variables
814
fail:
@@ -14,6 +20,7 @@
1420
# Set log directory
1521
- set_fact:
1622
cl_log_dir: "{{ log_dir_path | default('/root/clf_logs', true) }}"
23+
ocp_version: "{{ ocp_version.stdout }}"
1724

1825
# Validate external URLs and install python on external VMs
1926
- block:
@@ -36,7 +43,7 @@
3643
when: cluster_log_forwarder
3744

3845
# Custom ImageContentSourcePolicy and CatalogSource
39-
- name: Create ImageContentSourcePolicy and CatalogSource for CLO less than or equal to 5.8
46+
- name: Create ImageContentSourcePolicy and CatalogSource for CLO less than 5.9
4047
block:
4148
- name: Create CatalogSource
4249
template:
@@ -45,6 +52,16 @@
4552

4653
- name: Run ImageContentSourcePolicy
4754
shell: oc apply -f "{{ role_path }}/files/ImageContentSourcePolicy.yml"
55+
when: ocp_version | float < 4.13
56+
57+
- name: Create ImageDigestMirrorSet
58+
template:
59+
src: "{{ role_path }}/templates/idms.yaml.j2"
60+
dest: "{{ role_path }}/files/ImageDigestMirrorSet.yaml"
61+
62+
- name: Run ImageDigestMirrorSet
63+
include_tasks: "{{ role_path }}/files/ImageDigestMirrorSet.yaml"
64+
when: ocp_version | float >= 4.13
4865

4966
- name: Run CatalogSource
5067
shell: oc apply -f "{{ role_path }}/files/CatalogSource.yml"
@@ -65,9 +82,9 @@
6582
when:
6683
- elasticsearch_clf_cs != '' and clusterlogging_clf_cs != ''
6784
- elasticsearch_clf_cs != None and clusterlogging_clf_cs != None
68-
- clo_version | float <= 5.8
85+
- clo_version | float < 5.9
6986

70-
- name: Create ImageContentSourcePolicy and CatalogSource for CLO greater than 5.8
87+
- name: Create ImageContentSourcePolicy and CatalogSource for CLO greater than or equal to 5.9
7188
block:
7289
- name: Create CatalogSource
7390
template:
@@ -76,6 +93,16 @@
7693

7794
- name: Run ImageContentSourcePolicy
7895
shell: oc apply -f "{{ role_path }}/files/ImageContentSourcePolicy.yml"
96+
when: ocp_version | float < 4.13
97+
98+
- name: Create ImageDigestMirrorSet
99+
template:
100+
src: "{{ role_path }}/templates/idms.yaml.j2"
101+
dest: "{{ role_path }}/files/ImageDigestMirrorSet.yaml"
102+
103+
- name: Run ImageDigestMirrorSet
104+
include_tasks: "{{ role_path }}/files/ImageDigestMirrorSet.yaml"
105+
when: ocp_version | float >= 4.13
79106

80107
- name: Run CatalogSource
81108
shell: oc apply -f "{{ role_path }}/files/NewCatalogSource.yml"
@@ -105,6 +132,10 @@
105132
shell: oc get ImageContentSourcePolicy | grep brew-registry | wc -l
106133
register: icsp
107134

135+
- name: Check if the ImageDigestMirrorSet exists
136+
shell: oc get ImageDigestMirrorSet | grep fbc-clo-testing-idms | wc -l
137+
register: idms
138+
108139
- name: Check if the CatalogSource exists
109140
shell: oc get CatalogSource -n openshift-marketplace | grep "cluster-logging\|elasticsearch" |wc -l
110141
register: output
@@ -119,6 +150,10 @@
119150
shell: oc delete ImageContentSourcePolicy brew-registry
120151
when: icsp.stdout|int == 1
121152

153+
- name: Delete ImageDigestMirrorSet if it exists
154+
shell: oc delete ImageDigestMirrorSet fbc-clo-testing-idms
155+
when: idms.stdout|int == 1
156+
122157
- name: Delete CatalogSource if it exists
123158
shell: oc delete CatalogSource elasticsearch cluster-logging -n openshift-marketplace
124159
when:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
- name: Create ImageDigestMirrorSet
2+
k8s:
3+
state: present
4+
definition:
5+
apiVersion: config.openshift.io/v1
6+
kind: ImageDigestMirrorSet
7+
metadata:
8+
name: fbc-clo-testing-idms
9+
spec:
10+
imageDigestMirrors:
11+
- mirrors:
12+
- brew.registry.redhat.io
13+
source: registry-proxy.engineering.redhat.com
14+
- mirrors:
15+
- quay.io/redhat-user-workloads/obs-logging-tenant/loki-operator-bundle-v{{ logging_version }}
16+
source: registry.redhat.io/openshift-logging/loki-operator-bundle
17+
- mirrors:
18+
- quay.io/redhat-user-workloads/obs-logging-tenant/cluster-logging-operator-bundle-v{{ logging_version }}
19+
source: registry.redhat.io/openshift-logging/cluster-logging-operator-bundle
20+
- mirrors:
21+
- quay.io/redhat-user-workloads/obs-logging-tenant/cluster-logging-operator-v{{ logging_version }}
22+
source: registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator
23+
- mirrors:
24+
- quay.io/redhat-user-workloads/obs-logging-tenant/logging-vector-v{{ logging_version }}
25+
source: registry.redhat.io/openshift-logging/vector-rhel9
26+
- mirrors:
27+
- quay.io/redhat-user-workloads/obs-logging-tenant/log-file-metric-exporter-v{{ logging_version }}
28+
source: registry.redhat.io/openshift-logging/log-file-metric-exporter-rhel9
29+
- mirrors:
30+
- quay.io/redhat-user-workloads/obs-logging-tenant/logging-eventrouter-v{{ logging_version }}
31+
source: registry.redhat.io/openshift-logging/eventrouter-rhel9
32+
- mirrors:
33+
- quay.io/redhat-user-workloads/obs-logging-tenant/loki-operator-v{{ logging_version }}
34+
source: registry.redhat.io/openshift-logging/loki-rhel9-operator
35+
- mirrors:
36+
- quay.io/redhat-user-workloads/obs-logging-tenant/logging-loki-v{{ logging_version }}
37+
source: registry.redhat.io/openshift-logging/logging-loki-rhel9
38+
- mirrors:
39+
- quay.io/redhat-user-workloads/obs-logging-tenant/lokistack-gateway-v{{ logging_version }}
40+
source: registry.redhat.io/openshift-logging/lokistack-gateway-rhel9
41+
- mirrors:
42+
- quay.io/redhat-user-workloads/obs-logging-tenant/opa-openshift-v{{ logging_version }}
43+
source: registry.redhat.io/openshift-logging/opa-openshift-rhel9

0 commit comments

Comments
 (0)