Skip to content

Commit bf053ec

Browse files
author
Adriano Santos
committed
feat: change controllers to cluster scoped
1 parent 0c52dec commit bf053ec

File tree

7 files changed

+106
-105
lines changed

7 files changed

+106
-105
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ defmodule SpawnOperator.K8s.Proxy.CM.Configmap do
116116
"apiVersion" => "v1",
117117
"kind" => "ConfigMap",
118118
"metadata" => %{
119-
"namespace" => ns,
119+
"namespace" => system,
120120
"name" => "#{name}-sidecar-cm"
121121
},
122122
"data" => %{

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
115115
"kind" => "Deployment",
116116
"metadata" => %{
117117
"name" => name,
118-
"namespace" => ns,
118+
"namespace" => system,
119119
"labels" => %{"app" => name, "actor-system" => system}
120120
},
121121
"spec" => %{
@@ -164,11 +164,11 @@ defmodule SpawnOperator.K8s.Proxy.Deployment do
164164
"--secret",
165165
"tls-certs",
166166
"--namespace",
167-
"#{ns}",
167+
"#{system}",
168168
"--service",
169169
"#{system}",
170170
"--to",
171-
"#{ns}"
171+
"#{system}"
172172
],
173173
"env" => [
174174
%{

spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/hpa.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ defmodule SpawnOperator.K8s.Proxy.HPA do
6262
"kind" => "HorizontalPodAutoscaler",
6363
"metadata" => %{
6464
"name" => name,
65-
"namespace" => ns,
65+
"namespace" => system,
6666
"labels" => %{"app" => name, "actor-system" => system}
6767
},
6868
"spec" => %{

spawn_operator/spawn_operator/lib/spawn_operator/k8s/proxy/service.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ defmodule SpawnOperator.K8s.Proxy.Service do
66
@impl true
77
def manifest(
88
%{
9-
system: _system,
10-
namespace: ns,
9+
system: system,
10+
namespace: _ns,
1111
name: name,
1212
params: params,
1313
labels: _labels,
@@ -65,7 +65,7 @@ defmodule SpawnOperator.K8s.Proxy.Service do
6565
"#{to_string(Application.spec(:spawn_operator, :vsn))}"
6666
},
6767
"name" => "#{name}",
68-
"namespace" => ns
68+
"namespace" => system
6969
},
7070
"spec" => %{
7171
"selector" => %{"app" => name},

spawn_operator/spawn_operator/lib/spawn_operator/k8s/system/secret/certmanager/certificate.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ defmodule SpawnOperator.K8s.System.Secret.CertManager.Certificate do
8585
end
8686

8787
defp build_certificate(system, ns, name, certmanager, opts) do
88-
dns_names = Keyword.get(opts, :dns_names, ["system-#{system}.svc.cluster.local"])
88+
dns_names = Keyword.get(opts, :dns_names, ["system-#{system}.#{system}.svc.cluster.local"])
8989
duration = Map.get(certmanager, "duration", @default_duration)
9090
group = Map.get(certmanager, "group", @default_group)
9191
issuer_kind = Map.get(certmanager, "kind", @default_issuer_kind)

spawn_operator/spawn_operator/lib/spawn_operator/operator.ex

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule SpawnOperator.Operator do
99
step(Bonny.Pluggable.ApplyStatus)
1010
step(Bonny.Pluggable.ApplyDescendants)
1111

12+
@impl true
1213
def crds() do
1314
[
1415
Bonny.API.CRD.new!(
@@ -49,11 +50,11 @@ defmodule SpawnOperator.Operator do
4950
def controllers(watch_namespace, _opts) do
5051
[
5152
%{
52-
query: K8s.Client.watch("spawn-eigr.io/v1", "Activator", namespace: watch_namespace),
53+
query: K8s.Client.watch("spawn-eigr.io/v1", "Activator"),
5354
controller: SpawnOperator.Controller.ActivatorController
5455
},
5556
%{
56-
query: K8s.Client.watch("spawn-eigr.io/v1", "ActorHost", namespace: watch_namespace),
57+
query: K8s.Client.watch("spawn-eigr.io/v1", "ActorHost"),
5758
controller: SpawnOperator.Controller.ActorHostController
5859
},
5960
%{

spawn_operator/spawn_operator/manifest.yaml

+94-94
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,90 @@
1-
# ---
2-
# metadata:
3-
# name: spawn-operator
4-
# labels:
5-
# k8s-app: spawn-operator
6-
# namespace: eigr-functions
7-
# spec:
8-
# template:
9-
# metadata:
10-
# labels:
11-
# k8s-app: spawn-operator
12-
# spec:
13-
# containers:
14-
# - env:
15-
# - name: MIX_ENV
16-
# value: prod
17-
# - name: BONNY_OPERATOR_NAME
18-
# value: spawn-operator
19-
# - name: BONNY_POD_NAME
20-
# valueFrom:
21-
# fieldRef:
22-
# fieldPath: metadata.name
23-
# - name: BONNY_POD_NAMESPACE
24-
# valueFrom:
25-
# fieldRef:
26-
# fieldPath: metadata.namespace
27-
# - name: BONNY_POD_IP
28-
# valueFrom:
29-
# fieldRef:
30-
# fieldPath: status.podIP
31-
# - name: BONNY_POD_SERVICE_ACCOUNT
32-
# valueFrom:
33-
# fieldRef:
34-
# fieldPath: spec.serviceAccountName
35-
# name: spawn-operator
36-
# ports:
37-
# - containerPort: 9090
38-
# image: ghcr.io/eigr/spawn-operator:2.0.0-RC4
39-
# resources:
40-
# limits:
41-
# cpu: 200m
42-
# memory: 380Mi
43-
# requests:
44-
# cpu: 200m
45-
# memory: 380Mi
46-
# securityContext:
47-
# runAsNonRoot: false
48-
# allowPrivilegeEscalation: false
49-
# readOnlyRootFilesystem: true
50-
# volumeMounts:
51-
# - mountPath: /app/.cache/bakeware/
52-
# name: bakeware-cache
53-
# livenessProbe:
54-
# failureThreshold: 3
55-
# httpGet:
56-
# path: /health/liveness
57-
# port: 9090
58-
# scheme: HTTP
59-
# initialDelaySeconds: 30
60-
# periodSeconds: 5
61-
# successThreshold: 1
62-
# timeoutSeconds: 5
63-
# readinessProbe:
64-
# failureThreshold: 3
65-
# httpGet:
66-
# path: /health/readiness
67-
# port: 9090
68-
# scheme: HTTP
69-
# initialDelaySeconds: 30
70-
# periodSeconds: 5
71-
# successThreshold: 1
72-
# timeoutSeconds: 5
73-
# volumes:
74-
# - emptyDir: {}
75-
# name: bakeware-cache
76-
# serviceAccountName: spawn-operator
77-
# selector:
78-
# matchLabels:
79-
# k8s-app: spawn-operator
80-
# replicas: 2
81-
# kind: Deployment
82-
# apiVersion: apps/v1
1+
---
2+
metadata:
3+
name: spawn-operator
4+
labels:
5+
k8s-app: spawn-operator
6+
namespace: eigr-functions
7+
spec:
8+
template:
9+
metadata:
10+
labels:
11+
k8s-app: spawn-operator
12+
spec:
13+
containers:
14+
- env:
15+
- name: MIX_ENV
16+
value: prod
17+
- name: BONNY_OPERATOR_NAME
18+
value: spawn-operator
19+
- name: BONNY_POD_NAME
20+
valueFrom:
21+
fieldRef:
22+
fieldPath: metadata.name
23+
- name: BONNY_POD_NAMESPACE
24+
valueFrom:
25+
fieldRef:
26+
fieldPath: metadata.namespace
27+
- name: BONNY_POD_IP
28+
valueFrom:
29+
fieldRef:
30+
fieldPath: status.podIP
31+
- name: BONNY_POD_SERVICE_ACCOUNT
32+
valueFrom:
33+
fieldRef:
34+
fieldPath: spec.serviceAccountName
35+
name: spawn-operator
36+
ports:
37+
- containerPort: 9090
38+
image: ghcr.io/eigr/spawn-operator:2.0.0-RC5
39+
resources:
40+
limits:
41+
cpu: 200m
42+
memory: 380Mi
43+
requests:
44+
cpu: 200m
45+
memory: 380Mi
46+
securityContext:
47+
runAsNonRoot: false
48+
allowPrivilegeEscalation: false
49+
readOnlyRootFilesystem: true
50+
volumeMounts:
51+
- mountPath: /app/.cache/bakeware/
52+
name: bakeware-cache
53+
livenessProbe:
54+
failureThreshold: 3
55+
httpGet:
56+
path: /health/liveness
57+
port: 9090
58+
scheme: HTTP
59+
initialDelaySeconds: 30
60+
periodSeconds: 5
61+
successThreshold: 1
62+
timeoutSeconds: 5
63+
readinessProbe:
64+
failureThreshold: 3
65+
httpGet:
66+
path: /health/readiness
67+
port: 9090
68+
scheme: HTTP
69+
initialDelaySeconds: 30
70+
periodSeconds: 5
71+
successThreshold: 1
72+
timeoutSeconds: 5
73+
volumes:
74+
- emptyDir: {}
75+
name: bakeware-cache
76+
serviceAccountName: spawn-operator
77+
selector:
78+
matchLabels:
79+
k8s-app: spawn-operator
80+
replicas: 2
81+
kind: Deployment
82+
apiVersion: apps/v1
8383

8484
---
85+
metadata:
86+
name: activators.spawn-eigr.io
87+
labels: {}
8588
spec:
8689
scope: Cluster
8790
group: spawn-eigr.io
@@ -95,6 +98,7 @@ spec:
9598
versions:
9699
- name: v1
97100
deprecated: false
101+
storage: true
98102
schema:
99103
openAPIV3Schema:
100104
type: object
@@ -105,19 +109,18 @@ spec:
105109
observedGeneration:
106110
type: integer
107111
x-kubernetes-preserve-unknown-fields: true
108-
storage: true
109112
additionalPrinterColumns: []
110113
subresources:
111114
status: {}
112115
served: true
113116
deprecationWarning:
114-
metadata:
115-
name: activators.spawn-eigr.io
116-
labels: {}
117117
kind: CustomResourceDefinition
118118
apiVersion: apiextensions.k8s.io/v1
119119

120120
---
121+
metadata:
122+
name: actorhosts.spawn-eigr.io
123+
labels: {}
121124
spec:
122125
scope: Cluster
123126
group: spawn-eigr.io
@@ -134,6 +137,7 @@ spec:
134137
versions:
135138
- name: v1
136139
deprecated: false
140+
storage: true
137141
schema:
138142
openAPIV3Schema:
139143
type: object
@@ -307,7 +311,6 @@ spec:
307311
type: array
308312
type: object
309313
type: object
310-
storage: true
311314
additionalPrinterColumns:
312315
- name: SDK
313316
type: string
@@ -333,13 +336,13 @@ spec:
333336
status: {}
334337
served: true
335338
deprecationWarning:
336-
metadata:
337-
name: actorhosts.spawn-eigr.io
338-
labels: {}
339339
kind: CustomResourceDefinition
340340
apiVersion: apiextensions.k8s.io/v1
341341

342342
---
343+
metadata:
344+
name: actorsystems.spawn-eigr.io
345+
labels: {}
343346
spec:
344347
scope: Cluster
345348
group: spawn-eigr.io
@@ -354,6 +357,7 @@ spec:
354357
versions:
355358
- name: v1
356359
deprecated: false
360+
storage: true
357361
schema:
358362
openAPIV3Schema:
359363
type: object
@@ -438,7 +442,6 @@ spec:
438442
type: string
439443
type: object
440444
type: object
441-
storage: true
442445
additionalPrinterColumns:
443446
- name: Cluster Kind
444447
type: string
@@ -456,9 +459,6 @@ spec:
456459
status: {}
457460
served: true
458461
deprecationWarning:
459-
metadata:
460-
name: actorsystems.spawn-eigr.io
461-
labels: {}
462462
kind: CustomResourceDefinition
463463
apiVersion: apiextensions.k8s.io/v1
464464

0 commit comments

Comments
 (0)