Skip to content

Commit 70f4bb9

Browse files
committed
[deploy_loki] Adding CloudKitty role.
Introduce the deploy_loki Ansible role to install the Loki operator on OpenShift and create an S3-compatible secret in the OpenStack namespace for CloudKitty integration. Add the deploy-loki-for-ck hook playbook and register the role in Zuul molecule configuration. Signed-off-by: Leonid Natapov <lnatapov@redhat.com>
1 parent 50fcb7f commit 70f4bb9

7 files changed

Lines changed: 305 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Deploy Loki for CloudKitty
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4+
gather_facts: true
5+
tasks:
6+
- name: Deploy Loki operator and MinIO for CloudKitty
7+
ansible.builtin.import_role:
8+
name: deploy_loki
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for specific language governing permissions and limitations
15+
# under the License.
16+
17+
# All variables intended for modification should be placed in this file.
18+
# All variables within this role should have a prefix of "cifmw_deploy_loki"
19+
20+
cifmw_deploy_loki: true
21+
cifmw_deploy_loki_wait_for_csv: true
22+
cifmw_deploy_loki_base_dir: >-
23+
{{
24+
cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data')
25+
}}
26+
cifmw_deploy_loki_manifest_dest: >-
27+
{{
28+
[
29+
cifmw_deploy_loki_base_dir,
30+
'artifacts',
31+
'manifests',
32+
'deploy_loki_for_ck.yaml'
33+
] | path_join
34+
}}
35+
36+
cifmw_deploy_loki_operator_namespace: openshift-operators-redhat
37+
cifmw_deploy_loki_subscription_channel: stable-6.4
38+
cifmw_deploy_loki_subscription_name: loki-operator
39+
cifmw_deploy_loki_catalog_source: redhat-operators
40+
cifmw_deploy_loki_catalog_namespace: openshift-marketplace
41+
42+
cifmw_deploy_loki_minio_namespace: minio-dev
43+
cifmw_deploy_loki_minio_image: quay.io/minio/minio:latest
44+
cifmw_deploy_loki_minio_pvc_storage: 10Gi
45+
cifmw_deploy_loki_minio_storage_class: lvms-local-storage
46+
# If empty, OpenShift assigns hosts for the routes.
47+
cifmw_deploy_loki_minio_route_console_host: ""
48+
cifmw_deploy_loki_minio_route_api_host: ""
49+
50+
cifmw_deploy_loki_openstack_namespace: openstack
51+
cifmw_deploy_loki_s3_secret_name: cloudkitty-loki-s3
52+
cifmw_deploy_loki_s3_bucket: loki
53+
cifmw_deploy_loki_minio_access_key: minio
54+
cifmw_deploy_loki_minio_secret_key: minio123
55+
56+
cifmw_deploy_loki_csv_wait_retries: 30
57+
cifmw_deploy_loki_csv_wait_delay: 10

roles/deploy_loki/meta/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for specific language governing permissions and limitations
15+
# under the License.
16+
17+
galaxy_info:
18+
author: CI Framework
19+
description: CI Framework Role -- deploy Loki operator and MinIO for CloudKitty
20+
company: Red Hat
21+
license: Apache-2.0
22+
min_ansible_version: "2.14"
23+
namespace: cifmw
24+
galaxy_tags:
25+
- cifmw
26+
27+
dependencies: []

roles/deploy_loki/tasks/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Ensure manifest output directory exists
18+
ansible.builtin.file:
19+
path: "{{ cifmw_deploy_loki_manifest_dest | dirname }}"
20+
state: directory
21+
mode: "0755"
22+
23+
- name: Render Loki / MinIO manifests for CloudKitty
24+
ansible.builtin.template:
25+
src: deploy_loki_for_ck.yaml.j2
26+
dest: "{{ cifmw_deploy_loki_manifest_dest }}"
27+
mode: "0644"
28+
29+
- name: Apply Loki operator and MinIO manifests
30+
when: cifmw_deploy_loki | bool
31+
environment:
32+
KUBECONFIG: >-
33+
{{
34+
cifmw_openshift_kubeconfig |
35+
default(ansible_env.HOME + '/.kube/config')
36+
}}
37+
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}"
38+
ansible.builtin.command:
39+
cmd: "oc apply -f {{ cifmw_deploy_loki_manifest_dest }}"
40+
register: cifmw_deploy_loki_apply_result
41+
changed_when: >-
42+
('stdout' in cifmw_deploy_loki_apply_result) and
43+
('unchanged' not in cifmw_deploy_loki_apply_result.stdout)
44+
45+
- name: Wait until Loki operator CSV reports Succeeded
46+
when:
47+
- cifmw_deploy_loki | bool
48+
- cifmw_deploy_loki_wait_for_csv | bool
49+
environment:
50+
KUBECONFIG: >-
51+
{{
52+
cifmw_openshift_kubeconfig |
53+
default(ansible_env.HOME + '/.kube/config')
54+
}}
55+
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}"
56+
ansible.builtin.shell:
57+
cmd: >-
58+
oc get csv -n {{ cifmw_deploy_loki_operator_namespace }}
59+
--no-headers=true | grep {{ cifmw_deploy_loki_subscription_name }}
60+
register: cifmw_deploy_loki_csv_out
61+
ignore_errors: true
62+
until: >-
63+
(cifmw_deploy_loki_csv_out.stdout_lines | length == 1) and
64+
('Succeeded' in cifmw_deploy_loki_csv_out.stdout)
65+
retries: "{{ cifmw_deploy_loki_csv_wait_retries }}"
66+
delay: "{{ cifmw_deploy_loki_csv_wait_delay }}"
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: {{ cifmw_deploy_loki_operator_namespace }}
6+
labels:
7+
name: {{ cifmw_deploy_loki_operator_namespace }}
8+
---
9+
apiVersion: operators.coreos.com/v1
10+
kind: OperatorGroup
11+
metadata:
12+
name: {{ cifmw_deploy_loki_subscription_name }}
13+
namespace: {{ cifmw_deploy_loki_operator_namespace }}
14+
spec:
15+
upgradeStrategy: Default
16+
---
17+
apiVersion: operators.coreos.com/v1alpha1
18+
kind: Subscription
19+
metadata:
20+
name: {{ cifmw_deploy_loki_subscription_name }}
21+
namespace: {{ cifmw_deploy_loki_operator_namespace }}
22+
spec:
23+
channel: {{ cifmw_deploy_loki_subscription_channel }}
24+
name: {{ cifmw_deploy_loki_subscription_name }}
25+
source: {{ cifmw_deploy_loki_catalog_source }}
26+
sourceNamespace: {{ cifmw_deploy_loki_catalog_namespace }}
27+
---
28+
apiVersion: v1
29+
kind: Namespace
30+
metadata:
31+
name: {{ cifmw_deploy_loki_minio_namespace }}
32+
labels:
33+
name: {{ cifmw_deploy_loki_minio_namespace }}
34+
---
35+
apiVersion: v1
36+
kind: Pod
37+
metadata:
38+
labels:
39+
app: minio
40+
name: minio
41+
namespace: {{ cifmw_deploy_loki_minio_namespace }}
42+
spec:
43+
containers:
44+
- name: minio
45+
image: {{ cifmw_deploy_loki_minio_image }}
46+
command:
47+
- /bin/bash
48+
- -c
49+
- |
50+
mkdir -p /data/loki && \
51+
minio server /data
52+
env:
53+
- name: MINIO_ACCESS_KEY
54+
value: "{{ cifmw_deploy_loki_minio_access_key }}"
55+
- name: MINIO_SECRET_KEY
56+
value: "{{ cifmw_deploy_loki_minio_secret_key }}"
57+
volumeMounts:
58+
- mountPath: /data
59+
name: storage
60+
volumes:
61+
- name: storage
62+
persistentVolumeClaim:
63+
claimName: minio-pvc
64+
---
65+
apiVersion: v1
66+
kind: PersistentVolumeClaim
67+
metadata:
68+
name: minio-pvc
69+
namespace: {{ cifmw_deploy_loki_minio_namespace }}
70+
spec:
71+
accessModes:
72+
- ReadWriteOnce
73+
resources:
74+
requests:
75+
storage: {{ cifmw_deploy_loki_minio_pvc_storage }}
76+
storageClassName: {{ cifmw_deploy_loki_minio_storage_class }}
77+
---
78+
apiVersion: v1
79+
kind: Service
80+
metadata:
81+
name: minio
82+
namespace: {{ cifmw_deploy_loki_minio_namespace }}
83+
spec:
84+
selector:
85+
app: minio
86+
ports:
87+
- name: api
88+
protocol: TCP
89+
port: 9000
90+
- name: console
91+
protocol: TCP
92+
port: 9090
93+
---
94+
kind: Route
95+
apiVersion: route.openshift.io/v1
96+
metadata:
97+
name: minio-console
98+
namespace: {{ cifmw_deploy_loki_minio_namespace }}
99+
spec:
100+
{% if cifmw_deploy_loki_minio_route_console_host | length > 0 %}
101+
host: {{ cifmw_deploy_loki_minio_route_console_host }}
102+
{% endif %}
103+
to:
104+
kind: Service
105+
name: minio
106+
weight: 100
107+
port:
108+
targetPort: console
109+
wildcardPolicy: None
110+
---
111+
kind: Route
112+
apiVersion: route.openshift.io/v1
113+
metadata:
114+
name: minio-api
115+
namespace: {{ cifmw_deploy_loki_minio_namespace }}
116+
spec:
117+
{% if cifmw_deploy_loki_minio_route_api_host | length > 0 %}
118+
host: {{ cifmw_deploy_loki_minio_route_api_host }}
119+
{% endif %}
120+
to:
121+
kind: Service
122+
name: minio
123+
weight: 100
124+
port:
125+
targetPort: api
126+
wildcardPolicy: None
127+
---
128+
apiVersion: v1
129+
kind: Secret
130+
metadata:
131+
name: {{ cifmw_deploy_loki_s3_secret_name }}
132+
namespace: {{ cifmw_deploy_loki_openstack_namespace }}
133+
stringData:
134+
access_key_id: "{{ cifmw_deploy_loki_minio_access_key }}"
135+
access_key_secret: "{{ cifmw_deploy_loki_minio_secret_key }}"
136+
bucketnames: "{{ cifmw_deploy_loki_s3_bucket }}"
137+
endpoint: "http://minio.{{ cifmw_deploy_loki_minio_namespace }}.svc.cluster.local:9000"

zuul.d/molecule.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,15 @@
927927
- ^.config/molecule/.*
928928
name: cifmw-molecule-cleanup_openstack
929929
parent: cifmw-molecule-noop
930+
- job:
931+
files:
932+
- ^common-requirements.txt
933+
- ^test-requirements.txt
934+
- ^roles/deploy_loki/.*
935+
- ^ci/playbooks/molecule.*
936+
- ^.config/molecule/.*
937+
name: cifmw-molecule-deploy_loki
938+
parent: cifmw-molecule-noop
930939
- job:
931940
files:
932941
- ^common-requirements.txt

zuul.d/projects.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- cifmw-molecule-config_drive
4343
- cifmw-molecule-copy_container
4444
- cifmw-molecule-deploy_bmh
45+
- cifmw-molecule-deploy_loki
4546
- cifmw-molecule-devscripts
4647
- cifmw-molecule-discover_latest_image
4748
- cifmw-molecule-dlrn_promote

0 commit comments

Comments
 (0)