blob: b870d20b5ea6d694881c534b24e01eafd6c121c8 [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
Tim Windelschmidt8814f522024-05-08 00:41:13 +020024import "metropolis/pkg/logtree/proto/logtree.proto";
25
Serge Bazanski30653ee2021-06-17 15:44:29 +020026// NodeRoles are the possible roles that a Metropolis Node should run within the
27// cluster. These are configured by the cluster and can be retrieved through the
28// Curator.
Serge Bazanski5839e972021-11-16 15:46:19 +010029//
30// Fields contained within each individual are publicly available, so while they
31// can be used to carry required data to start up services for a given role,
32// this must not be confidential/private data.
Serge Bazanski30653ee2021-06-17 15:44:29 +020033message NodeRoles {
Serge Bazanski15f7f632023-03-14 17:17:20 +010034 message KubernetesController {
35 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020036 message KubernetesWorker {
37 }
Serge Bazanski5839e972021-11-16 15:46:19 +010038 message ConsensusMember {
39 // ca_certificate is a DER-encoded x509 certificate of the etcd
40 // cluster's CA. The member must use this certificate to verify the
41 // identity of the cluster it's connecting to.
42 bytes ca_certificate = 1;
43 // pper_certificate is a DER-encoded x509 certificate of this node's
44 // etcd peer listener. The member must serve member traffic using this
45 // certificate. The private key corresponding to this certificate is
46 // the same as the node's primary private keypair.
47 bytes peer_certificate = 2;
48 // initial_crl is a certificate revocation list that the etcd member
49 // should be started with. After startup, the member will maintain its
50 // own CRL by updating it from its primary storage location, and etcd
51 // value.
52 //
53 // TODO(q3k): don't pass this here, instead pass this over an etcd
54 // watcher and curator.Watch.
55 bytes initial_crl = 3;
56 message Peer {
57 string Name = 1;
58 string URL = 2;
59 }
60 repeated Peer peers = 4;
61 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020062 KubernetesWorker kubernetes_worker = 1;
Serge Bazanski5839e972021-11-16 15:46:19 +010063 ConsensusMember consensus_member = 2;
Serge Bazanski15f7f632023-03-14 17:17:20 +010064 KubernetesController kubernetes_controller = 3;
Serge Bazanski30653ee2021-06-17 15:44:29 +020065}
66
67// NodeState is the state of a Metropolis node from the point of view of the
68// cluster it is a part of (or intending to be a part of).
69enum NodeState {
70 NODE_STATE_INVALID = 0;
71
72 // NEW: the node has established a first contact with the cluster and
73 // intends to register into it. The node's identity has not been verified
74 // and no hardware attestation of the new node was performed.
Mateusz Zalegad57ef1c2022-07-01 12:22:33 +020075 // The node has generated a CUK/NUK and set up storage encrypted with the
Serge Bazanski30653ee2021-06-17 15:44:29 +020076 // combination of both keys.
77 // The node has generated a private/public keypair, and that keypair has
78 // been used to contact the already running Cluster.
79 NODE_STATE_NEW = 1;
80 // STANDBY: the node has successfully passed identity and hardware
81 // attestation checks as defined by the cluster policy. The node still isn't
82 // part of the cluster, as it itself might perform checks against the
83 // running Cluster.
84 NODE_STATE_STANDBY = 2;
85 // UP: the node has passed all preconditions for STANDBY and has also
86 // performed a commit into the cluster by exchanging its CUK for a
87 // certificate issued by the cluster.
88 // The node is now ready to serve, and its certificate can be used to
89 // authenticate its identity cryptographically.
90 NODE_STATE_UP = 3;
Serge Bazanski7acd92d2023-10-30 18:56:00 +010091 // DECOMMISSIONED: The node has successfully been decommissioned and can be
92 // deleted.
93 //
94 // TODO(q3k): add missing -ING states.
95 NODE_STATE_DECOMMISSIONED = 4;
Serge Bazanski30653ee2021-06-17 15:44:29 +020096};
97
98// ClusterState is the state of the cluster from the point of view of a node.
99// Different subsystems can watch this state and depend on it for behaviour
100// (eg. start serving when HOME, maybe self-fence on SPLIT, etc.).
101enum ClusterState {
102 CLUSTER_STATE_INVALID = 0;
103
104 // UNKNOWN: the node has not yet determined the existence of a cluster it
105 // should join or start. This is a transient, initial state that should only
106 // manifest during boot.
107 CLUSTER_STATE_UNKNOWN = 1;
108 // FOREIGN: the node is attempting to register into an already existing
109 // cluster with which it managed to make preliminary contact, but which the
110 // cluster has not yet fully productionized (eg. the node is still being
111 // hardware attested, or the operator needs to confirm the
112 // registration of this node).
113 CLUSTER_STATE_FOREIGN = 2;
114 // TRUSTED: the node is attempting to register into an already registered
115 // cluster, and has been trusted by it. The node is now attempting to fully
116 // commit to registering into the cluster.
117 CLUSTER_STATE_TRUSTED = 3;
118 // HOME: the node is part of this cluster. This is the bulk of time in which
119 // this node will spend its time.
120 CLUSTER_STATE_HOME = 4;
121 // DISOWNING: the node has been disowned (ie., removed) by the cluster, and
122 // that it will not be ever part of any cluster again, and that it will be
123 // decommissioned by the operator.
124 CLUSTER_STATE_DISOWNING = 5;
125 // SPLIT:the node would usually be Home in a cluster, but has been split
126 // from the consensus of the cluster. This can happen for nodes running
127 // consensus when consensus is lost (eg. when there is no quorum or this
128 // node has been netsplit), and for other nodes if they have lost network
129 // connectivity to the consensus nodes. Clients should make their own
130 // decision what action to perform in this state, depending on the level of
131 // consistency required and whether it makes sense for the node to fence its
132 // services off.
133 CLUSTER_STATE_SPLIT = 6;
134}
Serge Bazanski2893e982021-09-09 13:06:16 +0200135
136// NodeStatus contains all fields self-reported by nodes. This data is
137// inherently less trusted than other data available about a node, as it can be
138// updated to any value by each node individually, including compromised nodes.
139message NodeStatus {
140 // external_address is the IP address that the node expects management,
141 // cluster and user traffic to arrive at (ie. the address on which it is
142 // listening for gRPC, and role-specific services like etcd and
143 // Kubernetes).
144 string external_address = 1;
Serge Bazanski966d40c2022-06-23 13:27:16 +0200145 // running_curator contains information about the curator service running
146 // on this node, or is nil if the service is not running.
147 message RunningCurator {
148 // port is the TCP port on which the curator is listening.
149 int32 port = 1;
150 }
151 RunningCurator running_curator = 3;
Mateusz Zalega312a2272022-04-25 12:03:58 +0200152 // timestamp is an epoch number associated with the last status update.
153 // It's set with a nanosecond granularity.
Mateusz Zalega28800ad2022-07-08 14:56:02 +0200154 google.protobuf.Timestamp timestamp = 2;
Serge Bazanski0ccc85b2023-11-20 12:59:20 +0100155 // version is the Metropolis version that this node is running.
156 version.spec.Version version = 4;
Serge Bazanski2893e982021-09-09 13:06:16 +0200157}
158
159// The Cluster Directory is information about the network addressing of nodes
160// in a cluster. It is a serialized snapshot of some of the state within the
161// etcd cluster, and can be used by external processes (like a node Registering
162// into the cluster) to know how to reach this cluster over the network. It can
163// be thought of as a phonebook, or a static name/address configuration that
164// could live in /etc/hosts.
165//
166// The directory explicitly doesn't carry any information about the cluster's
167// identity or security - these should be configured and checked by higher
168// level configuration and processes. The directory can be stored and
169// transmitted in cleartext and without an integrity checks (like saved to the
170// EFI system partition across reboots) and any malicious change to it will
171// cause no more than a denial of service against the consumer of this
172// directory. This is because all nodes contacted must present a valid cluster
173// identity/certificate before they are trusted by the consumers of this
174// directory.
175message ClusterDirectory {
176 message Node {
Serge Bazanski538292d2024-04-17 14:50:02 +0200177 string id = 3;
178 reserved 1;
Serge Bazanski2893e982021-09-09 13:06:16 +0200179 message Address {
180 string host = 1;
181 };
Serge Bazanskibc671d02021-10-05 17:53:32 +0200182 repeated Address addresses = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200183 };
184 repeated Node nodes = 1;
185}
Serge Bazanskie6bc2272023-03-28 16:28:13 +0200186
187
188// NodeClusterNetworking carries information about the cluster networking (ie.
189// WireGuard mesh) connectivity of a node.
190message NodeClusterNetworking {
191 message Prefix {
192 string cidr = 1;
193 }
194 // wireguard_pubkey is the base64-encoded public key used by the node.
195 string wireguard_pubkey = 1;
196 // prefixes are networking routes exported by the node to the cluster networking
197 // mesh, and are programmed by other nodes into their wireguard peer config.
198 repeated Prefix prefixes = 2;
199}
Serge Bazanskida114862023-03-29 17:46:42 +0200200
Serge Bazanskida114862023-03-29 17:46:42 +0200201// Filter set when requesting logs for a given DN. This message is equivalent to
202// the following GADT enum:
203// data LogFilter = WithChildren
204// | OnlyRaw
205// | OnlyLeveled
206// | LeveledWithMinimumSeverity(Severity)
207//
208// Multiple LogFilters can be chained/combined when requesting logs, as long as
209// they do not conflict.
210message LogFilter {
211 // Entries will be returned not only for the given DN, but all child DNs as
212 // well. For instance, if the requested DN is foo, entries logged to foo,
213 // foo.bar and foo.bar.baz will all be returned.
214 message WithChildren {
215 }
216 // Only raw logging entries will be returned. Conflicts with OnlyLeveled
217 // filters.
218 message OnlyRaw {
219 }
220 // Only leveled logging entries will be returned. Conflicts with OnlyRaw
221 // filters.
222 message OnlyLeveled {
223 }
224 // If leveled logs are returned, all entries at severity lower than `minimum`
225 // will be discarded.
226 message LeveledWithMinimumSeverity {
Tim Windelschmidt8814f522024-05-08 00:41:13 +0200227 metropolis.pkg.logtree.proto.LeveledLogSeverity minimum = 1;
Serge Bazanskida114862023-03-29 17:46:42 +0200228 }
229 oneof filter {
230 WithChildren with_children = 1;
231 OnlyRaw only_raw = 3;
232 OnlyLeveled only_leveled = 4;
233 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
234 }
235}
236
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100237// ClusterConfiguration contains the entirety of the user-configurable behaviour
238// of the cluster that is scoped to the entirety of the cluster (vs. per-node
239// configuration, which is kept alongside Node).
240//
241// It can be set initially when a cluster is being bootstrapped (in
242// NodeParamaters.ClusterBootstrap), and then can be partially managed by
243// management calls to the curator.
244message ClusterConfiguration {
245 // tpm_mode defines the TPM usage policy for cluster nodes. When nodes
246 // register into the cluster (and then join into it) they will report their
247 // TPM availability, and in return the cluster will respond whether they
248 // should use that TPM or not.
249 //
250 // If a node is instructed to use its TPM, it will use it to encrypt its part
251 // of the disk encryption key when saving it to the EFI system partition.
252 // That means that the node will only be able to re-join the cluster if its
253 // secure boot configuration doesn't change.
254 //
255 // If a node is instructed to not use its TPM, it will save its part of the
256 // disk encryption key straight onto the EFI system partition without any
257 // further encryption. It still needs to connect to a working cluster to
258 // retrieve the other part of the key. This means that the configuration is
259 // secure vs. offline disk decryption attempts, but not secure if an
260 // attacker can connect to a cluster and impersonate the node in order to
261 // retrieve the other part of its key.
262 enum TPMMode {
263 TPM_MODE_INVALID = 0;
264 // Nodes need to join with a TPM2.0 device and will be instructed to
265 // use it.
266 TPM_MODE_REQUIRED = 1;
267 // Nodes will be allowed to join regardless of TPM2.0 presence, and will
268 // be instructed to use it if they have one.
269 TPM_MODE_BEST_EFFORT = 2;
270 // Regardless of the node's local TPM presence it will be instructed to
271 // not use it.
272 TPM_MODE_DISABLED = 3;
273 }
274 TPMMode tpm_mode = 1;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200275
276 // storage_security_policy defines which node storage security settings are
277 // accepted by the cluster. Nodes are informed of the cluster policy when
278 // registering into the cluster, alongside a cluster-recommended storage
279 // security setting. The node then reports its selected node storage setting
280 // during its Commit call which the cluster verifies against its policy.
281 enum StorageSecurityPolicy {
282 STORAGE_SECURITY_POLICY_INVALID = 0;
283 // The cluster accepts any storage security.
284 STORAGE_SECURITY_POLICY_PERMISSIVE = 1;
285 // The cluster accepts any storage security that offers encryption.
286 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION = 2;
287 // The cluster accepts any storage security that offers encryption and
288 // authentication.
289 STORAGE_SECURITY_POLICY_NEEDS_ENCRYPTION_AND_AUTHENTICATION = 3;
290 // The cluster only accepts unencrypted and unauthenticated node storage.
291 STORAGE_SECURITY_POLICY_NEEDS_INSECURE = 4;
292 }
293 StorageSecurityPolicy storage_security_policy = 2;
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100294}
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100295
296// NodeTPMUsage describes whether a node has a TPM2.0 and if it is/should be
297// actively used to seal secrets before saving them to its EFI system partition.
298enum NodeTPMUsage {
299 NODE_TPM_INVALID = 0;
300 // This node has no TPM 2.0.
301 NODE_TPM_NOT_PRESENT = 1;
302 // This node has a TPM 2.0 but the cluster configuration mandates not using
303 // it.
304 NODE_TPM_PRESENT_BUT_UNUSED = 2;
305 // This node has a TPM 2.0 and it is being actively used.
306 NODE_TPM_PRESENT_AND_USED = 3;
Serge Bazanskifd6d4eb2023-05-25 14:45:48 +0200307}
308
309// NodeStorageSecurity describes how a node encrypts and/or authenticates its
310// local storage. In other words, it's a configuration setting for disk
311// encryption (ie. via dm-crypt) and disk integrity (ie. via dm-integrity) of
312// the Metropolis data partition.
313enum NodeStorageSecurity {
314 NODE_STORAGE_SECURITY_INVALID = 0;
315 // The node has unencrypted and unauthenticated disk storage. Its data
316 // partition is a plain XFS partition, and the node's credentials are stored
317 // on it directly.
318 NODE_STORAGE_SECURITY_INSECURE = 1;
319 // The node has encrypted but unauthenticated disk storage. Its data
320 // partition is an XFS partition mounted through dm-crypt.
321 NODE_STORAGE_SECURITY_ENCRYPTED = 2;
322 // The node has encrypted and authenticated storage. Its data
323 // partition is an XFS partition mounted through dm-integrity and dm-crypt.
324 NODE_STORAGE_SECURITY_AUTHENTICATED_ENCRYPTED = 3;
Serge Bazanskie4a4ce12023-03-22 18:29:54 +0100325}