blob: fc461ab2e519c0b9f4cfefc9295cb06991744255 [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 {
175 bytes public_key = 1;
176 message Address {
177 string host = 1;
178 };
Serge Bazanskibc671d02021-10-05 17:53:32 +0200179 repeated Address addresses = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200180 };
181 repeated Node nodes = 1;
182}
Serge Bazanskie6bc2272023-03-28 16:28:13 +0200183
184
185// NodeClusterNetworking carries information about the cluster networking (ie.
186// WireGuard mesh) connectivity of a node.
187message NodeClusterNetworking {
188 message Prefix {
189 string cidr = 1;
190 }
191 // wireguard_pubkey is the base64-encoded public key used by the node.
192 string wireguard_pubkey = 1;
193 // prefixes are networking routes exported by the node to the cluster networking
194 // mesh, and are programmed by other nodes into their wireguard peer config.
195 repeated Prefix prefixes = 2;
196}
Serge Bazanskida114862023-03-29 17:46:42 +0200197
198// Severity level corresponding to //metropolis/pkg/logtree.Severity.
199enum LeveledLogSeverity {
200 INVALID = 0;
201 INFO = 1;
202 WARNING = 2;
203 ERROR = 3;
204 FATAL = 4;
205}
206
207// Filter set when requesting logs for a given DN. This message is equivalent to
208// the following GADT enum:
209// data LogFilter = WithChildren
210// | OnlyRaw
211// | OnlyLeveled
212// | LeveledWithMinimumSeverity(Severity)
213//
214// Multiple LogFilters can be chained/combined when requesting logs, as long as
215// they do not conflict.
216message LogFilter {
217 // Entries will be returned not only for the given DN, but all child DNs as
218 // well. For instance, if the requested DN is foo, entries logged to foo,
219 // foo.bar and foo.bar.baz will all be returned.
220 message WithChildren {
221 }
222 // Only raw logging entries will be returned. Conflicts with OnlyLeveled
223 // filters.
224 message OnlyRaw {
225 }
226 // Only leveled logging entries will be returned. Conflicts with OnlyRaw
227 // filters.
228 message OnlyLeveled {
229 }
230 // If leveled logs are returned, all entries at severity lower than `minimum`
231 // will be discarded.
232 message LeveledWithMinimumSeverity {
233 LeveledLogSeverity minimum = 1;
234 }
235 oneof filter {
236 WithChildren with_children = 1;
237 OnlyRaw only_raw = 3;
238 OnlyLeveled only_leveled = 4;
239 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
240 }
241}
242
243// LogEntry corresponding to logtree.LogEntry in //metropolis/pkg/logtree.
244message LogEntry {
245 // A leveled log entry emitted from a compatible system, eg. Metorpolis code
246 // or a klog-parsed line.
247 message Leveled {
248 repeated string lines = 1;
249 google.protobuf.Timestamp timestamp = 2;
250 LeveledLogSeverity severity = 3;
251 // Source of the error, expressed as file:line.
252 string location = 4;
253 }
254 // Raw log entry, captured from an external system without parting. Might
255 // contain some timestamp/level/origin information embedded in data. Data
256 // contained within should be treated as unsanitized external data.
257 message Raw {
258 string data = 1;
259 // Original length of line, set if data was truncated.
260 int64 original_length = 2;
261 }
262
263 // Origin DN.
264 string dn = 1;
265 oneof kind {
266 Leveled leveled = 2;
267 Raw raw = 3;
268 }
269}
270
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100271// ClusterConfiguration contains the entirety of the user-configurable behaviour
272// of the cluster that is scoped to the entirety of the cluster (vs. per-node
273// configuration, which is kept alongside Node).
274//
275// It can be set initially when a cluster is being bootstrapped (in
276// NodeParamaters.ClusterBootstrap), and then can be partially managed by
277// management calls to the curator.
278message ClusterConfiguration {
279 // tpm_mode defines the TPM usage policy for cluster nodes. When nodes
280 // register into the cluster (and then join into it) they will report their
281 // TPM availability, and in return the cluster will respond whether they
282 // should use that TPM or not.
283 //
284 // If a node is instructed to use its TPM, it will use it to encrypt its part
285 // of the disk encryption key when saving it to the EFI system partition.
286 // That means that the node will only be able to re-join the cluster if its
287 // secure boot configuration doesn't change.
288 //
289 // If a node is instructed to not use its TPM, it will save its part of the
290 // disk encryption key straight onto the EFI system partition without any
291 // further encryption. It still needs to connect to a working cluster to
292 // retrieve the other part of the key. This means that the configuration is
293 // secure vs. offline disk decryption attempts, but not secure if an
294 // attacker can connect to a cluster and impersonate the node in order to
295 // retrieve the other part of its key.
296 enum TPMMode {
297 TPM_MODE_INVALID = 0;
298 // Nodes need to join with a TPM2.0 device and will be instructed to
299 // use it.
300 TPM_MODE_REQUIRED = 1;
301 // Nodes will be allowed to join regardless of TPM2.0 presence, and will
302 // be instructed to use it if they have one.
303 TPM_MODE_BEST_EFFORT = 2;
304 // Regardless of the node's local TPM presence it will be instructed to
305 // not use it.
306 TPM_MODE_DISABLED = 3;
307 }
308 TPMMode tpm_mode = 1;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200309
310 // storage_security_policy defines which node storage security settings are
311 // accepted by the cluster. Nodes are informed of the cluster policy when
312 // registering into the cluster, alongside a cluster-recommended storage
313 // security setting. The node then reports its selected node storage setting
314 // during its Commit call which the cluster verifies against its policy.
315 enum StorageSecurityPolicy {
316 STORAGE_SECURITY_POLICY_INVALID = 0;
317 // The cluster accepts any storage security.
318 STORAGE_SECURITY_POLICY_PERMISSIVE = 1;
319 // The cluster accepts any storage security that offers encryption.
320 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION = 2;
321 // The cluster accepts any storage security that offers encryption and
322 // authentication.
323 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION_AND_AUTHENTICATION = 3;
324 // The cluster only accepts unencrypted and unauthenticated node storage.
325 STORAGE_SECURITY_POLICY_NEEDS_INSECURE = 4;
326 }
327 StorageSecurityPolicy storage_security_policy = 2;
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100328}
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100329
330// NodeTPMUsage describes whether a node has a TPM2.0 and if it is/should be
331// actively used to seal secrets before saving them to its EFI system partition.
332enum NodeTPMUsage {
333 NODE_TPM_INVALID = 0;
334 // This node has no TPM 2.0.
335 NODE_TPM_NOT_PRESENT = 1;
336 // This node has a TPM 2.0 but the cluster configuration mandates not using
337 // it.
338 NODE_TPM_PRESENT_BUT_UNUSED = 2;
339 // This node has a TPM 2.0 and it is being actively used.
340 NODE_TPM_PRESENT_AND_USED = 3;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200341}
342
343// NodeStorageSecurity describes how a node encrypts and/or authenticates its
344// local storage. In other words, it's a configuration setting for disk
345// encryption (ie. via dm-crypt) and disk integrity (ie. via dm-integrity) of
346// the Metropolis data partition.
347enum NodeStorageSecurity {
348 NODE_STORAGE_SECURITY_INVALID = 0;
349 // The node has unencrypted and unauthenticated disk storage. Its data
350 // partition is a plain XFS partition, and the node's credentials are stored
351 // on it directly.
352 NODE_STORAGE_SECURITY_INSECURE = 1;
353 // The node has encrypted but unauthenticated disk storage. Its data
354 // partition is an XFS partition mounted through dm-crypt.
355 NODE_STORAGE_SECURITY_ENCRYPTED = 2;
356 // The node has encrypted and authenticated storage. Its data
357 // partition is an XFS partition mounted through dm-integrity and dm-crypt.
358 NODE_STORAGE_SECURITY_AUTHENTICATED_ENCRYPTED = 3;
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100359}