Browse Source

apply infra label to projects

Grega Bremec 1 month ago
parent
commit
5faa8584a8
2 changed files with 30 additions and 1 deletions
  1. 12 1
      playbooks/pre-flight.yml
  2. 18 0
      playbooks/roles/apply-infra-labels/tasks/main.yml

+ 12 - 1
playbooks/pre-flight.yml

@@ -116,12 +116,23 @@
         - prep
         - setup
         - monitor
+    # Apply some labels to projects.
+    - include_role:
+        name: apply-infra-labels
+        apply:
+          tags:
+            - prep
+            - setup
+            - labels
+      tags:
+        - prep
+        - setup
+        - labels
 
 # TODO: deploy grafana (?)
 # TODO: deploy logging (?)
 # TODO: logging requires minio
 # TODO: create a private network (nmstate + bridges?)
-# TODO: apply ichp_infra: true labels to projects
 
 # Some additional configuration for infra.
 - name: Ensure HAProxy on utility does not forward plaintext HTTP to OpenShift.

+ 18 - 0
playbooks/roles/apply-infra-labels/tasks/main.yml

@@ -0,0 +1,18 @@
+---
+# Applies infra labels to key projects.
+- name: Apply a label patch to all the relevant projects.
+  kubernetes.core.k8s:
+    kubeconfig: tmp/kubeconfig-ocp4
+    validate_certs: no
+    api_version: v1
+    kind: namespace
+    name: "{{ item }}"
+    state: patched
+    resource_definition:
+      metadata:
+        labels:
+          ichp_infra: "true"
+  loop:
+    - openshift-monitoring
+    - openshift-user-workload-monitoring
+...