|
| 1 | +suite: opensearch-operator raises vm.max_map_count per node |
| 2 | + |
| 3 | +# OpenSearch will not start below vm.max_map_count=262144 and the sysctl is not |
| 4 | +# namespaced, so no pod can set it for itself. This DaemonSet is the platform's |
| 5 | +# carrier for it, which is why its shape is the contract: privileged init, that |
| 6 | +# exact sysctl, and nothing mounted from the host. |
| 7 | +release: |
| 8 | + name: opensearch-operator |
| 9 | + namespace: cozy-opensearch-operator |
| 10 | +tests: |
| 11 | + # The command is pinned whole because both halves of it are the contract: the |
| 12 | + # threshold OpenSearch needs, and the comparison that makes it a floor. Writing |
| 13 | + # the value unconditionally would lower vm.max_map_count on any node already |
| 14 | + # tuned above it, node-wide, on every boot. |
| 15 | + - it: raises the sysctl to a floor from a privileged init container |
| 16 | + template: templates/sysctl-daemonset.yaml |
| 17 | + asserts: |
| 18 | + - equal: |
| 19 | + path: kind |
| 20 | + value: DaemonSet |
| 21 | + - equal: |
| 22 | + path: spec.template.spec.initContainers[0].name |
| 23 | + value: init-sysctl |
| 24 | + - equal: |
| 25 | + path: spec.template.spec.initContainers[0].command |
| 26 | + value: |
| 27 | + - sh |
| 28 | + - -c |
| 29 | + - 'set -e; current=$(sysctl -n vm.max_map_count); if [ "$current" -lt 262144 ]; then sysctl -w vm.max_map_count=262144; fi' |
| 30 | + - equal: |
| 31 | + path: spec.template.spec.initContainers[0].securityContext.privileged |
| 32 | + value: true |
| 33 | + |
| 34 | + - it: keeps the privilege in the init container only |
| 35 | + template: templates/sysctl-daemonset.yaml |
| 36 | + asserts: |
| 37 | + - equal: |
| 38 | + path: spec.template.spec.containers[0].name |
| 39 | + value: idle |
| 40 | + # The trap is the contract, not decoration. PID 1 of a namespace receives |
| 41 | + # only the signals it installed a handler for, so a bare sleep here ignores |
| 42 | + # SIGTERM and every pod is SIGKILLed after the full grace period on each |
| 43 | + # rollout and node drain. |
| 44 | + - equal: |
| 45 | + path: spec.template.spec.containers[0].command |
| 46 | + value: ["sh", "-c", "trap 'exit 0' TERM INT; sleep infinity & wait"] |
| 47 | + - notExists: |
| 48 | + path: spec.template.spec.containers[0].securityContext.privileged |
| 49 | + - equal: |
| 50 | + path: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation |
| 51 | + value: false |
| 52 | + - equal: |
| 53 | + path: spec.template.spec.containers[0].securityContext.capabilities.drop |
| 54 | + value: ["ALL"] |
| 55 | + |
| 56 | + # Nothing may reach the host filesystem: the write belongs in /proc/sys and |
| 57 | + # the pod reapplies it on every node restart. |
| 58 | + - it: touches no host path |
| 59 | + template: templates/sysctl-daemonset.yaml |
| 60 | + asserts: |
| 61 | + - notExists: |
| 62 | + path: spec.template.spec.volumes |
| 63 | + - notExists: |
| 64 | + path: spec.template.spec.initContainers[0].volumeMounts |
| 65 | + - notExists: |
| 66 | + path: spec.template.spec.containers[0].volumeMounts |
| 67 | + - equal: |
| 68 | + path: spec.template.spec.automountServiceAccountToken |
| 69 | + value: false |
| 70 | + - equal: |
| 71 | + path: spec.template.spec.priorityClassName |
| 72 | + value: system-node-critical |
| 73 | + |
| 74 | + - it: lands on tainted nodes and pins the image by digest |
| 75 | + template: templates/sysctl-daemonset.yaml |
| 76 | + asserts: |
| 77 | + - contains: |
| 78 | + path: spec.template.spec.tolerations |
| 79 | + content: |
| 80 | + operator: Exists |
| 81 | + effect: NoSchedule |
| 82 | + - contains: |
| 83 | + path: spec.template.spec.tolerations |
| 84 | + content: |
| 85 | + operator: Exists |
| 86 | + effect: NoExecute |
| 87 | + - matchRegex: |
| 88 | + path: spec.template.spec.initContainers[0].image |
| 89 | + pattern: '^docker\.io/library/busybox:[^@]+@sha256:[0-9a-f]{64}$' |
| 90 | + |
| 91 | + - it: takes the image override for an air-gapped registry |
| 92 | + template: templates/sysctl-daemonset.yaml |
| 93 | + set: |
| 94 | + sysctl: |
| 95 | + image: registry.example.test/library/busybox:1.37.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 |
| 96 | + asserts: |
| 97 | + - equal: |
| 98 | + path: spec.template.spec.initContainers[0].image |
| 99 | + value: registry.example.test/library/busybox:1.37.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 |
| 100 | + - equal: |
| 101 | + path: spec.template.spec.containers[0].image |
| 102 | + value: registry.example.test/library/busybox:1.37.0@sha256:0000000000000000000000000000000000000000000000000000000000000000 |
0 commit comments