فهرست منبع

start working on logging playbook

Grega Bremec 7 ماه پیش
والد
کامیت
262f5d1fe5

+ 53 - 0
playbooks/monitoring-start.yml

@@ -0,0 +1,53 @@
+- name: Prepare for the navigate exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: monitoring-apps
+  pre_tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+  roles:
+    - role: deploy-logging
+
+  post_tasks:
+    - name: Check whether the namespace is already there
+      k8s_info:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+      register: ge_exists
+
+    - name: Fail if the namespace exists
+      fail:
+        msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
+      when: ge_exists.resources | length > 0
+
+    - name: Ensure there is a namespace for the exercise
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+...

+ 23 - 0
playbooks/roles/deploy-logging/files/cluster-logging.yml

@@ -0,0 +1,23 @@
+apiVersion: logging.openshift.io/v1
+kind: ClusterLogging
+metadata:
+  name: instance 
+  namespace: openshift-logging 
+spec:
+  collection:
+    type: vector
+  logStore:
+    lokistack:
+      name: logging-loki
+    retentionPolicy:
+      application:
+        maxAge: 7d
+      audit:
+        maxAge: 7d
+      infra:
+        maxAge: 7d
+    type: lokistack
+  visualization:
+    ocpConsole:
+      logsLimit: 15
+  managementState: Managed

+ 18 - 0
playbooks/roles/deploy-logging/files/loki-stack.yml

@@ -0,0 +1,18 @@
+apiVersion: loki.grafana.com/v1
+kind: LokiStack
+metadata:
+  name: logging-loki 
+  namespace: openshift-logging 
+spec:
+  size: 1x.extra-small 
+  storage:
+    schemas:
+    - version: v12
+      effectiveDate: "2022-06-01"
+    secret:
+      name: logging-loki-s3 
+      type: s3 
+      credentialMode: static
+  storageClassName: ocs-external-storagecluster-ceph-rbd
+  tenants:
+    mode: openshift-logging 

+ 21 - 0
playbooks/roles/deploy-logging/tasks/main.yml

@@ -0,0 +1,21 @@
+---
+- name: Ensure the openshift-operators-redhat and openshift-operators project are enabled for monitoring.
+  k8s:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: v1
+    kind: namespace
+    name: openshift-operators-redhat
+    definition:
+      metadata:
+        labels:
+          openshift.io/cluster-monitoring: "true"
+
+# Ensure openshift-logging namespace is there, and it is enabled for monitoring.
+
+# Create a LokiStack resource if not yet there.
+
+# Create a ClusterLogging instance if not yet there.
+
+# Verification???
+