|
| 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 the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | + |
| 17 | +- name: Reduce cluster logging to minimum |
| 18 | + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" |
| 19 | + gather_facts: false |
| 20 | + environment: |
| 21 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 22 | + tasks: |
| 23 | + - name: Get all MachineConfigPools |
| 24 | + kubernetes.core.k8s_info: |
| 25 | + api_version: machineconfiguration.openshift.io/v1 |
| 26 | + kind: MachineConfigPool |
| 27 | + register: _mcp_list |
| 28 | + |
| 29 | + - name: Apply KubeletConfig per MachineConfigPool |
| 30 | + kubernetes.core.k8s: |
| 31 | + state: present |
| 32 | + definition: |
| 33 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 34 | + kind: KubeletConfig |
| 35 | + metadata: |
| 36 | + name: "reduce-container-logs-{{ item }}" |
| 37 | + spec: |
| 38 | + machineConfigPoolSelector: |
| 39 | + matchLabels: |
| 40 | + pools.operator.machineconfiguration.openshift.io/{{ item }}: "" |
| 41 | + kubeletConfig: |
| 42 | + containerLogMaxSize: "1Mi" |
| 43 | + containerLogMaxFiles: 2 |
| 44 | + loop: >- |
| 45 | + {{ _mcp_list.resources | map(attribute='metadata.name') | list }} |
| 46 | +
|
| 47 | + - name: Apply ContainerRuntimeConfig per MachineConfigPool |
| 48 | + kubernetes.core.k8s: |
| 49 | + state: present |
| 50 | + definition: |
| 51 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 52 | + kind: ContainerRuntimeConfig |
| 53 | + metadata: |
| 54 | + name: "reduce-crio-logs-{{ item }}" |
| 55 | + spec: |
| 56 | + machineConfigPoolSelector: |
| 57 | + matchLabels: |
| 58 | + pools.operator.machineconfiguration.openshift.io/{{ item }}: "" |
| 59 | + containerRuntimeConfig: |
| 60 | + logLevel: "error" |
| 61 | + logSizeMax: "1Mi" |
| 62 | + loop: >- |
| 63 | + {{ _mcp_list.resources | map(attribute='metadata.name') | list }} |
| 64 | +
|
| 65 | + - name: Wait for MachineConfigPool rollouts to complete |
| 66 | + when: cifmw_reduce_cluster_logging_wait | default(true) | bool |
| 67 | + ansible.builtin.command: |
| 68 | + cmd: >- |
| 69 | + oc wait mcp --all |
| 70 | + --for=condition=Updated |
| 71 | + --timeout=1800s |
| 72 | + changed_when: false |
0 commit comments