Skip to content

Commit

Permalink
Fix automation and change name of the datasource (#385)
Browse files Browse the repository at this point in the history
* Fix automation and change name of the datasource

Signed-off-by: Jakub Stejskal <[email protected]>

* Revert branch for deployment-hub

Signed-off-by: Jakub Stejskal <[email protected]>

---------

Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless authored Jan 13, 2025
1 parent 856b2fd commit 134053a
Show file tree
Hide file tree
Showing 27 changed files with 167 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/skodjob-ee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./skodjob-ee/context
file: ./skodjob-ee/context/Dockerfile
file: ./skodjob-ee/context/Containerfile
push: true
# TODO - Change org when we will create a new one
tags: quay.io/tealc/skodjob-ee:latest
3 changes: 3 additions & 0 deletions image-update/strimzi-image-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ do
LATEST_DIGEST=$(skopeo inspect --override-arch amd64 --override-os linux docker://"$TARGET_ORG_REPO"/"$IMAGE":latest-kafka-"$PREFIX" --format "{{ .Digest }}")
elif [[ $ELEMENT == *"kafka@"* ]]; then
continue
# Do not care about bridge version
elif [[ $ELEMENT == *"bridge@"* ]]; then
continue
else
LATEST_DIGEST=$(skopeo inspect --override-arch amd64 --override-os linux docker://"$TARGET_ORG_REPO"/"$IMAGE" --format "{{ .Digest }}")
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
template: templates/acm/06-thanos-storage-secret.yaml.j2
verify_ssl: no

# This is needed if the clusters are created via our ACM.
# MultiClusterObservability is installed only on managed clusters with this label
- name: Label each cluster with vendor=OpenShift
ansible.builtin.shell: "oc label managedcluster {{ cluster.name }} vendor=OpenShift --overwrite"
environment:
KUBECONFIG: "{{ kubeconfig_path }}/{{ infra_context_name }}"
loop: "{{ clusters_dict.values() }}"
loop_control:
loop_var: cluster

- name: "Create multicluster observability on Infra cluster"
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
labels:
project: "skodjob"
secret: "cert-manager"
strimzi.io/sync-secrets: "true"

- name: Clean helm releases for workflows
shell: "oc delete secret -l owner=helm -n {{ infra_workflow_namespace }} || true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Create Strimzi namespaces on Infra cluster
- name: Create Strimzi Operator namespaces on Infra cluster
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
verify_ssl: no
Expand All @@ -11,12 +11,28 @@
name: "{{ item }}"
labels:
project: "skodjob"
strimzi.io/sync-secrets: "true"
strimzi.io/type: operators
loop:
- "{{ strimzi_operator_namespace }}"
- "{{ strimzi_kafka_namespace }}"
- "{{ strimzi_drain_cleaner_namespace }}"

- name: Create Strimzi Event Bus namespaces on Infra cluster
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
verify_ssl: no
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ item }}"
labels:
project: "skodjob"
strimzi.io/sync-secrets: "true"
strimzi.io/type: operands
loop:
- "{{ strimzi_kafka_namespace }}"

- name: Clean helm releases for workflows
shell: "oc delete secret -l owner=helm -n {{ strimzi_operator_namespace }} || true"
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
---
# Get Grafana access token and update clusters data
- name: "Export access token {{ cluster.name }}"
# shell: "oc serviceaccounts get-token grafana-serviceaccount -n {{ target.sa_namespace }}"
shell: "oc get $(oc get secret -o name -n {{ cluster.monitoring_namespace }} | grep {{ sa_name }}-token) -n {{ cluster.monitoring_namespace }} -o=jsonpath='{.data.token}' | base64 -d"
- name: "Export access token for {{ cluster.name }}"
shell: "oc get secret {{ sa_name }} -n {{ cluster.monitoring_namespace }} -o=jsonpath='{.data.token}' | base64 -d"
environment:
KUBECONFIG: "{{ kubeconfig_path }}/{{ cluster.name }}"
register: "access_token_out"

- debug:
msg: "{{ access_token_out }}"

- name: "Set facts grafana access token - {{ cluster.name }}"
set_fact: access_token="{{ access_token_out.stdout }}"

- name: Check that token exists
fail:
msg: "Token is not properly stored!\n{{ access_token }}"
when: access_token | length == 0

- name: "Update facts for {{ cluster.name }}"
ansible.utils.update_fact:
updates:
Expand All @@ -23,7 +33,7 @@
clusters_dict: "{{ updated_data.clusters_dict }}"
when: is_worker is defined

- name: "Create Grafana data-source {{ cluster.name }}"
- name: "Create Grafana data-source {{ datasource_name }}"
kubernetes.core.k8s:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
namespace: "{{ cluster.monitoring_namespace }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,21 @@
vars:
is_worker: True
sa_name: "{{ cluster.name }}-grafana"
datasource_name: "{{ cluster.name }}"
url: "https://thanos-querier-openshift-monitoring.apps.{{ cluster.name }}.{{ cluster_domain }}:443"

- name: Create data-sources on Infra cluster for Infra data
include_tasks: deploy-data-source.yaml
loop:
- {name: "{{ infra_context_name }}",
datasource_name: "{{ infra_context_name }}",
sa_namespace: "{{ infra_user_namespace }}",
monitoring_namespace: "{{ infra_monitoring_namespace }}",
target_cluster_name: "{{ infra_context_name }}",
context: "{{ infra_context_name }}",
url: "https://thanos-querier.openshift-monitoring.svc.cluster.local:9091"}
- {name: "skodjob-thanos",
- {name: "{{ infra_context_name }}",
datasource_name: "skodjob-thanos",
sa_namespace: "{{ infra_user_namespace }}",
monitoring_namespace: "{{ infra_monitoring_namespace }}",
target_cluster_name: "{{ infra_context_name }}",
Expand All @@ -154,7 +157,8 @@
loop_control:
loop_var: cluster
vars:
sa_name: "skodjob-sa"
sa_name: "{{ infra_context_name }}-grafana"
datasource_name: "{{ cluster.datasource_name }}"

- name: Configure Alertmanager to for sending alerts on Infra cluster from all clusters
kubernetes.core.k8s:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,79 @@
verify_ssl: no
apply: true
with_fileglob: 'templates/argo-workflows/eventsource/*.j2'

- name: Wait for EventSources - Deployed
kubernetes.core.k8s_info:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
namespace: "{{ infra_workflow_namespace }}"
kind: EventSource
api_version: argoproj.io/v1alpha1
name: "{{ item }}"
wait: true
verify_ssl: no
wait_condition:
type: Deployed
status: True
loop:
- automation-hub
register: eventsource_info

# TODO - Fail if single sensor is not found, this could be improved to properly check the status
- name: Fail if EventSource is not found
fail:
msg: "EventSource automation-hub not found."
loop: "{{ eventsource_info.results }}"
when: item.resources | length == 0

- name: Wait for EventSources - SourcesProvided
kubernetes.core.k8s_info:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
namespace: "{{ infra_workflow_namespace }}"
kind: EventSource
api_version: argoproj.io/v1alpha1
name: "{{ item }}"
wait: true
verify_ssl: no
wait_condition:
type: SourcesProvided
status: True
loop:
- automation-hub

- name: Wait for Sensors - Deployed
kubernetes.core.k8s_info:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
namespace: "{{ infra_workflow_namespace }}"
kind: Sensor
api_version: argoproj.io/v1alpha1
name: "{{ item }}"
wait: true
verify_ssl: no
wait_condition:
type: Deployed
status: True
loop:
- automation-hub
register: sensor_info

# TODO - Fail if single sensor is not found, this could be improved to properly check the status
- name: Fail if Sensor is not found
fail:
msg: "Sensor automation-hub not found."
loop: "{{ sensor_info.results }}"
when: item.resources | length == 0

- name: Wait for Sensors - TriggersProvided
kubernetes.core.k8s_info:
kubeconfig: "{{ kubeconfig_path }}/{{ infra_context_name }}"
namespace: "{{ infra_workflow_namespace }}"
kind: Sensor
api_version: argoproj.io/v1alpha1
name: "{{ item }}"
wait: true
verify_ssl: no
wait_condition:
type: TriggersProvided
status: True
loop:
- automation-hub
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ spec:
receiveStorageSize: 100Gi
ruleStorageSize: 10Gi
storageClass: standard-csi
# This might need increase in the future
storeStorageSize: 10Gi
# For more info see https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.7/html-single/apis/index
# For more info see https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.12/html-single/apis/index
advanced:
receive:
replicas: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: ApplicationSet
metadata:
name: amq-streams-infra
spec:
syncPolicy:
preserveResourcesOnDeletion: true
generators:
- matrix:
generators:
Expand Down Expand Up @@ -36,7 +38,6 @@ spec:
selfHeal: true
syncOptions:
- CreateNamespace=true
preserveResourcesOnDeletion: true
managedNamespaceMetadata:
labels:
project: skodjob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: ApplicationSet
metadata:
name: debezium
spec:
syncPolicy:
preserveResourcesOnDeletion: true
generators:
- matrix:
generators:
Expand Down Expand Up @@ -36,7 +38,6 @@ spec:
selfHeal: true
syncOptions:
- CreateNamespace=true
preserveResourcesOnDeletion: true
managedNamespaceMetadata:
labels:
project: skodjob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/argo
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/strimzi-operator
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/strimzi-operator
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/strimzi-drain-cleaner
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka-connect
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka-kraft
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka-mirror-maker
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka-mirror-maker
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/strimzi-operator
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/strimzi-drain-cleaner
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/alerts/kafka
directory:
recurse: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
project: monitoring
source:
repoURL: https://github.com/skodjob/deployment-hub
targetRevision: HEAD
targetRevision: {{ deployment_hub_branch }}
path: metrics/grafana/dashboards
directory:
recurse: true
Expand Down
Loading

0 comments on commit 134053a

Please sign in to comment.