Skip to content

Commit

Permalink
fix: correct the postinstall script to disable running dns server and…
Browse files Browse the repository at this point in the history
… update k8s script to use daemon set
  • Loading branch information
benjivesterby committed Apr 21, 2023
1 parent 5ff144e commit 450fbfb
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 51 deletions.
121 changes: 121 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Void DNS Sink Hole and local DNS Resolver Config File
#
# This file is used to configure the Void DNS Sink Hole and local DNS Resolver.
# The configuration file can be in YAML, JSON, or TOML format, named config
# with the appropriate extension.
#
# The configuration file is loaded from the following locations, in order:
# - /etc/void/config.yaml
# - $HOME/.void/config.yaml
# - ./config.yaml
#
# The configuration file can be overridden with the --config flag.
#
# There are three types of dns entries:
# - local: A list of local domains that will be resolved by Void.
# - allow: A list of domains that will be resolved upstream, bypassing
# Void's DNS sink hole.
# - block: A list of domains that will be blocked by Void's DNS sink hole.
#
# DNS resolution is performed in the following order:
#
# 1. If the domain is in the local list, resolve the domain locally.
# 2. If the domain is in the allow list, resolve the domain upstream.
# 3. If the domain is in the block list, return empty response.
#
# Void supports local and remote lists, or lists of lists.
#
# Lists can be regular expressions, wildcard domains, or exact domains. They
# can also be lists that point to other lists (requires additional config, see
# below) that contain regex, wildcard, or exact domains. Direct lists do not
# require the `format` to be specified, but regex and wildcard lists do.
#
# NOTE: The file extension is not used to determine the format of the list,
# it is the `format` field that determines the format of the list.
#
# Direct List Example
# - path: "/etc/void/local.hosts"
#
# Regex List Example
# - path: "/etc/void/hosts.regex"
# format: regex
#
# Wildcard List Example
# - path: "/etc/void/hosts.wild"
# format: wildcard
#
# List of Lists Example
# - path: "/etc/void/hosts.lists"
# lists: true
# format: direct # Optional, defaults to direct if not specified
#
#
# Void understands lists in hostfile format, or line delimited format.
#
# Void supports either local or remote files (urls beginning with http:// or
# https://). Remote files are cached locally in the configured cache directory.
#
# Defaults
# -------
# The default configuration is:
#
# Port: 53
#
# Upstream is Cloudflare TLS encrypted DNS:
# - tcp-tls://1.1.1.1:853
# - tcp-tls://1.0.0.1:853
#
#
# Cache: /etc/void/cache

# Logger configures the log location and log rotation settings.
#
# Uses configuration from https://github.com/natefinch/lumberjack/tree/v2.0
logger:
filename: "/var/log/void/void.log"
maxage: 30
# maxsize: 100 # MB
# maxbackups: 10
# localtime: false
compress: true

verbose: true

dns:
#port: 53 # default
#upstream: [ # default
# "tcp-tls://1.1.1.1:853",
# "tcp-tls://1.0.0.1:853",
#]
local:
- path: "/etc/void/local.hosts"
format: direct
- path: "/etc/void/local.wild"
format: wildcard
allow:
- path: "/etc/void/custom_allow.hosts"
format: direct
- path: https://raw.githubusercontent.com/mmotti/pihole-regex/master/whitelist.list
format: direct
- path: https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt
format: direct
- path: https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/optional-list.txt
format: direct
block:
- path: https://v.firebog.net/hosts/lists.php?type=nocross
lists: true
format: direct
- path: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
format: direct
- path: https://raw.githubusercontent.com/mmotti/pihole-regex/master/regex.list
format: regex
- path: https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt
format: direct
- path: https://www.github.developerdan.com/hosts/lists/amp-hosts-extended.txt
format: direct
- path: https://www.github.developerdan.com/hosts/lists/dating-services-extended.txt
format: direct
- path: https://www.github.developerdan.com/hosts/lists/hate-and-junk-extended.txt
format: direct
- path: https://www.github.developerdan.com/hosts/lists/tracking-aggressive-extended.txt
format: direct
53 changes: 14 additions & 39 deletions deployment/k8s/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apiVersion: apps/v1
kind: Deployment
kind: DaemonSet
metadata:
name: void-deployment
name: void-daemonset
spec:
replicas: 3
selector:
matchLabels:
app: void
Expand All @@ -12,43 +11,19 @@ spec:
labels:
app: void
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: void-container
image: ghcr.io/devnw/void:v0.0.10-beta2
image: ghcr.io/devnw/void:latest
ports:
- containerPort: 53
resources:
limits:
cpu: 500m
requests:
cpu: 250m

---

apiVersion: v1
kind: Service
metadata:
name: void-loadbalancer
spec:
selector:
app: void
ports:
- protocol: UDP
port: 53
targetPort: 53
type: LoadBalancer

---

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: void-autoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: void-deployment
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 80
protocol: UDP
volumeMounts:
- name: void-storage
mountPath: /etc/void
volumes:
- name: void-storage
hostPath:
path: /etc/void
type: DirectoryOrCreate
30 changes: 18 additions & 12 deletions deployment/scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ set -e

configure()
{
systemctl enable void.service
# Set DNSStubListener=no in /etc/systemd/resolved.conf
sed -i 's/#DNSStubListener=yes/DNSStubListener=no/' /etc/systemd/resolved.conf

systemctl daemon-reload
# Restart the systemd-resolved service
systemctl restart systemd-resolved

systemctl start void.service
systemctl enable void.service

systemctl daemon-reload

systemctl start void.service
}

case $1 in
configure)
configure
;;
configure)
configure
;;

abort-upgrade)
;;
abort-upgrade)
;;

abort-remove)
;;
abort-remove)
;;

abort-deconfigure)
;;
abort-deconfigure)
;;
esac

0 comments on commit 450fbfb

Please sign in to comment.