blob: 653b0d275a9f2731977a894391de72c80f5655f9 [file] [log] [blame]
Lorenz Brundd8c80e2019-10-07 16:19:49 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020017syntax = "proto3";
Serge Bazanski662b5b32020-12-21 13:49:00 +010018package metropolis.proto.common;
Serge Bazanski31370b02021-01-07 16:31:14 +010019option go_package = "source.monogon.dev/metropolis/proto/common";
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020020
Mateusz Zalega28800ad2022-07-08 14:56:02 +020021import "google/protobuf/timestamp.proto";
Serge Bazanski0ccc85b2023-11-20 12:59:20 +010022import "version/spec/spec.proto";
Mateusz Zalega28800ad2022-07-08 14:56:02 +020023
Serge Bazanski30653ee2021-06-17 15:44:29 +020024// NodeRoles are the possible roles that a Metropolis Node should run within the
25// cluster. These are configured by the cluster and can be retrieved through the
26// Curator.
Serge Bazanski5839e972021-11-16 15:46:19 +010027//
28// Fields contained within each individual are publicly available, so while they
29// can be used to carry required data to start up services for a given role,
30// this must not be confidential/private data.
Serge Bazanski30653ee2021-06-17 15:44:29 +020031message NodeRoles {
Serge Bazanski15f7f632023-03-14 17:17:20 +010032 message KubernetesController {
33 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020034 message KubernetesWorker {
35 }
Serge Bazanski5839e972021-11-16 15:46:19 +010036 message ConsensusMember {
37 // ca_certificate is a DER-encoded x509 certificate of the etcd
38 // cluster's CA. The member must use this certificate to verify the
39 // identity of the cluster it's connecting to.
40 bytes ca_certificate = 1;
41 // pper_certificate is a DER-encoded x509 certificate of this node's
42 // etcd peer listener. The member must serve member traffic using this
43 // certificate. The private key corresponding to this certificate is
44 // the same as the node's primary private keypair.
45 bytes peer_certificate = 2;
46 // initial_crl is a certificate revocation list that the etcd member
47 // should be started with. After startup, the member will maintain its
48 // own CRL by updating it from its primary storage location, and etcd
49 // value.
50 //
51 // TODO(q3k): don't pass this here, instead pass this over an etcd
52 // watcher and curator.Watch.
53 bytes initial_crl = 3;
54 message Peer {
55 string Name = 1;
56 string URL = 2;
57 }
58 repeated Peer peers = 4;
59 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020060 KubernetesWorker kubernetes_worker = 1;
Serge Bazanski5839e972021-11-16 15:46:19 +010061 ConsensusMember consensus_member = 2;
Serge Bazanski15f7f632023-03-14 17:17:20 +010062 KubernetesController kubernetes_controller = 3;
Serge Bazanski30653ee2021-06-17 15:44:29 +020063}
64
65// NodeState is the state of a Metropolis node from the point of view of the
66// cluster it is a part of (or intending to be a part of).
67enum NodeState {
68 NODE_STATE_INVALID = 0;
69
70 // NEW: the node has established a first contact with the cluster and
71 // intends to register into it. The node's identity has not been verified
72 // and no hardware attestation of the new node was performed.
Mateusz Zalegad57ef1c2022-07-01 12:22:33 +020073 // The node has generated a CUK/NUK and set up storage encrypted with the
Serge Bazanski30653ee2021-06-17 15:44:29 +020074 // combination of both keys.
75 // The node has generated a private/public keypair, and that keypair has
76 // been used to contact the already running Cluster.
77 NODE_STATE_NEW = 1;
78 // STANDBY: the node has successfully passed identity and hardware
79 // attestation checks as defined by the cluster policy. The node still isn't
80 // part of the cluster, as it itself might perform checks against the
81 // running Cluster.
82 NODE_STATE_STANDBY = 2;
83 // UP: the node has passed all preconditions for STANDBY and has also
84 // performed a commit into the cluster by exchanging its CUK for a
85 // certificate issued by the cluster.
86 // The node is now ready to serve, and its certificate can be used to
87 // authenticate its identity cryptographically.
88 NODE_STATE_UP = 3;
Serge Bazanski7acd92d2023-10-30 18:56:00 +010089 // DECOMMISSIONED: The node has successfully been decommissioned and can be
90 // deleted.
91 //
92 // TODO(q3k): add missing -ING states.
93 NODE_STATE_DECOMMISSIONED = 4;
Serge Bazanski30653ee2021-06-17 15:44:29 +020094};
95
96// ClusterState is the state of the cluster from the point of view of a node.
97// Different subsystems can watch this state and depend on it for behaviour
98// (eg. start serving when HOME, maybe self-fence on SPLIT, etc.).
99enum ClusterState {
100 CLUSTER_STATE_INVALID = 0;
101
102 // UNKNOWN: the node has not yet determined the existence of a cluster it
103 // should join or start. This is a transient, initial state that should only
104 // manifest during boot.
105 CLUSTER_STATE_UNKNOWN = 1;
106 // FOREIGN: the node is attempting to register into an already existing
107 // cluster with which it managed to make preliminary contact, but which the
108 // cluster has not yet fully productionized (eg. the node is still being
109 // hardware attested, or the operator needs to confirm the
110 // registration of this node).
111 CLUSTER_STATE_FOREIGN = 2;
112 // TRUSTED: the node is attempting to register into an already registered
113 // cluster, and has been trusted by it. The node is now attempting to fully
114 // commit to registering into the cluster.
115 CLUSTER_STATE_TRUSTED = 3;
116 // HOME: the node is part of this cluster. This is the bulk of time in which
117 // this node will spend its time.
118 CLUSTER_STATE_HOME = 4;
119 // DISOWNING: the node has been disowned (ie., removed) by the cluster, and
120 // that it will not be ever part of any cluster again, and that it will be
121 // decommissioned by the operator.
122 CLUSTER_STATE_DISOWNING = 5;
123 // SPLIT:the node would usually be Home in a cluster, but has been split
124 // from the consensus of the cluster. This can happen for nodes running
125 // consensus when consensus is lost (eg. when there is no quorum or this
126 // node has been netsplit), and for other nodes if they have lost network
127 // connectivity to the consensus nodes. Clients should make their own
128 // decision what action to perform in this state, depending on the level of
129 // consistency required and whether it makes sense for the node to fence its
130 // services off.
131 CLUSTER_STATE_SPLIT = 6;
132}
Serge Bazanski2893e982021-09-09 13:06:16 +0200133
134// NodeStatus contains all fields self-reported by nodes. This data is
135// inherently less trusted than other data available about a node, as it can be
136// updated to any value by each node individually, including compromised nodes.
137message NodeStatus {
138 // external_address is the IP address that the node expects management,
139 // cluster and user traffic to arrive at (ie. the address on which it is
140 // listening for gRPC, and role-specific services like etcd and
141 // Kubernetes).
142 string external_address = 1;
Serge Bazanski966d40c2022-06-23 13:27:16 +0200143 // running_curator contains information about the curator service running
144 // on this node, or is nil if the service is not running.
145 message RunningCurator {
146 // port is the TCP port on which the curator is listening.
147 int32 port = 1;
148 }
149 RunningCurator running_curator = 3;
Mateusz Zalega312a2272022-04-25 12:03:58 +0200150 // timestamp is an epoch number associated with the last status update.
151 // It's set with a nanosecond granularity.
Mateusz Zalega28800ad2022-07-08 14:56:02 +0200152 google.protobuf.Timestamp timestamp = 2;
Serge Bazanski0ccc85b2023-11-20 12:59:20 +0100153 // version is the Metropolis version that this node is running.
154 version.spec.Version version = 4;
Serge Bazanski2893e982021-09-09 13:06:16 +0200155}
156
157// The Cluster Directory is information about the network addressing of nodes
158// in a cluster. It is a serialized snapshot of some of the state within the
159// etcd cluster, and can be used by external processes (like a node Registering
160// into the cluster) to know how to reach this cluster over the network. It can
161// be thought of as a phonebook, or a static name/address configuration that
162// could live in /etc/hosts.
163//
164// The directory explicitly doesn't carry any information about the cluster's
165// identity or security - these should be configured and checked by higher
166// level configuration and processes. The directory can be stored and
167// transmitted in cleartext and without an integrity checks (like saved to the
168// EFI system partition across reboots) and any malicious change to it will
169// cause no more than a denial of service against the consumer of this
170// directory. This is because all nodes contacted must present a valid cluster
171// identity/certificate before they are trusted by the consumers of this
172// directory.
173message ClusterDirectory {
174 message Node {
Serge Bazanski538292d2024-04-17 14:50:02 +0200175 string id = 3;
176 reserved 1;
Serge Bazanski2893e982021-09-09 13:06:16 +0200177 message Address {
178 string host = 1;
179 };
Serge Bazanskibc671d02021-10-05 17:53:32 +0200180 repeated Address addresses = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200181 };
182 repeated Node nodes = 1;
183}
Serge Bazanskie6bc2272023-03-28 16:28:13 +0200184
185
186// NodeClusterNetworking carries information about the cluster networking (ie.
187// WireGuard mesh) connectivity of a node.
188message NodeClusterNetworking {
189 message Prefix {
190 string cidr = 1;
191 }
192 // wireguard_pubkey is the base64-encoded public key used by the node.
193 string wireguard_pubkey = 1;
194 // prefixes are networking routes exported by the node to the cluster networking
195 // mesh, and are programmed by other nodes into their wireguard peer config.
196 repeated Prefix prefixes = 2;
197}
Serge Bazanskida114862023-03-29 17:46:42 +0200198
199// Severity level corresponding to //metropolis/pkg/logtree.Severity.
200enum LeveledLogSeverity {
201 INVALID = 0;
202 INFO = 1;
203 WARNING = 2;
204 ERROR = 3;
205 FATAL = 4;
206}
207
208// Filter set when requesting logs for a given DN. This message is equivalent to
209// the following GADT enum:
210// data LogFilter = WithChildren
211// | OnlyRaw
212// | OnlyLeveled
213// | LeveledWithMinimumSeverity(Severity)
214//
215// Multiple LogFilters can be chained/combined when requesting logs, as long as
216// they do not conflict.
217message LogFilter {
218 // Entries will be returned not only for the given DN, but all child DNs as
219 // well. For instance, if the requested DN is foo, entries logged to foo,
220 // foo.bar and foo.bar.baz will all be returned.
221 message WithChildren {
222 }
223 // Only raw logging entries will be returned. Conflicts with OnlyLeveled
224 // filters.
225 message OnlyRaw {
226 }
227 // Only leveled logging entries will be returned. Conflicts with OnlyRaw
228 // filters.
229 message OnlyLeveled {
230 }
231 // If leveled logs are returned, all entries at severity lower than `minimum`
232 // will be discarded.
233 message LeveledWithMinimumSeverity {
234 LeveledLogSeverity minimum = 1;
235 }
236 oneof filter {
237 WithChildren with_children = 1;
238 OnlyRaw only_raw = 3;
239 OnlyLeveled only_leveled = 4;
240 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
241 }
242}
243
244// LogEntry corresponding to logtree.LogEntry in //metropolis/pkg/logtree.
245message LogEntry {
246 // A leveled log entry emitted from a compatible system, eg. Metorpolis code
247 // or a klog-parsed line.
248 message Leveled {
249 repeated string lines = 1;
250 google.protobuf.Timestamp timestamp = 2;
251 LeveledLogSeverity severity = 3;
252 // Source of the error, expressed as file:line.
253 string location = 4;
254 }
255 // Raw log entry, captured from an external system without parting. Might
256 // contain some timestamp/level/origin information embedded in data. Data
257 // contained within should be treated as unsanitized external data.
258 message Raw {
259 string data = 1;
260 // Original length of line, set if data was truncated.
261 int64 original_length = 2;
262 }
263
264 // Origin DN.
265 string dn = 1;
266 oneof kind {
267 Leveled leveled = 2;
268 Raw raw = 3;
269 }
270}
271
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100272// ClusterConfiguration contains the entirety of the user-configurable behaviour
273// of the cluster that is scoped to the entirety of the cluster (vs. per-node
274// configuration, which is kept alongside Node).
275//
276// It can be set initially when a cluster is being bootstrapped (in
277// NodeParamaters.ClusterBootstrap), and then can be partially managed by
278// management calls to the curator.
279message ClusterConfiguration {
280 // tpm_mode defines the TPM usage policy for cluster nodes. When nodes
281 // register into the cluster (and then join into it) they will report their
282 // TPM availability, and in return the cluster will respond whether they
283 // should use that TPM or not.
284 //
285 // If a node is instructed to use its TPM, it will use it to encrypt its part
286 // of the disk encryption key when saving it to the EFI system partition.
287 // That means that the node will only be able to re-join the cluster if its
288 // secure boot configuration doesn't change.
289 //
290 // If a node is instructed to not use its TPM, it will save its part of the
291 // disk encryption key straight onto the EFI system partition without any
292 // further encryption. It still needs to connect to a working cluster to
293 // retrieve the other part of the key. This means that the configuration is
294 // secure vs. offline disk decryption attempts, but not secure if an
295 // attacker can connect to a cluster and impersonate the node in order to
296 // retrieve the other part of its key.
297 enum TPMMode {
298 TPM_MODE_INVALID = 0;
299 // Nodes need to join with a TPM2.0 device and will be instructed to
300 // use it.
301 TPM_MODE_REQUIRED = 1;
302 // Nodes will be allowed to join regardless of TPM2.0 presence, and will
303 // be instructed to use it if they have one.
304 TPM_MODE_BEST_EFFORT = 2;
305 // Regardless of the node's local TPM presence it will be instructed to
306 // not use it.
307 TPM_MODE_DISABLED = 3;
308 }
309 TPMMode tpm_mode = 1;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200310
311 // storage_security_policy defines which node storage security settings are
312 // accepted by the cluster. Nodes are informed of the cluster policy when
313 // registering into the cluster, alongside a cluster-recommended storage
314 // security setting. The node then reports its selected node storage setting
315 // during its Commit call which the cluster verifies against its policy.
316 enum StorageSecurityPolicy {
317 STORAGE_SECURITY_POLICY_INVALID = 0;
318 // The cluster accepts any storage security.
319 STORAGE_SECURITY_POLICY_PERMISSIVE = 1;
320 // The cluster accepts any storage security that offers encryption.
321 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION = 2;
322 // The cluster accepts any storage security that offers encryption and
323 // authentication.
324 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION_AND_AUTHENTICATION = 3;
325 // The cluster only accepts unencrypted and unauthenticated node storage.
326 STORAGE_SECURITY_POLICY_NEEDS_INSECURE = 4;
327 }
328 StorageSecurityPolicy storage_security_policy = 2;
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100329}
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100330
331// NodeTPMUsage describes whether a node has a TPM2.0 and if it is/should be
332// actively used to seal secrets before saving them to its EFI system partition.
333enum NodeTPMUsage {
334 NODE_TPM_INVALID = 0;
335 // This node has no TPM 2.0.
336 NODE_TPM_NOT_PRESENT = 1;
337 // This node has a TPM 2.0 but the cluster configuration mandates not using
338 // it.
339 NODE_TPM_PRESENT_BUT_UNUSED = 2;
340 // This node has a TPM 2.0 and it is being actively used.
341 NODE_TPM_PRESENT_AND_USED = 3;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200342}
343
344// NodeStorageSecurity describes how a node encrypts and/or authenticates its
345// local storage. In other words, it's a configuration setting for disk
346// encryption (ie. via dm-crypt) and disk integrity (ie. via dm-integrity) of
347// the Metropolis data partition.
348enum NodeStorageSecurity {
349 NODE_STORAGE_SECURITY_INVALID = 0;
350 // The node has unencrypted and unauthenticated disk storage. Its data
351 // partition is a plain XFS partition, and the node's credentials are stored
352 // on it directly.
353 NODE_STORAGE_SECURITY_INSECURE = 1;
354 // The node has encrypted but unauthenticated disk storage. Its data
355 // partition is an XFS partition mounted through dm-crypt.
356 NODE_STORAGE_SECURITY_ENCRYPTED = 2;
357 // The node has encrypted and authenticated storage. Its data
358 // partition is an XFS partition mounted through dm-integrity and dm-crypt.
359 NODE_STORAGE_SECURITY_AUTHENTICATED_ENCRYPTED = 3;
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100360}