|
| 1 | +# kics-scan ignore |
| 2 | +--- |
| 3 | +apiVersion: batch/v1 |
| 4 | +kind: Job |
| 5 | +metadata: |
| 6 | + name: wireguard-client-test |
| 7 | + namespace: {{ .Release.Namespace }} |
| 8 | + annotations: |
| 9 | + helm.sh/hook: test |
| 10 | +spec: |
| 11 | + template: |
| 12 | + spec: |
| 13 | + automountServiceAccountToken: false |
| 14 | + initContainers: |
| 15 | + - name: sysctls |
| 16 | + image: busybox:stable |
| 17 | + command: |
| 18 | + - sh |
| 19 | + - -c |
| 20 | + - sysctl -w net.ipv4.ip_forward=1 && sysctl -w net.ipv4.conf.all.forwarding=1 |
| 21 | + securityContext: |
| 22 | + runAsNonRoot: false |
| 23 | + privileged: true |
| 24 | + resources: |
| 25 | + requests: |
| 26 | + memory: 64Mi |
| 27 | + cpu: "100m" |
| 28 | + limits: |
| 29 | + memory: 64Mi |
| 30 | + cpu: "100m" |
| 31 | + containers: |
| 32 | + - name: wireguard-client |
| 33 | + image: ghcr.io/bryopsida/wireguard:main |
| 34 | + securityContext: |
| 35 | + runAsNonRoot: {{ .Values.securityContext.runAsNonRoot | default true }} |
| 36 | + runAsUser: {{ .Values.securityContext.runAsUser | default 1000 }} |
| 37 | + readOnlyRootFilesystem: {{ .Values.securityContext.readOnlyRootFilesystem | default true }} |
| 38 | + allowPrivilegeEscalation: {{ .Values.securityContext.allowPrivilegeEscalation | default true }} |
| 39 | + privileged: {{ .Values.securityContext.privileged | default false }} |
| 40 | + capabilities: |
| 41 | + drop: |
| 42 | + - ALL |
| 43 | + add: |
| 44 | + - NET_ADMIN |
| 45 | + - NET_RAW |
| 46 | + - SETUID |
| 47 | + - SETGID |
| 48 | + env: |
| 49 | + - name: WG_PRIVATE_KEY |
| 50 | + value: "gILClOGWPR+w9q4f0A7hlTKdQHC0vHwXPrGLHPKJi2o=" |
| 51 | + - name: WG_SERVER |
| 52 | + value: "{{ .Release.Name }}-wireguard.{{ .Release.Namespace }}.svc" |
| 53 | + - name: WG_SERVER_PORT |
| 54 | + value: "{{ .Values.service.port }}" |
| 55 | + - name: WG_SERVER_CIDR |
| 56 | + value: "{{ .Values.wireguard.serverCidr }}" |
| 57 | + - name: WG_CLIENT_IP |
| 58 | + value: "172.32.32.2/32" |
| 59 | + resources: |
| 60 | + requests: |
| 61 | + cpu: "100m" |
| 62 | + memory: "128Mi" |
| 63 | + limits: |
| 64 | + cpu: "500m" |
| 65 | + memory: "256Mi" |
| 66 | + command: |
| 67 | + - /bin/sh |
| 68 | + args: |
| 69 | + - -c |
| 70 | + - | |
| 71 | + set -e |
| 72 | + |
| 73 | + cat <<EOF > /tmp/wg0.conf |
| 74 | + [Interface] |
| 75 | + PrivateKey = ${WG_PRIVATE_KEY} |
| 76 | + Address = ${WG_CLIENT_IP} |
| 77 | +
|
| 78 | + [Peer] |
| 79 | + PublicKey = $(cat /etc/wireguard-server/privatekey | wg pubkey) |
| 80 | + Endpoint = ${WG_SERVER}:${WG_SERVER_PORT} |
| 81 | + AllowedIPs = ${WG_SERVER_CIDR} |
| 82 | + EOF |
| 83 | +
|
| 84 | + wg-quick up /tmp/wg0.conf |
| 85 | + sleep 5 |
| 86 | + sudo ping -c 1 -W 1 172.32.32.1 |
| 87 | + volumeMounts: |
| 88 | + - name: wireguard-server-secret |
| 89 | + mountPath: /etc/wireguard-server/ |
| 90 | + readOnly: true |
| 91 | + - name: tmp-volume |
| 92 | + mountPath: /tmp |
| 93 | + volumes: |
| 94 | + - name: wireguard-server-secret |
| 95 | + secret: |
| 96 | + secretName: {{ .Release.Name }}-wg-generated |
| 97 | + - name: tmp-volume |
| 98 | + emptyDir: {} |
| 99 | + restartPolicy: Never |
| 100 | + backoffLimit: 4 |
0 commit comments