Skip to content

[Feat] EPMD as Daemonset #434

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 4 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,25 @@ run-proxy-with-postgres:
SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= \
iex --name [email protected] -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 [email protected] -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 && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 =
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading