commit 7a994325570cc9be5ddc2f6503d0bd745bbcc3b3
parent e6bf165ec18ef3ae0bda4dc7ecc4b2675e8d89d6
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 5 Sep 2023 11:43:47 +0200
Add envoy
Diffstat:
2 files changed, 111 insertions(+), 1 deletion(-)
diff --git a/nixos/common/lib/envoy.nix b/nixos/common/lib/envoy.nix
@@ -0,0 +1,109 @@
+{ lib, pkgs, config, ... }:
+{
+ services = {
+ envoy = {
+ enable = true;
+ settings = {
+ static_resources = {
+ admin = {
+ access_log_path = "/dev/null";
+ address = {
+ socket_address = {
+ protocol = "TCP";
+ address = "127.0.0.1";
+ port_value = "9901";
+ };
+ };
+ };
+ listeners = [
+ {
+ name = "postgres";
+ address = {
+ socket_address = {
+ address = "10.100.12.1";
+ port_value = 5000;
+ };
+ };
+ filter_chains = [
+ {
+ filters = [
+ {
+ name = "envoy.filters.network.postgres_proxy";
+ typed_config = {
+ "@type" = "type.googleapis.com/envoy.extensions.filters.network.postgres_proxy.v3alpha.PostgresProxy";
+ stat_prefix = "destination";
+ };
+ }
+ {
+ name = "envoy.filters.network.tcp_proxy";
+ typed_config = {
+ "@type" = "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy";
+ stat_prefix = "destination";
+ cluster = "postgres_cluster";
+ };
+ }
+ ];
+ }
+ ];
+ }
+ ];
+ clusters = [
+ {
+ name = "postgres_cluster";
+ connect_timeout = "0.5s";
+ type = "STRICT_DNS";
+ lb_policy = "LEAST_REQUEST";
+ load_assignment = {
+ cluster_name = "postgres_cluster";
+ endpoints = [
+ {
+ lb_endpoints = [
+ {
+ endpoint = {
+ health_check_config = {
+ port_value = 8008;
+ };
+ address = {
+ socket_address = {
+ address = "10.100.0.2";
+ port_value = 5432;
+ };
+ };
+ };
+ }
+ {
+ endpoint = {
+ health_check_config = {
+ port_value = 8008;
+ };
+ address = {
+ socket_address = {
+ address = "10.100.0.1";
+ port_value = 5432;
+ };
+ };
+ };
+ }
+ ];
+ }
+ ];
+ };
+ health_checks = [
+ {
+ timeout = "1s";
+ interval = "5s";
+ unhealthy_threshold = 3;
+ healthy_threshold = 2;
+ http_health_check = {
+ path = "/";
+ port = 8008;
+ };
+ }
+ ];
+ }
+ ];
+ };
+ };
+ };
+ };
+}
diff --git a/nixos/worker-1/configuration.nix b/nixos/worker-1/configuration.nix
@@ -26,6 +26,7 @@
./boot.nix
../common/lib/shell.nix
+ ../common/lib/envoy.nix
../common/lib/fail2ban.nix
../common/lib/podman.nix
../common/lib/asterisk.nix
@@ -364,7 +365,7 @@
};
haproxy = {
- enable = true;
+ enable = false;
config = ''
global
maxconn 300