Skip to content

Commit 1e03731

Browse files
authored
Merge pull request #2078 from hexlet-codebattle/runner-namespace-customisation
add config for kubernetes namespace
2 parents ff31aaf + 02f98d0 commit 1e03731

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

k8s/timoni/codebattle/templates/deployment.cue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import (
4747
}, {
4848
name: "CODEBATTLE_VERSION"
4949
value: #config.image.codebattle.tag
50+
}, {
51+
name: "KUBERNETES_NAMESPACE"
52+
valueFrom: fieldRef: fieldPath: "metadata.namespace"
5053
}]
5154
}, {
5255
name: "nginx"

services/app/apps/codebattle/lib/codebattle/code_check/executor/remote_rust.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,8 @@ defmodule Codebattle.CodeCheck.Executor.RemoteRust do
100100
end
101101

102102
# defp runner_url(_lang), do: "http://localhost:4002/run"
103-
defp runner_url(lang), do: "http://runner-#{lang}.default.svc/run"
103+
defp runner_url(lang) do
104+
namespace = Application.get_env(:codebattle, :k8s_namespace, "default")
105+
"http://runner-#{lang}.#{namespace}.svc/run"
106+
end
104107
end

services/app/config/config.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ config :codebattle,
123123
config :codebattle,
124124
jitsi_api_key: System.get_env("JITSI_API_KEY", "")
125125

126+
config :codebattle, k8s_namespace: System.get_env("KUBERNETES_NAMESPACE", "default")
127+
126128
config :runner, :runner_url, "http://localhost:4001"
127129
config :runner, load_dot_env_file: true
128130
config :runner, pull_docker_images: false

0 commit comments

Comments
 (0)