1234567891011121314151617181920 |
- apiVersion: v1
- kind: ConfigMap
- metadata:
- name: {{ include "openvpn.fullname" . }}-routecheck
- data:
- route.sh: |
- while sleep 60
- do
- /sbin/ip link list {{ .Values.dev_name }} > /dev/null 2>&1
- if [ $? -ne 0 ]; then
- __server_pod_ip=$(kubectl get po -o json | jq -r '.items[] | select(.metadata.labels.component=="application") | select(.status.phase=="Running").status.podIP')
- __route_ip=$(ip route get {{ .Values.net }} | awk '{print $3}')
- if [[ $__server_pod_ip != $__route_ip ]]; then
- ip route delete {{ .Values.net }}/$(mask2cdr {{ .Values.mask }}) > /dev/null 2>&1
- ip route add {{ .Values.net }}/$(mask2cdr {{ .Values.mask }}) via $__server_pod_ip
- fi
- fi
- done
- finish.sh: |
- ip route delete {{ .Values.net }}/$(mask2cdr {{ .Values.mask }}) > /dev/null 2>&1
|