Skip to content

Commit dfdb72e

Browse files
author
Adriano Santos
committed
feat: use volume image to load protobuf files
1 parent a47cfe9 commit dfdb72e

File tree

6 files changed

+197
-136
lines changed

6 files changed

+197
-136
lines changed

examples/simple/host-simple.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ metadata:
1414
# Optional. Here I`m using Nats Broker without authentication
1515
spawn-eigr.io/sidecar-pubsub-adapter: "nats"
1616
spawn-eigr.io/sidecar-pubsub-nats-hosts: "nats://spawn-nats:4222"
17-
spawn-eigr.io/sidecar-image-tag: "ghcr.io/eigr/spawn-proxy:2.0.0-RC2"
17+
spawn-eigr.io/sidecar-image-tag: "ghcr.io/eigr/spawn-proxy:1.4.3"
1818
spec:
1919
host:
20-
image: ttl.sh/spawn-java-example:1h # Mandatory
20+
image: ttl.sh/spawn-java-example:24h # Mandatory
2121
ports:
2222
- name: http
2323
containerPort: 8090

kind-cluster-config.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
name: eigr-spawn
4+
featureGates:
5+
ImageVolume: true
36
nodes:
47
- role: control-plane
8+
image: kindest/node:v1.31.4@sha256:2cb39f7295fe7eafee0842b1052a599a4fb0f8bcf3f83d96c7f4864c357c6c30
59
- role: worker
6-
- role: worker
7-
- role: worker
10+
image: kindest/node:v1.31.4@sha256:2cb39f7295fe7eafee0842b1052a599a4fb0f8bcf3f83d96c7f4864c357c6c30

mix.lock

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
%{
22
"acceptor_pool": {:hex, :acceptor_pool, "1.0.0", "43c20d2acae35f0c2bcd64f9d2bde267e459f0f3fd23dab26485bf518c281b21", [:rebar3], [], "hexpm", "0cbcd83fdc8b9ad2eee2067ef8b91a14858a5883cb7cd800e6fcd5803e158788"},
3+
"bakeware": {:hex, :bakeware, "0.2.4", "0aaf49b34f4bab2aa433f9ff1485d9401e421603160abd6d269c469fc7b65212", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "7b97bcf6fbeee53bb32441d6c495bf478d26f9575633cfef6831e421e86ada6d"},
4+
"bandit": {:hex, :bandit, "1.5.3", "c7ee44871da696371a5674dd2c2062e974a18cd787732efcf50cc70b98c78fdc", [:mix], [{:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "3812ed5e48c1f1e3109edb5c463c6f8aaf25ecfac2826606be3e5237550116ef"},
35
"broadway": {:hex, :broadway, "1.1.0", "8ed3aea01fd6f5640b3e1515b90eca51c4fc1fac15fb954cdcf75dc054ae719c", [:mix], [{:gen_stage, "~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.7 or ~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25e315ef1afe823129485d981dcc6d9b221cea30e625fd5439e9b05f44fb60e4"},
46
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
57
"castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"},
@@ -21,6 +23,7 @@
2123
"ecto": {:hex, :ecto, "3.12.5", "4a312960ce612e17337e7cefcf9be45b95a3be6b36b6f94dfb3d8c361d631866", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6eb18e80bef8bb57e17f5a7f068a1719fbda384d40fc37acb8eb8aeca493b6ea"},
2224
"ecto_sql": {:hex, :ecto_sql, "3.12.1", "c0d0d60e85d9ff4631f12bafa454bc392ce8b9ec83531a412c12a0d415a3a4d0", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aff5b958a899762c5f09028c847569f7dfb9cc9d63bdb8133bff8a5546de6bf5"},
2325
"ed25519": {:hex, :ed25519, "1.4.1", "479fb83c3e31987c9cad780e6aeb8f2015fb5a482618cdf2a825c9aff809afc4", [:mix], [], "hexpm", "0dacb84f3faa3d8148e81019ca35f9d8dcee13232c32c9db5c2fb8ff48c80ec7"},
26+
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
2427
"equivalex": {:hex, :equivalex, "1.0.3", "170d9a82ae066e0020dfe1cf7811381669565922eb3359f6c91d7e9a1124ff74", [:mix], [], "hexpm", "46fa311adb855117d36e461b9c0ad2598f72110ad17ad73d7533c78020e045fc"},
2528
"ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"},
2629
"file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"},
@@ -62,6 +65,7 @@
6265
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
6366
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
6467
"nkeys": {:hex, :nkeys, "0.3.0", "837add5261a3cdd8ff75b54e0475062313093929ab5e042fa48e010f33b10d16", [:mix], [{:ed25519, "~> 1.3", [hex: :ed25519, repo: "hexpm", optional: false]}, {:kcl, "~> 1.4", [hex: :kcl, repo: "hexpm", optional: false]}], "hexpm", "b5af773a296620ee8eeb1ec6dc5b68f716386f7e53f7bda8c4ac23515823dfe4"},
68+
"observer_cli": {:hex, :observer_cli, "1.8.1", "edfe0c0f983631961599326f239f6e99750aba7387515002b1284dcfe7fcd6d2", [:mix, :rebar3], [{:recon, "~> 2.5.6", [hex: :recon, repo: "hexpm", optional: false]}], "hexpm", "a3cd6300dd8290ade93d688fbd79c872e393b01256309dd7a653feb13c434fb4"},
6569
"opentelemetry": {:hex, :opentelemetry, "1.5.0", "7dda6551edfc3050ea4b0b40c0d2570423d6372b97e9c60793263ef62c53c3c2", [:rebar3], [{:opentelemetry_api, "~> 1.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "cdf4f51d17b592fc592b9a75f86a6f808c23044ba7cf7b9534debbcc5c23b0ee"},
6670
"opentelemetry_api": {:hex, :opentelemetry_api, "1.4.0", "63ca1742f92f00059298f478048dfb826f4b20d49534493d6919a0db39b6db04", [:mix, :rebar3], [], "hexpm", "3dfbbfaa2c2ed3121c5c483162836c4f9027def469c41578af5ef32589fcfc58"},
6771
"opentelemetry_ecto": {:hex, :opentelemetry_ecto, "1.2.0", "2382cb47ddc231f953d3b8263ed029d87fbf217915a1da82f49159d122b64865", [:mix], [{:opentelemetry_api, "~> 1.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:opentelemetry_process_propagator, "~> 0.2", [hex: :opentelemetry_process_propagator, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "70dfa2e79932e86f209df00e36c980b17a32f82d175f0068bf7ef9a96cf080cf"},
@@ -78,16 +82,20 @@
7882
"protobuf": {:hex, :protobuf, "0.13.0", "7a9d9aeb039f68a81717eb2efd6928fdf44f03d2c0dfdcedc7b560f5f5aae93d", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "21092a223e3c6c144c1a291ab082a7ead32821ba77073b72c68515aa51fef570"},
7983
"protobuf_generate": {:hex, :protobuf_generate, "0.1.3", "57841bc60e2135e190748119d83f78669ee7820c0ad6555ada3cd3cd7df93143", [:mix], [{:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "dae4139b00ba77a279251a0ceb5593b1bae745e333b4ce1ab7e81e8e4906016b"},
8084
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
85+
"recon": {:hex, :recon, "2.5.6", "9052588e83bfedfd9b72e1034532aee2a5369d9d9343b61aeb7fbce761010741", [:mix, :rebar3], [], "hexpm", "96c6799792d735cc0f0fd0f86267e9d351e63339cbe03df9d162010cefc26bb0"},
8186
"retry": {:hex, :retry, "0.18.0", "dc58ebe22c95aa00bc2459f9e0c5400e6005541cf8539925af0aa027dc860543", [:mix], [], "hexpm", "9483959cc7bf69c9e576d9dfb2b678b71c045d3e6f39ab7c9aa1489df4492d73"},
8287
"salsa20": {:hex, :salsa20, "1.0.4", "404cbea1fa8e68a41bcc834c0a2571ac175580fec01cc38cc70c0fb9ffc87e9b", [:mix], [], "hexpm", "745ddcd8cfa563ddb0fd61e7ce48d5146279a2cf7834e1da8441b369fdc58ac6"},
8388
"shards": {:hex, :shards, "1.1.1", "8b42323457d185b26b15d05187784ce6c5d1e181b35c46fca36c45f661defe02", [:make, :rebar3], [], "hexpm", "169a045dae6668cda15fbf86d31bf433d0dbbaec42c8c23ca4f8f2d405ea8eda"},
89+
"sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"},
8490
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
8591
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
8692
"telemetry_metrics": {:hex, :telemetry_metrics, "1.0.0", "29f5f84991ca98b8eb02fc208b2e6de7c95f8bb2294ef244a176675adc7775df", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f23713b3847286a534e005126d4c959ebcca68ae9582118ce436b521d1d47d5d"},
8793
"telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "1.2.1", "c9755987d7b959b557084e6990990cb96a50d6482c683fb9622a63837f3cd3d8", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "5e2c599da4983c4f88a33e9571f1458bf98b0cf6ba930f1dc3a6e8cf45d5afb6"},
8894
"telemetry_poller": {:hex, :telemetry_poller, "1.1.0", "58fa7c216257291caaf8d05678c8d01bd45f4bdbc1286838a28c4bb62ef32999", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9eb9d9cbfd81cbd7cdd24682f8711b6e2b691289a0de6826e58452f28c103c8f"},
95+
"thousand_island": {:hex, :thousand_island, "1.3.9", "095db3e2650819443e33237891271943fad3b7f9ba341073947581362582ab5a", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25ab4c07badadf7f87adb4ab414e0ed374e5f19e72503aa85132caa25776e54f"},
8996
"tls_certificate_check": {:hex, :tls_certificate_check, "1.25.0", "702b1835fe718a52310509537392abd067dbe941ebc05fe72409d2b2f8061651", [:rebar3], [{:ssl_verify_fun, "~> 1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "167343ccf50538cf2faf61a3f1460e749b3edf2ecef55516af2b5834362abcb1"},
9097
"uuid": {:hex, :uuid, "1.1.8", "e22fc04499de0de3ed1116b770c7737779f226ceefa0badb3592e64d5cfb4eb9", [:mix], [], "hexpm", "c790593b4c3b601f5dc2378baae7efaf5b3d73c4c6456ba85759905be792f2ac"},
98+
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
9199
"x509": {:hex, :x509, "0.8.10", "5d1ec6d5f4db31982f9dc34e6a1eebd631d04599e0b6c1c259f1dadd4495e11f", [:mix], [], "hexpm", "a191221665af28b9bdfff0c986ef55f80e126d8ce751bbdf6cefa846410140c0"},
92100
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
93101
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},

spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/deployment.ex

+80-38
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,24 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
6262
}
6363
}
6464

65-
@file_shared_volume %{
66-
"name" => "shared-volume",
67-
"emptyDir" => %{}
68-
}
69-
70-
@file_protos_volume %{
71-
"name" => "proto-volume",
72-
"emptyDir" => %{}
73-
}
74-
7565
@default_certs_volume %{
7666
"name" => "certs",
7767
"secret" => %{"secretName" => "tls-certs", "optional" => true}
7868
}
7969

8070
@default_volumes [
81-
@default_certs_volume,
82-
@file_shared_volume,
83-
@file_protos_volume
71+
@default_certs_volume
8472
]
85-
86-
@file_copy_volume_mounts [
87-
%{"name" => "shared-volume", "mountPath" => "/shared-volume"},
73+
74+
@proto_volume_mounts [
8875
%{"name" => "proto-volume", "mountPath" => "/actors"}
8976
]
9077

9178
@default_certs_volume_mounts %{"name" => "certs", "mountPath" => "/app/certs"}
9279

9380
@default_volume_mounts [
9481
@default_certs_volume_mounts
95-
96-
] ++ @file_copy_volume_mounts
82+
]
9783

9884
@default_termination_period_seconds 405
9985

@@ -185,16 +171,6 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
185171
"value" => "none"
186172
}
187173
]
188-
},
189-
%{
190-
"name" => "copy-proto-files",
191-
"image" => "alpine:3.20",
192-
"command" => ["/bin/sh", "-c"],
193-
"args" => [
194-
#"if [ -d /actors ]; then cp -r /actors/* /shared-volume/; else echo 'Source folder not found!' && exit 1; fi"
195-
"ls -ltra /"
196-
],
197-
"volumeMounts" => @default_volume_mounts
198174
}
199175
],
200176
"serviceAccountName" => "#{system}-sa"
@@ -312,7 +288,7 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
312288
"ports" => actor_host_function_ports,
313289
"resources" => actor_host_function_resources
314290
}
315-
|> maybe_put_volume_mounts_to_host_container(host_params)
291+
|> maybe_put_volume_mounts_to_host_container(host_params, :actorhost)
316292

317293
[
318294
host_and_proxy_container
@@ -399,7 +375,7 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
399375
}
400376
]
401377
}
402-
|> maybe_put_volume_mounts_to_host_container(host_params)
378+
|> maybe_put_volume_mounts_to_host_container(host_params, :sidecar)
403379

404380
host_container =
405381
%{
@@ -409,7 +385,7 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
409385
"resources" => actor_host_function_resources
410386
}
411387
|> maybe_put_ports_to_host_container(host_params)
412-
|> maybe_put_volume_mounts_to_host_container(host_params)
388+
|> maybe_put_volume_mounts_to_host_container(host_params, :actorhost)
413389

414390
[
415391
proxy_container,
@@ -460,26 +436,92 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
460436
Map.put(spec, "terminationGracePeriodSeconds", @default_termination_period_seconds)
461437
end
462438

463-
defp maybe_put_volumes(spec, %{"volumes" => volumes}) do
439+
defp maybe_put_volumes(spec, %{"volumes" => volumes} = params) do
440+
host_params = Map.get(params, "host")
441+
actor_host_function_image = Map.get(host_params, "image")
442+
443+
proto_volume_mounts = [
444+
%{
445+
"name" => "proto-volume",
446+
"image" => %{
447+
"reference" => actor_host_function_image,
448+
"pullPolicy" => "IfNotPresent"
449+
}
450+
}
451+
]
452+
464453
volumes =
465-
volumes ++ @default_volumes |> List.flatten() |> Enum.uniq(&(&1["name"]))
454+
(volumes ++
455+
@default_volumes)
456+
|> Kernel.++(proto_volume_mounts)
457+
|> List.flatten()
458+
|> Enum.uniq(& &1["name"])
466459

467460
Map.merge(spec, %{"volumes" => volumes})
468461
end
469462

470-
defp maybe_put_volumes(spec, _) do
471-
Map.put(spec, "volumes", @default_volumes)
463+
defp maybe_put_volumes(spec, params) do
464+
host_params = Map.get(params, "host")
465+
actor_host_function_image = Map.get(host_params, "image")
466+
467+
proto_volume_mounts = [
468+
%{
469+
"name" => "proto-volume",
470+
"image" => %{
471+
"reference" => actor_host_function_image,
472+
"pullPolicy" => "IfNotPresent"
473+
}
474+
}
475+
]
476+
477+
volumes =
478+
@default_volumes
479+
|> Kernel.++(proto_volume_mounts)
480+
|> List.flatten()
481+
482+
Map.put(spec, "volumes", volumes)
472483
end
473484

474-
defp maybe_put_volume_mounts_to_host_container(spec, %{"volumeMounts" => volumeMounts}) do
475-
volumeMounts = volumeMounts ++ @default_volume_mounts |> List.flatten() |> Enum.uniq(&(&1["name"]))
485+
defp maybe_put_volume_mounts_to_host_container(
486+
spec,
487+
%{"volumeMounts" => volumeMounts},
488+
:actorhost
489+
) do
490+
volumeMounts =
491+
(volumeMounts ++ @default_volume_mounts) |> List.flatten() |> Enum.uniq(& &1["name"])
492+
476493
Map.merge(spec, %{"volumeMounts" => volumeMounts})
477494
end
478495

479-
defp maybe_put_volume_mounts_to_host_container(spec, _) do
496+
defp maybe_put_volume_mounts_to_host_container(spec, _, :actorhost) do
480497
Map.put(spec, "volumeMounts", @default_volume_mounts)
481498
end
482499

500+
defp maybe_put_volume_mounts_to_host_container(
501+
spec,
502+
%{"volumeMounts" => volumeMounts},
503+
:sidecar
504+
) do
505+
volumeMounts =
506+
volumeMounts
507+
|> Kernel.++(@default_volume_mounts)
508+
|> Kernel.++(@proto_volume_mounts)
509+
|> List.flatten()
510+
|> Enum.uniq(& &1["name"])
511+
512+
Map.merge(spec, %{"volumeMounts" => volumeMounts})
513+
end
514+
515+
defp maybe_put_volume_mounts_to_host_container(spec, _, :sidecar) do
516+
volumeMounts =
517+
@default_volume_mounts
518+
|> Kernel.++(@proto_volume_mounts)
519+
|> List.flatten()
520+
|> Enum.uniq(& &1["name"])
521+
522+
Map.put(spec, "volumeMounts", volumeMounts)
523+
end
524+
483525
defp maybe_warn_wrong_volumes(params, host_params) do
484526
volumes = Map.get(params, "volumes", [])
485527

spawn_operator/spawn_operator/lib/spawn_operator/k8s_conn.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule SpawnOperator.K8sConn do
1111

1212
@spec get(atom()) :: K8s.Conn.t()
1313
def get(:dev) do
14-
{:ok, conn} = K8s.Conn.from_file("~/.kube/config", context: "k3d-k3d-eigr-spawn")
14+
{:ok, conn} = K8s.Conn.from_file("~/.kube/config", context: "k3d-eigr-spawn")
1515
struct!(conn, insecure_skip_tls_verify: true)
1616
end
1717

0 commit comments

Comments
 (0)