diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a2449ec5..eee59c95 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -96,13 +96,13 @@ jobs: elixir-version: ${{matrix.elixir}} # Define the elixir version [required] otp-version: ${{matrix.otp}} # Define the OTP version [required] - - uses: actions/cache@v1 + - uses: actions/cache@v4 id: deps-cache with: path: deps key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 id: build-cache with: path: _build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2ffbfdb5..1adc80ba 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,13 +25,13 @@ jobs: elixir-version: ${{matrix.elixir}} otp-version: ${{matrix.otp}} - - uses: actions/cache@v1 + - uses: actions/cache@v4 id: deps-cache with: path: deps key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 id: build-cache with: path: _build diff --git a/Makefile b/Makefile index eb010866..aeba973f 100644 --- a/Makefile +++ b/Makefile @@ -293,6 +293,25 @@ run-proxy-with-postgres: SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= \ iex --name spawn_a3@127.0.0.1 -S mix +run-proxy-with-mariadb: + cd spawn_proxy/proxy && mix deps.get && \ + OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4317 \ + OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc \ + OTEL_EXPORTER_OTLP_TRACES_COMPRESSION=gzip \ + SPAWN_PROXY_LOGGER_LEVEL=info \ + PROXY_CLUSTER_STRATEGY=epmd \ + SPAWN_USE_INTERNAL_NATS=false \ + SPAWN_PUBSUB_ADAPTER=native \ + PROXY_DATABASE_PORT=3307 \ + PROXY_DATABASE_TYPE=mariadb \ + PROXY_DATABASE_USERNAME=admin \ + PROXY_DATABASE_SECRET=admin \ + PROXY_DATABASE_POOL_SIZE=30 \ + PROXY_HTTP_PORT=9001 \ + USER_FUNCTION_PORT=8090 \ + SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= \ + iex --name spawn_a3@127.0.0.1 -S mix + run-proxy-local-nodejs-test: ERL_ZFLAGS='-proto_dist inet_tls -ssl_dist_optfile rel/overlays/local-mtls.ssl.conf' \ cd spawn_proxy/proxy && mix deps.get && \ diff --git a/spawn_operator/spawn_operator/lib/spawn_operator/handler/actor_system_handler.ex b/spawn_operator/spawn_operator/lib/spawn_operator/handler/actor_system_handler.ex index 0c100d99..9b5de66b 100644 --- a/spawn_operator/spawn_operator/lib/spawn_operator/handler/actor_system_handler.ex +++ b/spawn_operator/spawn_operator/lib/spawn_operator/handler/actor_system_handler.ex @@ -34,6 +34,8 @@ defmodule SpawnOperator.Handler.ActorSystemHandler do alias SpawnOperator.K8s.System.RoleBinding alias SpawnOperator.K8s.System.Secret.ActorSystemSecret alias SpawnOperator.K8s.System.ServiceAccount + alias SpawnOperator.K8s.System.EpmdDS + alias SpawnOperator.K8s.System.EpmdPolicy @behaviour Pluggable @@ -51,7 +53,9 @@ defmodule SpawnOperator.Handler.ActorSystemHandler do {:cluster_service, build_system_service(resource)}, {:service_account, build_service_account(resource)}, {:roles, build_role(resource)}, - {:role_binding, build_role_binding(resource)} + {:role_binding, build_role_binding(resource)}, + {:epmd_daemonset, build_epmd_daemonset(resource)}, + {:epmd_network_policy, build_epmd_network_policy(resource)} ] axn = @@ -135,4 +139,14 @@ defmodule SpawnOperator.Handler.ActorSystemHandler do SpawnOperator.get_args(resource) |> RoleBinding.manifest() end + + defp build_epmd_daemonset(resource) do + SpawnOperator.get_args(resource) + |> RoleBinding.manifest() + end + + defp build_epmd_network_policy(resource) do + SpawnOperator.get_args(resource) + |> RoleBinding.manifest() + end end diff --git a/spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/deployment.ex b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/deployment.ex index fb797f5e..5d1f693e 100644 --- a/spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/deployment.ex +++ b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/deployment.ex @@ -151,12 +151,12 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do "metadata" => %{ "name" => name, "namespace" => system, - "labels" => %{"app" => name, "actor-system" => system} + "labels" => %{"app" => name, "actor-system" => system, "operator" => "spawn-operator"} }, "spec" => %{ "replicas" => replicas, "selector" => %{ - "matchLabels" => %{"actor-system" => system} + "matchLabels" => %{"actor-system" => system, "operator" => "spawn-operator"} }, "strategy" => %{ "type" => "RollingUpdate", diff --git a/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_ds.ex b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_ds.ex new file mode 100644 index 00000000..4bf74edb --- /dev/null +++ b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_ds.ex @@ -0,0 +1,62 @@ +defmodule SpawnOperator.K8s.System.EpmdDS do + @moduledoc false + @behaviour SpawnOperator.K8s.Manifest + + @ports [ + %{"name" => "epmd", "containerPort" => 4369, "hostPort" => 4369, "protocol" => "TCP"} + ] + + @impl true + def manifest(%{labels: labels} = _resource, _opts \\ []) do + %{ + "apiVersion" => "apps/v1", + "kind" => "DaemonSet", + "metadata" => %{ + "name" => "spawn-epmd", + "namespace" => "eigr-functions", + "labels" => + Map.merge(labels, %{ + "app" => "spawn-epmd", + "spawn-eigr.io/controller.version" => "#{Application.spec(:spawn_operator, :vsn)}" + }) + }, + "spec" => %{ + "selector" => %{ + "matchLabels" => %{ + "app" => "epmd", + "epmd-cluster" => "spawn-epmd" + } + }, + "template" => %{ + "metadata" => %{ + "labels" => %{ + "app" => "epmd", + "epmd-cluster" => "spawn-epmd" + } + }, + "spec" => %{ + "hostNetwork" => true, + "containers" => [ + %{ + "name" => "epmd", + "image" => "erlang:26", + "command" => ["epmd", "-d", "-relaxed_command_check"], + "ports" => @ports, + "resources" => %{ + "limits" => %{ + "memory" => "10Mi", + "cpu" => "10m" + }, + "requests" => %{ + "memory" => "5Mi", + "cpu" => "5m" + } + } + } + ] + } + } + } + } + end +end diff --git a/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_policy.ex b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_policy.ex new file mode 100644 index 00000000..5188e1ff --- /dev/null +++ b/spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/epmd_policy.ex @@ -0,0 +1,50 @@ +defmodule SpawnOperator.K8s.System.EpmdPolicy do + @moduledoc false + @behaviour SpawnOperator.K8s.Manifest + + @port 4369 + + @impl true + def manifest(%{labels: labels} = _resource, _opts \\ []) do + %{ + "apiVersion" => "networking.k8s.io/v1", + "kind" => "NetworkPolicy", + "metadata" => %{ + "name" => "spawn-epmd-policy", + "namespace" => "eigr-functions", + "labels" => + Map.merge(labels, %{ + "spawn-eigr.io/controller.version" => "#{Application.spec(:spawn_operator, :vsn)}" + }) + }, + "spec" => %{ + "podSelector" => %{ + "matchLabels" => %{ + "app" => "epmd", + "epmd-cluster" => "spawn-epmd" + } + }, + "policyTypes" => ["Ingress"], + "ingress" => [ + %{ + "from" => [ + %{ + "podSelector" => %{ + "matchLabels" => %{ + "operator" => "spawn-operator" + } + } + } + ], + "ports" => [ + %{ + "protocol" => "TCP", + "port" => @port + } + ] + } + ] + } + } + end +end