Ver código fonte

add preStop hook to cleanup routes

Stavros kois 2 anos atrás
pai
commit
83f9690c81
1 arquivos alterados com 14 adições e 0 exclusões
  1. 14 0
      test/wg-easy/1.0.0/templates/deployment.yaml

+ 14 - 0
test/wg-easy/1.0.0/templates/deployment.yaml

@@ -87,6 +87,20 @@ spec:
             initialDelaySeconds: 5
             failureThreshold: 40
             periodSeconds: 15
+          lifecycle:
+            preStop:
+            exec:
+                command:
+                  - /bin/bash
+                  - -c
+                  - |
+                    echo "Deleting routes created by the app..."
+                    netmask=$(ip route | grep {{ $ip }})
+                    netmask=$(echo $netmask | grep -o -E '/.\d*')
+                    netmask=${netmask#/}
+                    echo "Matched routes to delete... {{ $ip }}/$netmask"
+                    ip route del {{ $ip }}/$netmask || echo "Route deletion failed..."
+                    echo "Routes deleted..."
 {{ include "common.networking.dnsConfiguration" .Values | nindent 6 }}
       volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }}
       {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}