Skip to content

Commit

Permalink
Add logic to OVN-Kubernetes to determine what platform we are runnin…
Browse files Browse the repository at this point in the history
…g on.

    Only use drop icmp frag needed daemonset when on Azure platform
    drop icmp frag needed received from other nodes in the cluster

Signed-off-by: Michael Cambria <mcambria@redhat.com>
  • Loading branch information
mccv1r0 committed Sep 24, 2021
1 parent 1432459 commit 7a05ada
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
68 changes: 68 additions & 0 deletions bindata/network/ovn-kubernetes/ovnkube-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,74 @@ spec:
command: ["test", "-f", "/etc/cni/net.d/10-ovn-kubernetes.conf"]
initialDelaySeconds: 5
periodSeconds: 5
{{- if .OVNPlatformAzure}}
- name: drop-icmp
image: "{{.OvnImage}}"
command:
- /bin/bash
- -c
- |
set -xe
touch /var/run/ovn/add_iptables.sh
chmod 0755 /var/run/ovn/add_iptables.sh
cat <<'EOF' > /var/run/ovn/add_iptables.sh
#!/bin/sh
if [ -z "$3" ]
then
echo "Called with host address missing, ignore"
exit 0
fi
echo "Adding ICMP drop rule for '$3' "
if iptables -C CHECK_ICMP_SOURCE -p icmp -s $3 -j ICMP_ACTION
then
echo "iptables already set for $3"
else
iptables -A CHECK_ICMP_SOURCE -p icmp -s $3 -j ICMP_ACTION
fi
EOF
echo "I$(date "+%m%d %H:%M:%S.%N") - drop-icmp - start drop-icmp ${K8S_NODE}"
iptables -X CHECK_ICMP_SOURCE || true
iptables -N CHECK_ICMP_SOURCE || true
iptables -F CHECK_ICMP_SOURCE
iptables -D INPUT -p icmp --icmp-type fragmentation-needed -j CHECK_ICMP_SOURCE || true
iptables -I INPUT -p icmp --icmp-type fragmentation-needed -j CHECK_ICMP_SOURCE
iptables -N ICMP_ACTION || true
iptables -F ICMP_ACTION
iptables -A ICMP_ACTION -j LOG
iptables -A ICMP_ACTION -j DROP
#
ip addr show
ip route show
iptables -nvL
iptables -nvL -t nat
oc observe pods -n openshift-ovn-kubernetes -l app=ovnkube-node -a '{ .status.hostIP }' -- /var/run/ovn/add_iptables.sh
#systemd-run -qPG -- oc observe pods -n openshift-ovn-kubernetes -l app=ovnkube-node -a '{ .status.hostIP }' -- /var/run/ovn/add_iptables.sh
lifecycle:
preStop:
exec:
command: ["/bin/bash", "-c", "echo drop-icmp done"]
securityContext:
privileged: true
volumeMounts:
# for the iptables wrapper
- mountPath: /host
name: host-slash
readOnly: true
mountPropagation: HostToContainer
- mountPath: /run/ovn/
name: run-ovn
resources:
requests:
cpu: 5m
memory: 20Mi
env:
- name: K8S_NODE
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- end}}
nodeSelector:
beta.kubernetes.io/os: "linux"
volumes:
Expand Down
12 changes: 12 additions & 0 deletions pkg/network/ovn_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
data.Data["OVNPolicyAuditDestination"] = c.PolicyAuditConfig.Destination
data.Data["OVNPolicyAuditSyslogFacility"] = c.PolicyAuditConfig.SyslogFacility
data.Data["OVN_LOG_PATTERN_CONSOLE"] = OVN_LOG_PATTERN_CONSOLE
if bootstrapResult.OVN.Platform == configv1.AzurePlatformType {
data.Data["OVNPlatformAzure"] = true
} else {
data.Data["OVNPlatformAzure"] = false
}

var ippools string
for _, net := range conf.ClusterNetwork {
Expand Down Expand Up @@ -433,6 +438,12 @@ func bootstrapOVN(conf *operv1.Network, kubeClient client.Client) (*bootstrap.Bo
}
externalControlPlane := infraConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode

var platformType configv1.PlatformType
if infraConfig.Status.PlatformStatus != nil {
platformType = infraConfig.Status.PlatformStatus.Type
}
klog.V(2).Infof("Openshift-OVN: Bootstrap OVN infraConfig Platform: %q", platformType)

rcD := replicaCountDecoder{}
if err := yaml.Unmarshal([]byte(clusterConfig.Data["install-config"]), &rcD); err != nil {
return nil, fmt.Errorf("Unable to bootstrap OVN, unable to unmarshal install-config: %s", err)
Expand Down Expand Up @@ -556,6 +567,7 @@ func bootstrapOVN(conf *operv1.Network, kubeClient client.Client) (*bootstrap.Bo
ExistingNodeDaemonset: nodeDS,
OVNKubernetesConfig: ovnConfigResult,
PrePullerDaemonset: prePullerDS,
Platform: platformType,
},
}
return &res, nil
Expand Down

0 comments on commit 7a05ada

Please sign in to comment.