Skip to content

Commit

Permalink
fixup! dev-docs: full L3 connectivity in VPN chart
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Jan 5, 2024
1 parent a089f83 commit ac5466b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
15 changes: 1 addition & 14 deletions dev-docs/howto/vpn/helm/files/routing/pod-l3-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ if [ "$$" -eq "1" ]; then
exit 1
fi

# Disable source IP verification on our network interface. Otherwise, VPN
# packets will be dropped by Cilium.

cilium_agent=$(pidof cilium-agent)
myip=$(ip -j addr show eth0 | jq -r '.[0].addr_info[] | select(.family == "inet") | .local')

cilium() {
nsenter -t "${cilium_agent}" -a -r -w cilium "$@"
}

myendpoint=$(cilium endpoint get "ipv4:${myip}" | jq '.[0].id')

cilium endpoint config "${myendpoint}" SourceIPVerification=Disabled

# Set up routes for VPN traffic. Inside our netns, point to the VPN interface.
# In the host network namespace, point to the pod interface.

Expand All @@ -38,6 +24,7 @@ ip_root() {
lower_interface_id=$(ip -j l show eth0 | jq '.[0].link_index')
lower_interface=$(ip_root -j link show | jq -r ".[] | select(.ifindex == ${lower_interface_id}) | .ifname")

myip=$(ip -j addr show eth0 | jq -r '.[0].addr_info[] | select(.family == "inet") | .local')
for cidr in ${VPN_PEER_CIDRS}; do
ip_root route replace "${cidr}" via "${myip}" dev "${lower_interface}"
done
29 changes: 29 additions & 0 deletions dev-docs/howto/vpn/helm/files/routing/sidecar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Disable source IP verification on our network interface. Otherwise, VPN
# packets will be dropped by Cilium.

reconcile_sip_verification() {

# Disable source IP verification on our network interface. Otherwise, VPN
# packets will be dropped by Cilium.

cilium_agent=$(pidof cilium-agent)
myip=$(ip -j addr show eth0 | jq -r '.[0].addr_info[] | select(.family == "inet") | .local')

cilium() {
nsenter -t "${cilium_agent}" -a -r -w cilium "$@"
}

myendpoint=$(cilium endpoint get "ipv4:${myip}" | jq '.[0].id')

if [ "$(cilium endpoint config "${myendpoint}" -o json | jq -r .realized.options.SourceIPVerification)" = "Enabled" ]; then
cilium endpoint config "${myendpoint}" SourceIPVerification=Disabled
fi

}

while true; do
reconcile_sip_verification
sleep 10
done
10 changes: 10 additions & 0 deletions dev-docs/howto/vpn/helm/templates/strongswan-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ spec:
mountPath: "/etc/swanctl/swanctl.conf"
subPath: "swanctl.conf"
readOnly: true
- name: cilium-setup
image: {{ .Values.image | quote }}
command: ["/bin/sh", "/scripts/sidecar.sh"]
env: {{- include "..commonEnv" . | nindent 10 }}
securityContext:
privileged: true
volumeMounts:
- name: scripts
mountPath: "/scripts"
readOnly: true
volumes:
- name: netns
emptyDir: {}
Expand Down
13 changes: 10 additions & 3 deletions dev-docs/howto/vpn/helm/templates/wireguard-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ spec:
- name: netns
mountPath: "/var/run/netns"
containers:
- name: placeholder # TODO: replace with pause
image: {{ .Values.image | quote }}
command: ["/bin/sh", "-c", "while true; do sleep 1000; done"]
- name: cilium-setup
image: {{ .Values.image | quote }}
command: ["/bin/sh", "/scripts/sidecar.sh"]
env: {{- include "..commonEnv" . | nindent 10 }}
securityContext:
privileged: true
volumeMounts:
- name: scripts
mountPath: "/scripts"
readOnly: true
volumes:
- name: netns
emptyDir: {}
Expand Down

0 comments on commit ac5466b

Please sign in to comment.