|
| 1 | +--- |
| 2 | +- name: Create kubelet-config with topologyManagerPolicy 'none' |
| 3 | + kubernetes.core.k8s: |
| 4 | + state: present |
| 5 | + definition: |
| 6 | + apiVersion: machineconfiguration.openshift.io/v1 |
| 7 | + kind: KubeletConfig |
| 8 | + metadata: |
| 9 | + name: cpumanager-enabled |
| 10 | + spec: |
| 11 | + machineConfigPoolSelector: |
| 12 | + matchLabels: |
| 13 | + custom-kubelet: cpumanager-enabled |
| 14 | + kubeletConfig: |
| 15 | + cpuManagerPolicy: static |
| 16 | + cpuManagerReconcilePeriod: 5s |
| 17 | + topologyManagerPolicy: none |
| 18 | + |
| 19 | +- name: Wait for 2 minutes before checking MCP status |
| 20 | + pause: |
| 21 | + minutes: 2 |
| 22 | + |
| 23 | +- name: Check mcp status |
| 24 | + shell: oc get mcp worker | awk 'NR==2 {print $3}' |
| 25 | + register: mcpstatus |
| 26 | + until: mcpstatus.stdout == 'True' |
| 27 | + retries: 20 |
| 28 | + delay: 60 |
| 29 | + |
| 30 | +- name: Check the worker node for the updated kubelet.conf |
| 31 | + shell: oc debug node/worker-1 -q -- chroot /host cat /etc/kubernetes/kubelet.conf | grep -E 'reservedSystemCPUs|cpuManager|topologyManager' |
| 32 | + register: pa_result |
| 33 | + |
| 34 | +- name: Verify the updated config |
| 35 | + debug: |
| 36 | + var: pa_result.stdout_lines |
| 37 | + |
| 38 | +- name: Create pod with {{ none_cpuv1 }} cpu request |
| 39 | + kubernetes.core.k8s: |
| 40 | + state: present |
| 41 | + definition: |
| 42 | + apiVersion: v1 |
| 43 | + kind: Pod |
| 44 | + metadata: |
| 45 | + name: "podcpu{{ none_cpuv1 }}" |
| 46 | + namespace: default |
| 47 | + spec: |
| 48 | + nodeSelector: |
| 49 | + kubernetes.io/hostname: worker-1 |
| 50 | + containers: |
| 51 | + - name: appcntr1 |
| 52 | + image: "{{ pause_image }}" |
| 53 | + imagePullPolicy: IfNotPresent |
| 54 | + command: [ "/bin/bash", "-c", "--" ] |
| 55 | + args: [ "while true; do sleep 300000; done;" ] |
| 56 | + resources: |
| 57 | + requests: |
| 58 | + cpu: "{{ none_cpuv1 }}" |
| 59 | + memory: 200Mi |
| 60 | + limits: |
| 61 | + cpu: "{{ none_cpuv1 }}" |
| 62 | + memory: 200Mi |
| 63 | + |
| 64 | +- name: Verify the pod gets scheduled |
| 65 | + shell: oc get pod podcpu{{ none_cpuv1 }} | awk 'NR==2 {print $3}' |
| 66 | + register: result |
| 67 | + until: result.stdout == "Running" |
| 68 | + retries: 5 |
| 69 | + delay: 10 |
| 70 | + |
| 71 | +- name: Create pod with {{ none_cpuv2 }} cpu request |
| 72 | + kubernetes.core.k8s: |
| 73 | + state: present |
| 74 | + definition: |
| 75 | + apiVersion: v1 |
| 76 | + kind: Pod |
| 77 | + metadata: |
| 78 | + name: "podcpu{{ none_cpuv2 }}" |
| 79 | + namespace: default |
| 80 | + spec: |
| 81 | + nodeSelector: |
| 82 | + kubernetes.io/hostname: worker-1 |
| 83 | + containers: |
| 84 | + - name: appcntr1 |
| 85 | + image: "{{ pause_image }}" |
| 86 | + imagePullPolicy: IfNotPresent |
| 87 | + command: [ "/bin/bash", "-c", "--" ] |
| 88 | + args: [ "while true; do sleep 300000; done;" ] |
| 89 | + resources: |
| 90 | + requests: |
| 91 | + cpu: "{{ none_cpuv2 }}" |
| 92 | + memory: 330Mi |
| 93 | + limits: |
| 94 | + cpu: "{{ none_cpuv2 }}" |
| 95 | + memory: 330Mi |
| 96 | + |
| 97 | +- name: Verify the pod gets scheduled |
| 98 | + shell: oc get pod podcpu{{ none_cpuv2 }} | awk 'NR==2 {print $3}' |
| 99 | + register: result |
| 100 | + until: result.stdout == "Running" |
| 101 | + retries: 5 |
| 102 | + delay: 10 |
| 103 | + |
| 104 | +- name: Print a simple message |
| 105 | + debug: |
| 106 | + msg: "None policy validated successfully" |
| 107 | + |
| 108 | +- name: Cleanup |
| 109 | + block: |
| 110 | + - name: Delete the pods created |
| 111 | + shell: oc delete pods --all |
| 112 | + |
| 113 | + - name: Verify pods deletion |
| 114 | + shell: oc get pods | wc -l |
| 115 | + register: pods_count |
| 116 | + until: pods_count.stdout | int == 0 |
| 117 | + retries: 10 |
| 118 | + delay: 10 |
0 commit comments