Skip to content

Commit 6c151f7

Browse files
author
Adriano Santos
committed
feat: share protobuf files between containers
1 parent 8d4aecd commit 6c151f7

File tree

5 files changed

+21
-42
lines changed

5 files changed

+21
-42
lines changed

examples/simple/host-simple.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ metadata:
1717
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:24h # Mandatory
20+
image: ttl.sh/spawn-java-example:48h # Mandatory
2121
ports:
2222
- name: http
2323
containerPort: 8090

spawn_operator/spawn_operator/lib/spawn_operator.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ defmodule SpawnOperator do
9191
actors_global_backpressure_min_demand:
9292
Map.get(annotations, "spawn-eigr.io/actors-global-backpressure-min-demand", "-1"),
9393
actors_global_backpressure_enabled:
94-
Map.get(annotations, "spawn-eigr.io/actors-global-backpressure-enabled", "true")
94+
Map.get(annotations, "spawn-eigr.io/actors-global-backpressure-enabled", "true"),
95+
grpc_include_protos_path: Map.get(annotations, "spawn-eigr.io/grpc-include-protos-path", "/shared/protos"),
9596
}
9697
end
9798
end

spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/configmap/sidecar_configmap.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ defmodule SpawnOperator.K8s.Proxy.CM.Configmap do
159159
annotations.actors_global_backpressure_max_demand,
160160
"ACTORS_GLOBAL_BACKPRESSURE_MIN_DEMAND" =>
161161
annotations.actors_global_backpressure_min_demand,
162-
"ACTORS_GLOBAL_BACKPRESSURE_ENABLED" => annotations.actors_global_backpressure_enabled
162+
"ACTORS_GLOBAL_BACKPRESSURE_ENABLED" => annotations.actors_global_backpressure_enabled,
163+
"PROXY_GRPC_INCLUDE_PROTOS_PATH" => annotations.grpc_include_protos_path,
163164
}
164165
}
165166
end

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

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

65+
@proto_volume %{
66+
"name" => "shared-volume",
67+
"emptyDir" => %{}
68+
}
69+
70+
6571
@default_certs_volume %{
6672
"name" => "certs",
6773
"secret" => %{"secretName" => "tls-certs", "optional" => true}
6874
}
6975

7076
@default_volumes [
71-
@default_certs_volume
72-
]
73-
74-
@proto_volume_mounts [
75-
%{"name" => "proto-volume", "mountPath" => "/actors"}
77+
@default_certs_volume,
78+
@proto_volume
7679
]
7780

7881
@default_certs_volume_mounts %{"name" => "certs", "mountPath" => "/app/certs"}
7982

83+
@default_proto_volume_mounts %{"name" => "shared-volume", "mountPath" => "/shared"}
84+
8085
@default_volume_mounts [
81-
@default_certs_volume_mounts
86+
@default_certs_volume_mounts,
87+
@default_proto_volume_mounts
8288
]
8389

8490
@default_termination_period_seconds 405
@@ -436,48 +442,21 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
436442
Map.put(spec, "terminationGracePeriodSeconds", @default_termination_period_seconds)
437443
end
438444

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-
445+
defp maybe_put_volumes(spec, %{"volumes" => volumes} = _params) do
453446
volumes =
454447
(volumes ++
455448
@default_volumes)
456-
|> Kernel.++(proto_volume_mounts)
457449
|> List.flatten()
458450
|> Enum.uniq(& &1["name"])
459451

460452
Map.merge(spec, %{"volumes" => volumes})
461453
end
462454

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-
455+
defp maybe_put_volumes(spec, _params) do
477456
volumes =
478457
@default_volumes
479-
|> Kernel.++(proto_volume_mounts)
480458
|> List.flatten()
459+
|> Enum.uniq(& &1["name"])
481460

482461
Map.put(spec, "volumes", volumes)
483462
end
@@ -505,7 +484,6 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
505484
volumeMounts =
506485
volumeMounts
507486
|> Kernel.++(@default_volume_mounts)
508-
|> Kernel.++(@proto_volume_mounts)
509487
|> List.flatten()
510488
|> Enum.uniq(& &1["name"])
511489

@@ -515,7 +493,6 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
515493
defp maybe_put_volume_mounts_to_host_container(spec, _, :sidecar) do
516494
volumeMounts =
517495
@default_volume_mounts
518-
|> Kernel.++(@proto_volume_mounts)
519496
|> List.flatten()
520497
|> Enum.uniq(& &1["name"])
521498

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-eigr-spawn")
14+
{:ok, conn} = K8s.Conn.from_file("~/.kube/config", context: "minikube")
1515
struct!(conn, insecure_skip_tls_verify: true)
1616
end
1717

0 commit comments

Comments
 (0)