Skip to content

Make it easy to deploy on aws #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/defguard-gateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: defguard-gateway
description: Defguard gateway is a public-facing VPN endpoint.

type: application
version: 0.1.4
version: 0.2.0
appVersion: 1.3.0
2 changes: 2 additions & 0 deletions charts/defguard-gateway/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ data:
DEFGUARD_GRPC_URL: {{ .Values.grpcUrl | quote }}
DEFGUARD_STATS_PERIOD: {{ .Values.statsPeriod | quote }}
RUST_LOG: {{ .Values.logLevel | quote }}
PRE_UP: "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that necessary? Can we guarantee the network interface will always be eth0 for all users of this chart? Maybe it should be wrapped in AWS-only condition?

PRE_DOWN: "iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE"
16 changes: 16 additions & 0 deletions charts/defguard-gateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ spec:
- name: grpc
containerPort: {{ .Values.service.ports.grpc }}
protocol: UDP
- name: wireguard # make it explicit
containerPort: {{ .Values.service.ports.wireguard }}
protocol: UDP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.token }}
Expand All @@ -56,6 +59,19 @@ spec:
name: {{ .Values.existingTokenSecret }}
key: {{ .Values.existingTokenSecretKey }}
{{- end }}
# used to keep nlb happy to do health checks at port 80.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be AWS-related only. Should be wrapped in a condition.

# Alternatively, we could add this command to the Dockerfile
- name: tcp-healthcheck
image: alpine/socat:latest
imagePullPolicy: IfNotPresent
command:
- socat
- "TCP-LISTEN:80,reuseaddr,fork"
- "SYSTEM:true"
ports:
- name: health
containerPort: 80
protocol: TCP
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
32 changes: 32 additions & 0 deletions charts/defguard-gateway/templates/wireguard-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ if eq .Values.cloudProvider "aws" }}

apiVersion: v1
kind: Service
metadata:
# service creates an aws NLB which exposes
annotations:
# Force the NLB’s health check to use TCP:443 (or 80, or any open TCP port)
service.beta.kubernetes.io/aws-load-balancer-healthcheck-protocol: "TCP"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-port: "80"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-interval: "10"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-timeout: "5"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-healthy-threshold: "2"
service.beta.kubernetes.io/aws-load-balancer-healthcheck-unhealthy-threshold: "2"
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"
service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing"
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
name: {{ include "defguard-gateway.fullname" . }}-wireguard
labels:
{{- include "defguard-gateway.labels" . | nindent 4 }}
spec:
type: LoadBalancer
externalTrafficPolicy: Local
ports:
- port: {{ .Values.service.ports.wireguard }}
targetPort: wireguard
protocol: UDP
name: wireguard
selector:
{{- include "defguard-gateway.selectorLabels" . | nindent 4 }}

{{ end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing LineFeed (LF) characted at the end of the file

18 changes: 16 additions & 2 deletions charts/defguard-gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,32 @@ podLabels: {}
# defguard-gateway pod replica count
replicaCount: 1
# defguard-gateway pod resources
resources: {}
resources:
requests:
cpu: 50m
memory: 50Mi
limits:
cpu: 500m
memory: 500Mi
# defguard-gateway pod security context
podSecurityContext: {}
# defguard-gateway container security context
securityContext: {}
securityContext:
privileged: false
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: [ "ALL" ]
add: [ "NET_ADMIN" ] # wireguard fails to start without this as it's not able to create interfaces
# defguard-gateway pod additional ENV from configmap
additionalEnvFromConfigMap: ""
# defguard-gateway service configuration
service:
ports:
grpc: 50051
wireguard: 51820 # wireguard listening port
type: ClusterIP
cloudProvider: aws
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be the default value.

# defguard-gateway serviceaccount configuration
serviceAccount:
annotations: {}
Expand Down