-
Notifications
You must be signed in to change notification settings - Fork 149
Adding Loki deployment role #3790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lnatapov
wants to merge
1
commit into
openstack-k8s-operators:main
Choose a base branch
from
lnatapov:Addin_ck_deployment_files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+308
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| --- | ||
| - name: Deploy Loki for CloudKitty | ||
| hosts: "{{ cifmw_target_hook_host | default('localhost') }}" | ||
| gather_facts: true | ||
| environment: | ||
| KUBECONFIG: "{{ cifmw_openshift_kubeconfig | default(ansible_env.HOME + '/.kube/config') }}" | ||
| PATH: "{{ cifmw_path | default(ansible_env.PATH) }}" | ||
| tasks: | ||
| - name: Deploy Loki operator and MinIO for CloudKitty | ||
| ansible.builtin.import_role: | ||
| name: deploy_loki |
This file contains hidden or 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,57 @@ | ||
| --- | ||
| # Copyright Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # All variables intended for modification should be placed in this file. | ||
| # All variables within this role should have a prefix of "cifmw_deploy_loki" | ||
|
|
||
| cifmw_deploy_loki: true | ||
| cifmw_deploy_loki_wait_for_csv: true | ||
| cifmw_deploy_loki_base_dir: >- | ||
| {{ | ||
| cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') | ||
| }} | ||
| cifmw_deploy_loki_manifest_dest: >- | ||
| {{ | ||
| [ | ||
| cifmw_deploy_loki_base_dir, | ||
| 'artifacts', | ||
| 'manifests', | ||
| 'deploy_loki_for_ck.yaml' | ||
| ] | path_join | ||
| }} | ||
|
|
||
| cifmw_deploy_loki_operator_namespace: openshift-operators-redhat | ||
| cifmw_deploy_loki_subscription_channel: stable-6.4 | ||
| cifmw_deploy_loki_subscription_name: loki-operator | ||
| cifmw_deploy_loki_catalog_source: redhat-operators | ||
| cifmw_deploy_loki_catalog_namespace: openshift-marketplace | ||
|
|
||
| cifmw_deploy_loki_minio_namespace: minio-dev | ||
| cifmw_deploy_loki_minio_image: quay.io/minio/minio:latest | ||
| cifmw_deploy_loki_minio_pvc_storage: 10Gi | ||
| cifmw_deploy_loki_minio_storage_class: lvms-local-storage | ||
| # If empty, OpenShift assigns hosts for the routes. | ||
| cifmw_deploy_loki_minio_route_console_host: "" | ||
| cifmw_deploy_loki_minio_route_api_host: "" | ||
|
|
||
| cifmw_deploy_loki_openstack_namespace: openstack | ||
| cifmw_deploy_loki_s3_secret_name: cloudkitty-loki-s3 | ||
| cifmw_deploy_loki_s3_bucket: loki | ||
| cifmw_deploy_loki_minio_access_key: minio | ||
| cifmw_deploy_loki_minio_secret_key: minio123 | ||
|
|
||
| cifmw_deploy_loki_csv_wait_retries: 30 | ||
| cifmw_deploy_loki_csv_wait_delay: 10 |
This file contains hidden or 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,27 @@ | ||
| --- | ||
| # Copyright Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| galaxy_info: | ||
| author: CI Framework | ||
| description: CI Framework Role -- deploy Loki operator and MinIO for CloudKitty | ||
| company: Red Hat | ||
| license: Apache-2.0 | ||
| min_ansible_version: "2.14" | ||
| namespace: cifmw | ||
| galaxy_tags: | ||
| - cifmw | ||
|
|
||
| dependencies: [] |
This file contains hidden or 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 @@ | ||
| --- | ||
| # Copyright Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| - name: Ensure manifest output directory exists | ||
| ansible.builtin.file: | ||
| path: "{{ cifmw_deploy_loki_manifest_dest | dirname }}" | ||
| state: directory | ||
| mode: "0755" | ||
|
|
||
| - name: Render Loki / MinIO manifests for CloudKitty | ||
| ansible.builtin.template: | ||
| src: deploy_loki_for_ck.yaml.j2 | ||
| dest: "{{ cifmw_deploy_loki_manifest_dest }}" | ||
| mode: "0644" | ||
|
|
||
| - name: Apply Loki operator and MinIO manifests | ||
| when: cifmw_deploy_loki | bool | ||
| environment: | ||
| KUBECONFIG: >- | ||
| {{ | ||
| cifmw_openshift_kubeconfig | | ||
| default(ansible_env.HOME + '/.kube/config') | ||
| }} | ||
| PATH: "{{ cifmw_path | default(ansible_env.PATH) }}" | ||
| ansible.builtin.command: | ||
| cmd: "oc apply -f {{ cifmw_deploy_loki_manifest_dest }}" | ||
| register: cifmw_deploy_loki_apply_result | ||
| changed_when: >- | ||
| ('stdout' in cifmw_deploy_loki_apply_result) and | ||
| ('unchanged' not in cifmw_deploy_loki_apply_result.stdout) | ||
|
|
||
| - name: Wait until Loki operator CSV reports Succeeded | ||
| when: | ||
| - cifmw_deploy_loki | bool | ||
| - cifmw_deploy_loki_wait_for_csv | bool | ||
| environment: | ||
| KUBECONFIG: >- | ||
| {{ | ||
| cifmw_openshift_kubeconfig | | ||
| default(ansible_env.HOME + '/.kube/config') | ||
| }} | ||
| PATH: "{{ cifmw_path | default(ansible_env.PATH) }}" | ||
| ansible.builtin.shell: | ||
| cmd: >- | ||
| oc get csv -n {{ cifmw_deploy_loki_operator_namespace }} | ||
| --no-headers=true | grep {{ cifmw_deploy_loki_subscription_name }} | ||
| register: cifmw_deploy_loki_csv_out | ||
| ignore_errors: true | ||
| until: >- | ||
| (cifmw_deploy_loki_csv_out.stdout_lines | length == 1) and | ||
| ('Succeeded' in cifmw_deploy_loki_csv_out.stdout) | ||
| retries: "{{ cifmw_deploy_loki_csv_wait_retries }}" | ||
| delay: "{{ cifmw_deploy_loki_csv_wait_delay }}" |
This file contains hidden or 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,137 @@ | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: {{ cifmw_deploy_loki_operator_namespace }} | ||
| labels: | ||
| name: {{ cifmw_deploy_loki_operator_namespace }} | ||
| --- | ||
| apiVersion: operators.coreos.com/v1 | ||
| kind: OperatorGroup | ||
| metadata: | ||
| name: {{ cifmw_deploy_loki_subscription_name }} | ||
| namespace: {{ cifmw_deploy_loki_operator_namespace }} | ||
| spec: | ||
| upgradeStrategy: Default | ||
| --- | ||
| apiVersion: operators.coreos.com/v1alpha1 | ||
| kind: Subscription | ||
| metadata: | ||
| name: {{ cifmw_deploy_loki_subscription_name }} | ||
| namespace: {{ cifmw_deploy_loki_operator_namespace }} | ||
| spec: | ||
| channel: {{ cifmw_deploy_loki_subscription_channel }} | ||
| name: {{ cifmw_deploy_loki_subscription_name }} | ||
| source: {{ cifmw_deploy_loki_catalog_source }} | ||
| sourceNamespace: {{ cifmw_deploy_loki_catalog_namespace }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: {{ cifmw_deploy_loki_minio_namespace }} | ||
| labels: | ||
| name: {{ cifmw_deploy_loki_minio_namespace }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| labels: | ||
| app: minio | ||
| name: minio | ||
| namespace: {{ cifmw_deploy_loki_minio_namespace }} | ||
| spec: | ||
| containers: | ||
| - name: minio | ||
| image: {{ cifmw_deploy_loki_minio_image }} | ||
| command: | ||
| - /bin/bash | ||
| - -c | ||
| - | | ||
| mkdir -p /data/loki && \ | ||
| minio server /data | ||
| env: | ||
| - name: MINIO_ACCESS_KEY | ||
| value: "{{ cifmw_deploy_loki_minio_access_key }}" | ||
| - name: MINIO_SECRET_KEY | ||
| value: "{{ cifmw_deploy_loki_minio_secret_key }}" | ||
| volumeMounts: | ||
| - mountPath: /data | ||
| name: storage | ||
| volumes: | ||
| - name: storage | ||
| persistentVolumeClaim: | ||
| claimName: minio-pvc | ||
| --- | ||
| apiVersion: v1 | ||
| kind: PersistentVolumeClaim | ||
| metadata: | ||
| name: minio-pvc | ||
| namespace: {{ cifmw_deploy_loki_minio_namespace }} | ||
| spec: | ||
| accessModes: | ||
| - ReadWriteOnce | ||
| resources: | ||
| requests: | ||
| storage: {{ cifmw_deploy_loki_minio_pvc_storage }} | ||
| storageClassName: {{ cifmw_deploy_loki_minio_storage_class }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: minio | ||
| namespace: {{ cifmw_deploy_loki_minio_namespace }} | ||
| spec: | ||
| selector: | ||
| app: minio | ||
| ports: | ||
| - name: api | ||
| protocol: TCP | ||
| port: 9000 | ||
| - name: console | ||
| protocol: TCP | ||
| port: 9090 | ||
| --- | ||
| kind: Route | ||
| apiVersion: route.openshift.io/v1 | ||
| metadata: | ||
| name: minio-console | ||
| namespace: {{ cifmw_deploy_loki_minio_namespace }} | ||
| spec: | ||
| {% if cifmw_deploy_loki_minio_route_console_host | length > 0 %} | ||
| host: {{ cifmw_deploy_loki_minio_route_console_host }} | ||
| {% endif %} | ||
| to: | ||
| kind: Service | ||
| name: minio | ||
| weight: 100 | ||
| port: | ||
| targetPort: console | ||
| wildcardPolicy: None | ||
| --- | ||
| kind: Route | ||
| apiVersion: route.openshift.io/v1 | ||
| metadata: | ||
| name: minio-api | ||
| namespace: {{ cifmw_deploy_loki_minio_namespace }} | ||
| spec: | ||
| {% if cifmw_deploy_loki_minio_route_api_host | length > 0 %} | ||
| host: {{ cifmw_deploy_loki_minio_route_api_host }} | ||
| {% endif %} | ||
| to: | ||
| kind: Service | ||
| name: minio | ||
| weight: 100 | ||
| port: | ||
| targetPort: api | ||
| wildcardPolicy: None | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: {{ cifmw_deploy_loki_s3_secret_name }} | ||
| namespace: {{ cifmw_deploy_loki_openstack_namespace }} | ||
| stringData: | ||
| access_key_id: "{{ cifmw_deploy_loki_minio_access_key }}" | ||
| access_key_secret: "{{ cifmw_deploy_loki_minio_secret_key }}" | ||
| bucketnames: "{{ cifmw_deploy_loki_s3_bucket }}" | ||
| endpoint: "http://minio.{{ cifmw_deploy_loki_minio_namespace }}.svc.cluster.local:9000" | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on the backup/restore feature and also needs minio for this. wondering if we should extract it into a dedicated role, to be reusable and use the same deployment, or if we keep it separate and run two instances, which can be different namespaces.