Repository navigation
Expand file tree
/
Copy pathateapi.proto
More file actions
3299 lines (2904 loc) · 110 KB
/
Copy pathateapi.proto
File metadata and controls
3299 lines (2904 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package substrate.ateapi.v1;
import "google/protobuf/descriptor.proto";
import "google/protobuf/timestamp.proto";
option go_package = "go.ate.dev/substrate/api/ateapi/v1;ateapi";
// Control is the primary RPC interface for Agentic Substrate.
service Control {
// Get an Actor.
rpc GetActor(GetActorRequest) returns (Actor) {
option (method).resource = "Actor";
}
// Create a new Actor deriving from a given ActorTemplate.
rpc CreateActor(CreateActorRequest) returns (Actor) {
option (method).resource = "Actor";
}
// Update mutable fields on an existing Actor.
rpc UpdateActor(UpdateActorRequest) returns (Actor) {
option (method).resource = "Actor";
}
// Suspend a given actor to a new snapshot. A running actor is checkpointed
// on its worker. A SUSPENDED actor is returned as it is.
rpc SuspendActor(SuspendActorRequest) returns (SuspendActorResponse) {
option (method).resource = "Actor";
}
// Resume an actor from its latest snapshot.
rpc ResumeActor(ResumeActorRequest) returns (ResumeActorResponse) {
option (method).resource = "Actor";
}
// Revert an actor to SUSPENDED state at its durable snapshot.
// Only crashed or running actors, or suspended actors with a node-local
// snapshot, can be reverted. A suspended actor without a node-local snapshot
// is already at its durable snapshot, so there is nothing to revert.
rpc RevertActor(RevertActorRequest) returns (RevertActorResponse) {
option (method).resource = "Actor";
}
// Delete an actor. A running actor's workload is terminated, its volumes
// detached, and its worker released before the record is removed.
rpc DeleteActor(DeleteActorRequest) returns (Actor) {
option (method).resource = "Actor";
}
// Get the egress policy resource nested under an Actor.
rpc GetActorEgressPolicy(GetActorEgressPolicyRequest) returns (EgressPolicy) {
option (method).resource = "EgressPolicy";
}
// Create the egress policy resource nested under an Actor.
rpc CreateActorEgressPolicy(CreateActorEgressPolicyRequest) returns (EgressPolicy) {
option (method).resource = "EgressPolicy";
}
// Replace the egress policy resource nested under an Actor.
rpc UpdateActorEgressPolicy(UpdateActorEgressPolicyRequest) returns (EgressPolicy) {
option (method).resource = "EgressPolicy";
}
// Delete the egress policy resource nested under an Actor.
rpc DeleteActorEgressPolicy(DeleteActorEgressPolicyRequest) returns (EgressPolicy) {
option (method).resource = "EgressPolicy";
}
// Create a Substrate-issued JWT asserting the actor identity.
//
// * Called by the egress gateway when actor JWT injection is configured for outbound requests.
rpc MintActorJwt(MintActorJwtRequest) returns (MintActorJwtResponse) {
option (method).resource = "Actor";
}
// Create a Substrate-issued SPIFFE certificate asserting the actor identity.
//
// SPIFFE URI: spiffe://${trustdomain}/actor/${atespace}/${actor}
//
// * Called by the egress gateway when actor client certificate injection is
// configured for outbound requests.
rpc MintActorCertificate(MintActorCertificateRequest) returns (MintActorCertificateResponse) {
option (method).resource = "Actor";
}
// Tag the external snapshot a suspended Actor holds. The tag gets its own
// copy of that snapshot, so suspending or deleting the Actor afterwards
// cannot collect it. When the Actor's latest snapshot is not uploaded yet,
// atelet uploads it first, so the call can take as long as that upload.
rpc CreateTag(CreateTagRequest) returns (Tag) {
option (method).resource = "Tag";
}
// Get a Tag.
rpc GetTag(GetTagRequest) returns (Tag) {
option (method).resource = "Tag";
}
// List Tags.
rpc ListTags(ListTagsRequest) returns (ListTagsResponse) {
option (method).resource = "Tag";
}
// Publish or unpublish a Tag without changing its address.
rpc UpdateTag(UpdateTagRequest) returns (Tag) {
option (method).resource = "Tag";
}
// Delete a Tag and the external snapshot it owns. Actors created from the
// tag that have not yet been suspended still point at that external snapshot
// and become unrecoverable, so do not delete a tag while such Actors exist.
rpc DeleteTag(DeleteTagRequest) returns (Tag) {
option (method).resource = "Tag";
}
// List Workers.
rpc ListWorkers(ListWorkersRequest) returns (ListWorkersResponse) {
option (method).resource = "Worker";
}
// Get a Worker.
rpc GetWorker(GetWorkerRequest) returns (Worker) {
option (method).resource = "Worker";
}
// Register a Worker. Called once its Pod has an IP. A Worker is registered
// UNAVAILABLE and takes no Actors until MarkWorkerAvailable.
rpc CreateWorker(CreateWorkerRequest) returns (Worker) {
option (method).resource = "Worker";
}
// Update observed pool state on a Worker.
rpc UpdateWorker(UpdateWorkerRequest) returns (Worker) {
option (method).resource = "Worker";
}
// Deregister a Worker. Does not cascade: the caller is responsible for
// cleaning up related resources first.
rpc DeleteWorker(DeleteWorkerRequest) returns (Worker) {
option (method).resource = "Worker";
}
// Mark a Worker as terminating so the scheduler stops routing new Actors to
// it. Idempotent; one-way. Deliberately leaves any bound Actor alone.
// Returns ABORTED if another write lands on the Worker first; retry.
rpc DrainWorker(DrainWorkerRequest) returns (DrainWorkerResponse) {
option (method).resource = "Worker";
}
// Mark an UNAVAILABLE Worker ACTIVE so the scheduler places Actors on it.
// Idempotent. Returns FAILED_PRECONDITION for a DRAINING Worker, and ABORTED
// if another write lands on the Worker first; retry.
//
// Every Actor placed after this call is stamped with the Worker's epoch as
// it stands then, so a caller raises epoch for a restarted the worker first.
rpc MarkWorkerAvailable(MarkWorkerAvailableRequest) returns (MarkWorkerAvailableResponse) {
option (method).resource = "Worker";
}
// Mark an ACTIVE Worker UNAVAILABLE so the scheduler stops placing Actors on
// it, as while its Pod is not Ready. Idempotent. Leaves any bound Actor
// alone. Returns FAILED_PRECONDITION for a DRAINING Worker, and ABORTED if
// another write lands on the Worker first; retry.
rpc MarkWorkerUnavailable(MarkWorkerUnavailableRequest) returns (MarkWorkerUnavailableResponse) {
option (method).resource = "Worker";
}
// List the Actors hosted by a given Worker.
rpc ListWorkerActorAssignments(ListWorkerActorAssignmentsRequest) returns (ListWorkerActorAssignmentsResponse) {
option (method).resource = "ActorAssignment";
}
// List Actors.
rpc ListActors(ListActorsRequest) returns (ListActorsResponse) {
option (method).resource = "Actor";
}
// Create a new Atespace. Substrate-native, stored in database.
rpc CreateAtespace(CreateAtespaceRequest) returns (Atespace) {
option (method).resource = "Atespace";
}
// Get an Atespace by name.
rpc GetAtespace(GetAtespaceRequest) returns (Atespace) {
option (method).resource = "Atespace";
}
// List Atespaces.
rpc ListAtespaces(ListAtespacesRequest) returns (ListAtespacesResponse) {
option (method).resource = "Atespace";
}
// Delete an empty Atespace. Rejects (FailedPrecondition) if any Actors or
// Tags remain.
rpc DeleteAtespace(DeleteAtespaceRequest) returns (Atespace) {
option (method).resource = "Atespace";
}
rpc CreateActorTemplate(CreateActorTemplateRequest) returns (ActorTemplate) {
option (method).resource = "ActorTemplate";
}
rpc GetActorTemplate(GetActorTemplateRequest) returns (ActorTemplate) {
option (method).resource = "ActorTemplate";
}
rpc ListActorTemplates(ListActorTemplatesRequest) returns (ListActorTemplatesResponse) {
option (method).resource = "ActorTemplate";
}
// Delete an ActorTemplate together with its golden actor and golden
// tag in the template's atespace.
rpc DeleteActorTemplate(DeleteActorTemplateRequest) returns (ActorTemplate) {
option (method).resource = "ActorTemplate";
}
// Get the deployment-wide global access policy singleton. Returns NotFound
// until the policy has been created.
rpc GetGlobalAccessPolicy(GetGlobalAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Create the deployment-wide global access policy singleton. The server's
// configured bootstrap owners are global owners whether or not this policy
// exists, so they can create it.
rpc CreateGlobalAccessPolicy(CreateGlobalAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Replace the deployment-wide global access policy singleton. Empty
// bindings revoke every grant held through the policy; bootstrap owners
// keep access.
rpc UpdateGlobalAccessPolicy(UpdateGlobalAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Get the access policy resource nested under an Atespace.
rpc GetAtespaceAccessPolicy(GetAtespaceAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Create the access policy resource nested under an Atespace.
rpc CreateAtespaceAccessPolicy(CreateAtespaceAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Replace the access policy resource nested under an Atespace.
rpc UpdateAtespaceAccessPolicy(UpdateAtespaceAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
// Delete the access policy resource nested under an Atespace.
rpc DeleteAtespaceAccessPolicy(DeleteAtespaceAccessPolicyRequest) returns (AccessPolicy) {
option (method).resource = "AccessPolicy";
}
}
// ObjectSnapshot addresses a snapshot held in object storage.
message ObjectSnapshot {
// snapshot_uri addresses the snapshot's prefix in object storage.
//
// +k8s:required
// +k8s:maxLength=2048 # the template's storage_location bound plus the owner prefix and snapshot name
string snapshot_uri = 1;
}
// SnapshotOwner indicates the owner of a snapshot.
enum SnapshotOwner {
SNAPSHOT_OWNER_UNSPECIFIED = 0;
// Snapshot captured directly from this Actor.
SNAPSHOT_OWNER_ACTOR = 1;
// Snapshot owned by a Tag (also includes Golden Snapshot)
SNAPSHOT_OWNER_TAG = 2;
// Keep this in sync with Snapshot.owner's maximum.
}
// SnapshotStorageState indicates the lifecycle stage of a durable snapshot.
enum SnapshotStorageState {
SNAPSHOT_STORAGE_STATE_UNSPECIFIED = 0;
// Snapshot creation in durable storage is in progress.
SNAPSHOT_STORAGE_STATE_PENDING = 1;
// Snapshot is complete and ready for use in durable storage.
SNAPSHOT_STORAGE_STATE_COMPLETED = 2;
// Keep this in sync with SnapshotStorage.state's maximum.
}
// SnapshotStorage records the durable storage representation of a Snapshot.
message SnapshotStorage {
// state is the lifecycle state of the durable snapshot.
//
// +k8s:required
// +k8s:minimum=1
// +k8s:maximum=2 # keep this in sync with the SnapshotStorageState enum
SnapshotStorageState state = 1;
// object snapshot is stored in object storage.
//
// +k8s:required
ObjectSnapshot object = 2;
}
// Snapshot represents one generation of an Actor's or Tag's snapshot state.
message Snapshot {
// uuid is the server-generated unique identifier for this snapshot, passed to
// atelet to identify the local checkpoint on disk and used as the snapshot
// name in object storage.
//
// +k8s:required
// +k8s:format=k8s-short-name
string uuid = 1;
// generation is the monotonically increasing generation number of this
// snapshot, starting at 1.
//
// +k8s:required
// +k8s:minimum=1
int32 generation = 2;
// owner identifies the origin and ownership of this snapshot.
//
// +k8s:required
// +k8s:minimum=1
// +k8s:maximum=2 # keep this in sync with the SnapshotOwner enum
SnapshotOwner owner = 3;
// fidelity is what this snapshot holds.
//
// +k8s:required
// +k8s:minimum=1
// +k8s:maximum=3 # keep this in sync with the SnapshotFidelity enum
SnapshotFidelity fidelity = 4;
// UID of the ActorTemplate whose sandbox this snapshot's guest state was
// captured from.
//
// +k8s:optional
// +k8s:format=k8s-uuid
string actor_template_uid = 5;
// locality identifies the Kubernetes node holding this snapshot's files.
// Detach, revert, or a later checkpoint clears it. Resume keeps the files.
//
// +k8s:optional
// +k8s:format=k8s-long-name
string locality = 6;
// durable_snapshot holds the durable storage representation of this snapshot.
// PENDING while the snapshot is uploaded, including an asynchronous suspend's
// snapshot that so far exists only on the node named by locality. COMPLETED
// once the upload is recorded.
//
// +k8s:optional
SnapshotStorage durable_snapshot = 7;
// sandbox_runtime is the runtime the actor ran under when the snapshot was
// taken.
//
// +k8s:optional
ActorSandboxRuntime sandbox_runtime = 8;
}
// SnapshotFidelity orders the state layers a snapshot can hold, lowest to
// highest. Each level includes the ones below it.
enum SnapshotFidelity {
SNAPSHOT_FIDELITY_UNSPECIFIED = 0;
// Durable volumes only. The actor resumes by cold-booting its containers
// from the OCI image with the volumes restored.
SNAPSHOT_FIDELITY_VOLUMES = 1;
// Volumes plus the root filesystem changes made since boot. The actor
// cold-boots on resume with its rootfs writes back in place.
SNAPSHOT_FIDELITY_ROOTFS = 2;
// Volumes, root filesystem changes, and process memory. The actor resumes
// where it left off.
SNAPSHOT_FIDELITY_MEMORY = 3;
// Keep this in sync with the maximums on fields of this type.
}
enum TagScope {
// Not set and rejected wherever a client supplies a scope
TAG_SCOPE_UNSPECIFIED = 0;
// May initialize Actors only in the tag's owning Atespace.
TAG_SCOPE_ATESPACE = 1;
// Published for use by Actors in any Atespace. The tag remains addressed
// through its owning Atespace.
TAG_SCOPE_PUBLISHED = 2;
}
// Selector matches worker pools by label.
// Only equality-based matching is supported.
message Selector {
// match_labels selects by exact equality on a set of labels.
//
// +k8s:optional
// +k8s:unionMember
// +k8s:minProperties=1
// +k8s:maxProperties=10
// +k8s:eachKey=+k8s:format=k8s-label-key
// +k8s:eachVal=+k8s:format=k8s-label-value
map<string, string> match_labels = 1;
}
// ResourceMetadata holds the common fields carried by every Substrate resource.
//
// +k8s:customValidation # timestamps must be valid, and update_time must not precede create_time
message ResourceMetadata {
// atespace is the namespace the resource belongs to. Empty for global-scoped
// resources. Caller-specified at creation and immutable thereafter.
//
// Atespaced resources should add `+k8s:subfield(atespace)=+k8s:required`
// Non-atespaced resources should add `+k8s:subfield(atespace)=+k8s:forbidden`
// +k8s:optional
// +k8s:format=k8s-short-name
// +k8s:immutable
string atespace = 1;
// name is the resource's name, unique within its atespace (or globally, for
// global-scoped resources). Caller-specified at creation and immutable thereafter.
//
// +k8s:required
// +k8s:format=k8s-short-name
// +k8s:immutable
string name = 2;
// uid is a server-assigned, globally unique identifier for this resource.
// Immutable throughout the lifecycle of the resource.
//
// This field is ignored during create operations and used as precondition
// for update operations.
//
// +k8s:optional
// +k8s:format=k8s-uuid
// +k8s:immutable
string uid = 3;
// version is increased on every mutation.
//
// This field is ignored during create operations and used as precondition
// for update operations.
//
// +k8s:optional
// +k8s:alpha(since: "0.0")=+k8s:monotonic # TODO: get rid of alpha prefix
// +k8s:minimum=1
// +k8s:update=NoUnset
int64 version = 4;
// create_time is the time the resource was created.
//
// This field is ignored on input.
//
// +k8s:optional
// +k8s:immutable
google.protobuf.Timestamp create_time = 5;
// update_time is the time the resource was last updated.
//
// This field is ignored on input.
//
// +k8s:optional
// +k8s:update=NoUnset
google.protobuf.Timestamp update_time = 6;
// delete_time is the time the resource started its deletion.
//
// This field is ignored on input.
//
// +k8s:optional
// +k8s:update=NoModify
// +k8s:update=NoUnset
google.protobuf.Timestamp delete_time = 7;
}
// ExternalVolumes is the external volume state recorded on an actor, wrapped
// so later additions do not reshape ActorStatus.
message ExternalVolumes {
// volumes has one entry per external volume of the template. Each template
// volume appears at most once.
//
// +k8s:optional
// +k8s:maxItems=32 # matches the template's volumes bound
// +k8s:listType=map
// +k8s:listMapKey=name
repeated ExternalVolumeStatus volumes = 1;
}
// ExternalVolumeStatus is one actor's view of an external volume it mounts.
message ExternalVolumeStatus {
// Name of the volume specified in the actor template. Template volume
// names are DNS labels.
//
// +k8s:required
// +k8s:format=k8s-short-name
// +k8s:update=NoModify
// +k8s:update=NoUnset # set-once; immutable would reject the create
// ratchet's nil->set when the final object is validated as an update
string name = 1;
// The globally unique volume_id returned from the storage system.
// This will be initially empty during volume creation. Its format is the
// storage system's own, so it is only bounded and checked for control
// characters (U+0000-U+0008, U+000B, U+000C, U+000E-U+001F, U+007F-U+009F).
// The CSI spec caps IDs at 128 bytes but does not require it, so allow
// some slack. Set once when provisioning completes, then never changed.
//
// +k8s:optional
// +k8s:maxLength=256
// +k8s:update=NoModify
// +k8s:update=NoUnset
// +k8s:customValidation # no control characters
string storage_volume_id = 2;
// Internal volume plugin name or CSI driver name, from the StorageClass
// provisioner. Must be a DNS subdomain, optionally prefixed with
// "substrate.io/" (per the CSI spec's driver-name syntax).
//
// +k8s:required
// +k8s:maxLength=253
// +k8s:update=NoModify
// +k8s:update=NoUnset # set-once, like name above
// +k8s:customValidation
string volume_type = 3;
// volume_context contains metadata returned by the CSI driver during volume
// provisioning, needed by the node plugin for mounting (e.g. attachment
// info). Keys and values are the driver's own, so the map is only bounded,
// not validated.
//
// +k8s:optional
// +k8s:customValidation # at most 40 KiB in total, ten times the CSI limit for map fields
map<string, string> volume_context = 4;
}
message Actor {
option (resource) = {
scope : SCOPE_ATESPACE
plural : "Actors"
};
// Common resource metadata: atespace, name, uid, version, timestamps.
//
// +k8s:required
// +k8s:subfield(atespace)=+k8s:required
ResourceMetadata metadata = 1;
// TODO: replace with full actor_template spec if we decide to make each Actor self-contained.
// +k8s:required
// +k8s:subfield(atespace)=+k8s:required
// +k8s:mutable
ObjectRef actor_template = 2;
// worker_selector is the per-actor placement constraint. The scheduler
// evaluates the AND of this selector and the template's workerSelector to
// find eligible pools. It narrows the template's selection; pinning a
// sandbox class belongs on the template's worker_selector.
// Changes take effect on the next ResumeActor call.
//
// +k8s:optional
Selector worker_selector = 3;
// The tag specified by the caller at CreateActor to seed this Actor from an
// ActorSnapshot. Unset if the Actor was not created from a snapshot. Set
// once at creation and immutable afterward.
//
// +k8s:optional
// +k8s:subfield(atespace)=+k8s:required
// +k8s:immutable
ObjectRef source_tag = 4;
// status is the system-managed state of the Actor. It is updated by the
// server and ignored on input. It is always present in output.
//
// +k8s:optional
ActorStatus status = 5;
}
// EgressPolicy is an egress policy resource nested under an Actor. An Actor has
// at most one egress policy resource, named "default".
//
message EgressPolicy {
option (resource) = {
parents : "Actor"
singleton : true
plural : "EgressPolicies"
};
// Standard resource metadata. Atespace must match the parent Actor and name
// must be "default". Both are caller-specified on create and immutable.
// UID, version, create_time, and update_time are server-managed.
//
// +k8s:required
// +k8s:subfield(atespace)=+k8s:required
// +k8s:customValidation # name must be "default"
ResourceMetadata metadata = 1;
// Rules are an unordered set of allows. Traffic is denied when no rule
// matches.
//
// For a given destination name and port, exactly one rule decides,
// whatever its protocol. When more than one rule matches, the winner is
// chosen by these criteria, in order, moving to the next one on a tie:
//
// * A matching hostname without a wildcard.
// * A matching port number rather than all ports.
//
// Two rules with the same pattern on the same port, or both on all ports,
// are rejected at admission.
//
// These criteria apply within a protocol and across protocols that decide
// on the same input, such as an https and a tls_passthrough rule that match
// the same pattern. Only the winning rule's effects are applied.
//
// +k8s:optional
// +k8s:maxItems=256
// +k8s:listType=atomic
// +k8s:customValidation # no two rules tie on a name and port
repeated EgressRule rules = 2;
}
// EgressPolicyTemplate defines an initial Actor egress policy without resource
// metadata. Each rule has the same defaults, validation, and semantics as
// EgressPolicy.rules.
message EgressPolicyTemplate {
// Rules are an unordered set of allows, with the same precedence and effects
// as EgressPolicy.rules. At least one rule is required. Traffic is denied
// when no rule matches.
//
// +k8s:required
// +k8s:maxItems=256
// +k8s:listType=atomic
// +k8s:customValidation # no two rules tie on a name and port
repeated EgressRule rules = 1;
}
// EgressRule allows traffic for a given protocol and destination (host name
// or IP, and port). The protocol fixes what the gateway matches on and when:
// a request, or a TLS connection at its ClientHello. Traffic that matches no
// rule is refused. All protocols here run over TCP; UDP is blocked. Protocols
// where the server sends first after connect are not supported.
//
// Users should expect additional protocols to be supported in the future.
message EgressRule {
// Cleartext HTTP to the named hosts: HTTP/1.1, and h2c as used by gRPC.
// TLS to these names is not allowed by this rule.
//
// +k8s:optional
// +k8s:unionMember
HttpRule http = 1;
// HTTPS to the named hosts, intercepted (man-in-the-middle) so the gateway
// can authorize and modify each request. HTTP/1.1 and HTTP/2 inside the
// TLS connection; HTTP/3 is not supported.
//
// +k8s:optional
// +k8s:unionMember
HttpsRule https = 2;
// TLS to the named servers, forwarded without decryption.
//
// +k8s:optional
// +k8s:unionMember
TlsPassthroughRule tls_passthrough = 3;
}
// HttpRule allows cleartext HTTP and is evaluated per request on the request
// authority (Host or :authority) and port. The gateway resolves the name and
// dials it.
message HttpRule {
// Hostname patterns: a DNS name, or a DNS name with "*" as its leftmost
// label. The rule matches when any pattern matches.
//
// The DNS name must conform to RFC 1034 and RFC 1123. It must be lowercase
// and must not have a trailing dot.
//
// A wildcard replaces the complete leftmost label. "*.example.com" matches
// exactly one non-empty label, such as "api.example.com". It does not match
// "example.com" or "nested.api.example.com". "*" alone matches every name.
// No other wildcard syntax is accepted. A pattern without a wildcard matches
// only the complete normalized name. Patterns may overlap: the rule ranks
// by the most specific pattern that matches the destination.
//
// Internationalized names must use their IDNA A-label (punycode) form; no
// Unicode conversion is performed. URLs, IP addresses, names with ports,
// malformed DNS names (for example, "foo..example.com"), and more than one
// trailing dot are invalid.
//
// +k8s:required
// +k8s:maxItems=256
// +k8s:listType=set
// +k8s:customValidation # format
repeated string hostnames = 1;
// Ports of the destination the Actor connected to. A port in a request's
// authority is neither matched nor dialed. Defaults to port 80.
//
// +k8s:optional
Ports ports = 2;
// Effects do not authorize traffic. They are applied only when this is the
// deciding rule.
//
// +k8s:optional
HttpRuleEffects effects = 3;
}
// HttpsRule allows HTTPS that the gateway intercepts (MITM). Every Actor behind such
// a rule must trust the gateway CA. Without it, TLS to these names fails in the
// Actor.
//
// A TLS connection whose SNI and port match is terminated with a leaf
// certificate for that name issued by the gateway CA. Each request inside it
// is then decided on its authority, and the gateway re-originates TLS to that
// authority; the SNI only selects the leaf.
//
// Interception is for HTTP. A connection that sends no SNI does not match,
// and a non-HTTP protocol inside an intercepted connection fails.
message HttpsRule {
// Server names matched against the SNI, in the pattern syntax of
// HttpRule.hostnames.
//
// +k8s:required
// +k8s:maxItems=256
// +k8s:listType=set
// +k8s:customValidation # format
repeated string hostnames = 1;
// Ports of the destination the Actor connected to. Defaults to port 443.
//
// +k8s:optional
Ports ports = 2;
// Effects do not authorize traffic. They are applied only when this is the
// deciding rule.
//
// +k8s:optional
HttpRuleEffects effects = 3;
}
// TlsPassthroughRule allows TLS that the gateway forwards without decryption.
// It is evaluated once per connection at the ClientHello, on the SNI and
// port, for any protocol carried over TLS. A connection that sends no SNI
// does not match. Protocols that upgrade to TLS after a cleartext exchange
// (STARTTLS) do not match. Because the gateway reads nothing after the
// ClientHello, a passthrough rule has no effects, and a policy change reaches
// an open connection only when it ends.
message TlsPassthroughRule {
// Server names matched against the SNI, in the pattern syntax of
// HttpRule.hostnames.
//
// +k8s:required
// +k8s:maxItems=256
// +k8s:listType=set
// +k8s:customValidation # format
repeated string hostnames = 1;
// Ports of the destination the Actor connected to.
//
// +k8s:required
Ports ports = 2;
}
// Ports selects the destination ports a rule matches. Every port, or a set
// of port numbers. all and numbers can not be set together.
message Ports {
// Every port.
//
// +k8s:optional
// +k8s:unionMember
AllPorts all = 1;
// Port numbers, without repeats.
//
// +k8s:optional
// +k8s:unionMember
// +k8s:maxItems=16
// +k8s:listType=set
// +k8s:eachVal=+k8s:minimum=1
// +k8s:eachVal=+k8s:maximum=65535
repeated int32 numbers = 2;
}
// AllPorts selects every port. It has no fields.
message AllPorts {}
// HttpRuleEffects contains effects applied by a matching HTTP or HTTPS rule.
//
// +k8s:customValidation # for "at least one" and duplicate headers
message HttpRuleEffects {
// Replaces placeholder request headers with credentials. A header is
// replaced only when the request from the Actor carries it; requests
// without the header are forwarded unchanged, so a credential reaches only
// the requests that ask for it. Header names must be unique
// case-insensitively.
//
// Replacement is supported on HTTP and HTTPS. On HTTP, the gateway does
// not originate TLS to the destination. Without separate transport
// protection, observers can read the credential and attackers on the path
// can modify the request. Deployments may encrypt traffic outside the
// gateway; policy authors must account for any unprotected segments
// between credential injection and the intended destination.
//
// +k8s:optional
// +k8s:maxItems=16
// +k8s:listType=map
// +k8s:listMapKey=header
// +k8s:customUnique # case-insensitive
// +k8s:customValidation # for duplicate headers
repeated CredentialHeader replace_headers = 1;
}
// CredentialHeader replaces the value of an HTTP request header with a
// credential. The Actor sends the header with a placeholder value, such as
// "Authorization: <something>"; the gateway discards that value and forwards
// the header with the credential instead. The placeholder itself is not
// inspected, so any value works. A request without the header is not
// modified.
message CredentialHeader {
// The case-insensitive HTTP request header to replace when present.
//
// +k8s:required
// +k8s:customValidation # format
string header = 1;
// Prepended verbatim to the credential value. Include any desired separator;
// for example, use "Bearer " (including the space) for Authorization.
//
// +k8s:optional
// +k8s:customValidation # format
string prefix = 2;
// Source-agnostic reference interpreted by a registered credential provider:
// ate-secret://<provider-class>/<provider-name>/<provider-specific-tail>
//
// Exactly one of credential_uri and actor_jwt must be set.
//
// +k8s:optional
// +k8s:unionMember
// +k8s:customValidation # format
string credential_uri = 3;
// A Substrate-issued JWT asserting the identity of the Actor that sent the
// request.
//
// +k8s:optional
// +k8s:unionMember
ActorJwtSource actor_jwt = 4;
}
// ActorJwtSource has the gateway mint a JWT for the Actor that sent the
// request. Relying parties verify it with OpenID Connect Discovery against its
// issuer. The gateway reuses a JWT across requests while enough of its
// lifetime remains, so its jti does not identify a single request.
message ActorJwtSource {
// The audiences the JWT is bound to, which become its aud claim.
//
// +k8s:required
// +k8s:maxItems=16
// +k8s:listType=set
// +k8s:eachVal=+k8s:minLength=1
// +k8s:eachVal=+k8s:maxLength=512
repeated string audiences = 1;
// Lifetime of each JWT, in seconds.
//
// +k8s:required
// +k8s:minimum=300
// +k8s:maximum=3600
int64 expiration_seconds = 2;
}
enum ActorState {
ACTOR_STATE_UNSPECIFIED = 0;
ACTOR_STATE_RESUMING = 1;
ACTOR_STATE_RUNNING = 2;
ACTOR_STATE_SUSPENDING = 3;
ACTOR_STATE_SUSPENDED = 4;
ACTOR_STATE_CRASHED = 5;
ACTOR_STATE_DELETING = 6;
ACTOR_STATE_REVERTING = 7;
// Keep this in sync with ActorStatus.state's maximum.
}
message ActorStatus {
// state is the Actor's current lifecycle state.
//
// +k8s:required
// +k8s:minimum=1
// +k8s:maximum=7 # keep this in sync with the ActorState enum
ActorState state = 1;
// worker_assignment points at the worker currently hosting this Actor.
// Unset whenever the Actor has no worker (SUSPENDED, CRASHED).
//
// It can be set and cleared, but not pointed at another Worker in place:
// the fields that identify the Worker cannot change while it is set.
//
// +k8s:optional
WorkerAssignment worker_assignment = 2;
// external_volumes is the state of the external volumes attached to the
// actor. These volumes only live as long as the actor and are deleted with
// it.
//
// +ate:preview=ExternalVolumes
// +k8s:optional
ExternalVolumes external_volumes = 3;
// crash records why and when the Actor entered CRASHED. It is set with the
// CRASHED state and cleared when a revert returns the Actor to SUSPENDED.
//
// +k8s:optional
ActorCrash crash = 4;
// assigned_node is the node hosting the Actor's worker or local snapshot.
// A suspended Actor remains attached while its local snapshot is kept.
// Detach or revert clears the binding.
//
// +k8s:optional
// +k8s:format=k8s-long-name
string assigned_node = 5;
// snapshots holds the Actor's active and in-progress snapshot generations.
//
// +k8s:optional
// +k8s:maxItems=16
// +k8s:listType=atomic
// +k8s:unique=map
// +k8s:listMapKey=generation
repeated Snapshot snapshots = 6;
// last_assigned_generation tracks the last snapshot generation assigned for
// this Actor during a Suspend request.
// Even during Revert, the generation is not decreased to keep track of snapshots
// that have become stale and need to be cleaned up.
//
// +k8s:optional
// +k8s:alpha(since: "0.0")=+k8s:monotonic # TODO: get rid of alpha prefix
// +k8s:minimum=0
// +k8s:update=NoUnset
int32 last_assigned_generation = 7;
}
// ActorCrash describes the failure that moved an Actor to CRASHED.
message ActorCrash {
// message is a human-readable description of the failure.
//
// +k8s:optional
// +k8s:maxLength=4096
string message = 1;
// crash_time is when the Actor entered CRASHED.
//
// +k8s:optional
google.protobuf.Timestamp crash_time = 2;
}
// WorkerAssignment points at the Worker currently hosting an Actor.
//
// This is a denormalized snapshot, not merely a reference: atenet reads
// worker_pod_ips on the request-routing path and must not need a second lookup,
// and kubectl-ate displays the pod name. The copies of the Worker's identity
// fields stay valid for the life of the assignment because those fields are
// immutable, and cannot change in place. worker_pod_ips and worker_epoch
// describe the worker process the Actor runs under, and are updated when the
// Actor becomes RUNNING.
//
// Pass `worker` to GetWorker; none of the denormalized fields identify the
// Worker to the API.
message WorkerAssignment {
// worker references the assigned Worker. This is the field to look the Worker
// up by; the worker_* fields below are a denormalized copy kept so that
// readers on a hot path do not have to fetch the Worker at all.
//
// Workers are global-scoped, so this carries no atespace.
//
// +k8s:beta(since: "0.0")=+k8s:subfield(atespace)=+k8s:forbidden # TODO: get rid of beta prefix
// +k8s:required
// +k8s:update=NoModify
ObjectRef worker = 6;
// worker_namespace is the Kubernetes namespace of the WorkerPool and worker Pod.
//
// +k8s:required
// +k8s:format=k8s-short-name
// +k8s:update=NoModify