Skip to content

Commit 11c08e6

Browse files
committed
Check on ipsec.service instead of libreswan package on host
The rpm db directory is different on rhcos and rhel workers, so mounting /usr/share/rpm directory will not work for rhel worker nodes. To avoid this, this commit checks on ipsec systemd service on the host to decide which ipsec deployment to be active or dormant. Signed-off-by: Periyasamy Palanisamy <[email protected]>
1 parent cb99bc3 commit 11c08e6

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

bindata/network/ovn-kubernetes/common/ipsec-containerized.yaml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ spec:
3737
- key: network.operator.openshift.io/dpu-host
3838
operator: DoesNotExist
3939
serviceAccountName: ovn-kubernetes-node
40+
{{ if .IPsecServiceCheckOnHost }}
41+
hostPID: true
42+
{{ end }}
4043
hostNetwork: true
4144
dnsPolicy: Default
4245
priorityClassName: "system-node-critical"
@@ -50,9 +53,9 @@ spec:
5053
#!/bin/bash
5154
set -exuo pipefail
5255
53-
{{ if .IPsecCheckForLibreswan }}
54-
if rpm --dbpath=/usr/share/rpm -q libreswan; then
55-
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container doesnt need to init anything"
56+
{{ if .IPsecServiceCheckOnHost }}
57+
if chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
58+
echo "host has ipsec.service running and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container doesnt need to init anything"
5659
exit 0
5760
fi
5861
{{ end }}
@@ -197,9 +200,6 @@ spec:
197200
name: signer-ca
198201
- mountPath: /etc/openvswitch
199202
name: etc-openvswitch
200-
- mountPath: /usr/share/rpm
201-
name: host-usr-share-rpm
202-
readOnly: true
203203
resources:
204204
requests:
205205
cpu: 10m
@@ -231,9 +231,9 @@ spec:
231231
}
232232
trap cleanup SIGTERM
233233
234-
{{ if .IPsecCheckForLibreswan }}
235-
if rpm --dbpath=/usr/share/rpm -q libreswan; then
236-
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container will sleep to infinity"
234+
{{ if .IPsecServiceCheckOnHost }}
235+
if chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
236+
echo "host has ipsec.service running and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container will sleep to infinity"
237237
sleep infinity
238238
fi
239239
{{ end }}
@@ -294,9 +294,6 @@ spec:
294294
name: host-var-log-ovs
295295
- mountPath: /etc/openvswitch
296296
name: etc-openvswitch
297-
- mountPath: /usr/share/rpm
298-
name: host-usr-share-rpm
299-
readOnly: true
300297
resources:
301298
requests:
302299
cpu: 10m
@@ -309,9 +306,9 @@ spec:
309306
- -c
310307
- |
311308
#!/bin/bash
312-
{{ if .IPsecCheckForLibreswan }}
313-
if rpm --dbpath=/usr/share/rpm -q libreswan; then
314-
echo "host has libreswan and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container is always \"alive\""
309+
{{ if .IPsecServiceCheckOnHost }}
310+
if chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
311+
echo "host has ipsec.service running and therefore ipsec will be configured by ipsec host daemonset, this ovn ipsec container is always \"alive\""
315312
exit 0
316313
fi
317314
{{ end }}
@@ -348,10 +345,6 @@ spec:
348345
- name: host-cni-netd
349346
hostPath:
350347
path: "{{.CNIConfDir}}"
351-
- name: host-usr-share-rpm
352-
hostPath:
353-
path: /usr/share/rpm
354-
type: DirectoryOrCreate
355348
tolerations:
356349
- operator: "Exists"
357350
{{end}}

bindata/network/ovn-kubernetes/common/ipsec-host.yaml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ spec:
5050
- |
5151
#!/bin/bash
5252
set -exuo pipefail
53-
{{ if .IPsecCheckForLibreswan }}
54-
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
55-
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container has nothing to init"
53+
{{ if .IPsecServiceCheckOnHost }}
54+
if ! chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
55+
echo "host doesn't have ipsec.service running, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container has nothing to init"
5656
exit 0
5757
fi
5858
{{ end }}
@@ -200,9 +200,6 @@ spec:
200200
name: etc-openvswitch
201201
- mountPath: /etc
202202
name: host-etc
203-
- mountPath: /usr/share/rpm
204-
name: host-usr-share-rpm
205-
readOnly: true
206203
resources:
207204
requests:
208205
cpu: 10m
@@ -219,9 +216,9 @@ spec:
219216
#!/bin/bash
220217
set -exuo pipefail
221218
222-
{{ if .IPsecCheckForLibreswan }}
223-
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
224-
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container will sleep to infinity"
219+
{{ if .IPsecServiceCheckOnHost }}
220+
if ! chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
221+
echo "host doesn't have ipsec.service running, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container will sleep to infinity"
225222
sleep infinity
226223
fi
227224
{{ end }}
@@ -301,9 +298,9 @@ spec:
301298
# In order to maintain traffic flows during container restart, we
302299
# need to ensure that xfrm state and policies are not flushed.
303300
304-
{{ if .IPsecCheckForLibreswan }}
305-
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
306-
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, preStop wont do anything"
301+
{{ if .IPsecServiceCheckOnHost }}
302+
if ! chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
303+
echo "host doesn't have ipsec.service running, therefore ipsec will be configured by ipsec-containerized daemonset, preStop wont do anything"
307304
exit 0
308305
fi
309306
{{ end }}
@@ -335,9 +332,6 @@ spec:
335332
name: usr-sbin
336333
- mountPath: /usr/libexec
337334
name: usr-libexec
338-
- mountPath: /usr/share/rpm
339-
name: host-usr-share-rpm
340-
readOnly: true
341335
resources:
342336
requests:
343337
cpu: 10m
@@ -350,9 +344,9 @@ spec:
350344
- -c
351345
- |
352346
#!/bin/bash
353-
{{ if .IPsecCheckForLibreswan }}
354-
if ! rpm --dbpath=/usr/share/rpm -q libreswan; then
355-
echo "host doesnt have libreswan, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container is always \"alive\""
347+
{{ if .IPsecServiceCheckOnHost }}
348+
if ! chroot /proc/1/root systemctl is-active --quiet ipsec.service; then
349+
echo "host doesn't have ipsec.service running, therefore ipsec will be configured by ipsec-containerized daemonset, this ovn ipsec container is always \"alive\""
356350
exit 0
357351
fi
358352
{{ end }}
@@ -541,10 +535,6 @@ spec:
541535
path: /usr/libexec
542536
type: Directory
543537
name: usr-libexec
544-
- name: host-usr-share-rpm
545-
hostPath:
546-
path: /usr/share/rpm
547-
type: DirectoryOrCreate
548538
tolerations:
549539
- operator: "Exists"
550540
{{end}}

pkg/network/ovn_kubernetes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
292292
data.Data["IPsecMachineConfigEnable"] = IPsecMachineConfigEnable
293293
data.Data["OVNIPsecDaemonsetEnable"] = OVNIPsecDaemonsetEnable
294294
data.Data["OVNIPsecEnable"] = OVNIPsecEnable
295-
data.Data["IPsecCheckForLibreswan"] = renderIPsecHostDaemonSet && renderIPsecContainerizedDaemonSet
295+
data.Data["IPsecServiceCheckOnHost"] = renderIPsecHostDaemonSet && renderIPsecContainerizedDaemonSet
296296

297297
klog.V(5).Infof("IPsec: is MachineConfig enabled: %v, is East-West DaemonSet enabled: %v", data.Data["IPsecMachineConfigEnable"], data.Data["OVNIPsecDaemonsetEnable"])
298298

0 commit comments

Comments
 (0)