blob: 27dfa5a67b645a0b0adb4e3dcaf999d1d1c94bda [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";
22
Serge Bazanski30653ee2021-06-17 15:44:29 +020023// NodeRoles are the possible roles that a Metropolis Node should run within the
24// cluster. These are configured by the cluster and can be retrieved through the
25// Curator.
Serge Bazanski5839e972021-11-16 15:46:19 +010026//
27// Fields contained within each individual are publicly available, so while they
28// can be used to carry required data to start up services for a given role,
29// this must not be confidential/private data.
Serge Bazanski30653ee2021-06-17 15:44:29 +020030message NodeRoles {
Serge Bazanski15f7f632023-03-14 17:17:20 +010031 message KubernetesController {
32 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020033 message KubernetesWorker {
34 }
Serge Bazanski5839e972021-11-16 15:46:19 +010035 message ConsensusMember {
36 // ca_certificate is a DER-encoded x509 certificate of the etcd
37 // cluster's CA. The member must use this certificate to verify the
38 // identity of the cluster it's connecting to.
39 bytes ca_certificate = 1;
40 // pper_certificate is a DER-encoded x509 certificate of this node's
41 // etcd peer listener. The member must serve member traffic using this
42 // certificate. The private key corresponding to this certificate is
43 // the same as the node's primary private keypair.
44 bytes peer_certificate = 2;
45 // initial_crl is a certificate revocation list that the etcd member
46 // should be started with. After startup, the member will maintain its
47 // own CRL by updating it from its primary storage location, and etcd
48 // value.
49 //
50 // TODO(q3k): don't pass this here, instead pass this over an etcd
51 // watcher and curator.Watch.
52 bytes initial_crl = 3;
53 message Peer {
54 string Name = 1;
55 string URL = 2;
56 }
57 repeated Peer peers = 4;
58 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020059 KubernetesWorker kubernetes_worker = 1;
Serge Bazanski5839e972021-11-16 15:46:19 +010060 ConsensusMember consensus_member = 2;
Serge Bazanski15f7f632023-03-14 17:17:20 +010061 KubernetesController kubernetes_controller = 3;
Serge Bazanski30653ee2021-06-17 15:44:29 +020062}
63
64// NodeState is the state of a Metropolis node from the point of view of the
65// cluster it is a part of (or intending to be a part of).
66enum NodeState {
67 NODE_STATE_INVALID = 0;
68
69 // NEW: the node has established a first contact with the cluster and
70 // intends to register into it. The node's identity has not been verified
71 // and no hardware attestation of the new node was performed.
Mateusz Zalegad57ef1c2022-07-01 12:22:33 +020072 // The node has generated a CUK/NUK and set up storage encrypted with the
Serge Bazanski30653ee2021-06-17 15:44:29 +020073 // combination of both keys.
74 // The node has generated a private/public keypair, and that keypair has
75 // been used to contact the already running Cluster.
76 NODE_STATE_NEW = 1;
77 // STANDBY: the node has successfully passed identity and hardware
78 // attestation checks as defined by the cluster policy. The node still isn't
79 // part of the cluster, as it itself might perform checks against the
80 // running Cluster.
81 NODE_STATE_STANDBY = 2;
82 // UP: the node has passed all preconditions for STANDBY and has also
83 // performed a commit into the cluster by exchanging its CUK for a
84 // certificate issued by the cluster.
85 // The node is now ready to serve, and its certificate can be used to
86 // authenticate its identity cryptographically.
87 NODE_STATE_UP = 3;
88 // DISOWNED: the node has been rejected or decommissioned by the cluster.
89 // Any further contact from the node to the cluster will be rejected.
90 NODE_STATE_DISOWNED = 4;
91};
92
93// ClusterState is the state of the cluster from the point of view of a node.
94// Different subsystems can watch this state and depend on it for behaviour
95// (eg. start serving when HOME, maybe self-fence on SPLIT, etc.).
96enum ClusterState {
97 CLUSTER_STATE_INVALID = 0;
98
99 // UNKNOWN: the node has not yet determined the existence of a cluster it
100 // should join or start. This is a transient, initial state that should only
101 // manifest during boot.
102 CLUSTER_STATE_UNKNOWN = 1;
103 // FOREIGN: the node is attempting to register into an already existing
104 // cluster with which it managed to make preliminary contact, but which the
105 // cluster has not yet fully productionized (eg. the node is still being
106 // hardware attested, or the operator needs to confirm the
107 // registration of this node).
108 CLUSTER_STATE_FOREIGN = 2;
109 // TRUSTED: the node is attempting to register into an already registered
110 // cluster, and has been trusted by it. The node is now attempting to fully
111 // commit to registering into the cluster.
112 CLUSTER_STATE_TRUSTED = 3;
113 // HOME: the node is part of this cluster. This is the bulk of time in which
114 // this node will spend its time.
115 CLUSTER_STATE_HOME = 4;
116 // DISOWNING: the node has been disowned (ie., removed) by the cluster, and
117 // that it will not be ever part of any cluster again, and that it will be
118 // decommissioned by the operator.
119 CLUSTER_STATE_DISOWNING = 5;
120 // SPLIT:the node would usually be Home in a cluster, but has been split
121 // from the consensus of the cluster. This can happen for nodes running
122 // consensus when consensus is lost (eg. when there is no quorum or this
123 // node has been netsplit), and for other nodes if they have lost network
124 // connectivity to the consensus nodes. Clients should make their own
125 // decision what action to perform in this state, depending on the level of
126 // consistency required and whether it makes sense for the node to fence its
127 // services off.
128 CLUSTER_STATE_SPLIT = 6;
129}
Serge Bazanski2893e982021-09-09 13:06:16 +0200130
131// NodeStatus contains all fields self-reported by nodes. This data is
132// inherently less trusted than other data available about a node, as it can be
133// updated to any value by each node individually, including compromised nodes.
134message NodeStatus {
135 // external_address is the IP address that the node expects management,
136 // cluster and user traffic to arrive at (ie. the address on which it is
137 // listening for gRPC, and role-specific services like etcd and
138 // Kubernetes).
139 string external_address = 1;
Serge Bazanski966d40c2022-06-23 13:27:16 +0200140 // running_curator contains information about the curator service running
141 // on this node, or is nil if the service is not running.
142 message RunningCurator {
143 // port is the TCP port on which the curator is listening.
144 int32 port = 1;
145 }
146 RunningCurator running_curator = 3;
Mateusz Zalega312a2272022-04-25 12:03:58 +0200147 // timestamp is an epoch number associated with the last status update.
148 // It's set with a nanosecond granularity.
Mateusz Zalega28800ad2022-07-08 14:56:02 +0200149 google.protobuf.Timestamp timestamp = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200150}
151
152// The Cluster Directory is information about the network addressing of nodes
153// in a cluster. It is a serialized snapshot of some of the state within the
154// etcd cluster, and can be used by external processes (like a node Registering
155// into the cluster) to know how to reach this cluster over the network. It can
156// be thought of as a phonebook, or a static name/address configuration that
157// could live in /etc/hosts.
158//
159// The directory explicitly doesn't carry any information about the cluster's
160// identity or security - these should be configured and checked by higher
161// level configuration and processes. The directory can be stored and
162// transmitted in cleartext and without an integrity checks (like saved to the
163// EFI system partition across reboots) and any malicious change to it will
164// cause no more than a denial of service against the consumer of this
165// directory. This is because all nodes contacted must present a valid cluster
166// identity/certificate before they are trusted by the consumers of this
167// directory.
168message ClusterDirectory {
169 message Node {
170 bytes public_key = 1;
171 message Address {
172 string host = 1;
173 };
Serge Bazanskibc671d02021-10-05 17:53:32 +0200174 repeated Address addresses = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200175 };
176 repeated Node nodes = 1;
177}
Serge Bazanskie6bc2272023-03-28 16:28:13 +0200178
179
180// NodeClusterNetworking carries information about the cluster networking (ie.
181// WireGuard mesh) connectivity of a node.
182message NodeClusterNetworking {
183 message Prefix {
184 string cidr = 1;
185 }
186 // wireguard_pubkey is the base64-encoded public key used by the node.
187 string wireguard_pubkey = 1;
188 // prefixes are networking routes exported by the node to the cluster networking
189 // mesh, and are programmed by other nodes into their wireguard peer config.
190 repeated Prefix prefixes = 2;
191}
Serge Bazanskida114862023-03-29 17:46:42 +0200192
193// Severity level corresponding to //metropolis/pkg/logtree.Severity.
194enum LeveledLogSeverity {
195 INVALID = 0;
196 INFO = 1;
197 WARNING = 2;
198 ERROR = 3;
199 FATAL = 4;
200}
201
202// Filter set when requesting logs for a given DN. This message is equivalent to
203// the following GADT enum:
204// data LogFilter = WithChildren
205// | OnlyRaw
206// | OnlyLeveled
207// | LeveledWithMinimumSeverity(Severity)
208//
209// Multiple LogFilters can be chained/combined when requesting logs, as long as
210// they do not conflict.
211message LogFilter {
212 // Entries will be returned not only for the given DN, but all child DNs as
213 // well. For instance, if the requested DN is foo, entries logged to foo,
214 // foo.bar and foo.bar.baz will all be returned.
215 message WithChildren {
216 }
217 // Only raw logging entries will be returned. Conflicts with OnlyLeveled
218 // filters.
219 message OnlyRaw {
220 }
221 // Only leveled logging entries will be returned. Conflicts with OnlyRaw
222 // filters.
223 message OnlyLeveled {
224 }
225 // If leveled logs are returned, all entries at severity lower than `minimum`
226 // will be discarded.
227 message LeveledWithMinimumSeverity {
228 LeveledLogSeverity minimum = 1;
229 }
230 oneof filter {
231 WithChildren with_children = 1;
232 OnlyRaw only_raw = 3;
233 OnlyLeveled only_leveled = 4;
234 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
235 }
236}
237
238// LogEntry corresponding to logtree.LogEntry in //metropolis/pkg/logtree.
239message LogEntry {
240 // A leveled log entry emitted from a compatible system, eg. Metorpolis code
241 // or a klog-parsed line.
242 message Leveled {
243 repeated string lines = 1;
244 google.protobuf.Timestamp timestamp = 2;
245 LeveledLogSeverity severity = 3;
246 // Source of the error, expressed as file:line.
247 string location = 4;
248 }
249 // Raw log entry, captured from an external system without parting. Might
250 // contain some timestamp/level/origin information embedded in data. Data
251 // contained within should be treated as unsanitized external data.
252 message Raw {
253 string data = 1;
254 // Original length of line, set if data was truncated.
255 int64 original_length = 2;
256 }
257
258 // Origin DN.
259 string dn = 1;
260 oneof kind {
261 Leveled leveled = 2;
262 Raw raw = 3;
263 }
264}
265
Serge Bazanski5df62ba2023-03-22 17:56:46 +0100266// ClusterConfiguration contains the entirety of the user-configurable behaviour
267// of the cluster that is scoped to the entirety of the cluster (vs. per-node
268// configuration, which is kept alongside Node).
269//
270// It can be set initially when a cluster is being bootstrapped (in
271// NodeParamaters.ClusterBootstrap), and then can be partially managed by
272// management calls to the curator.
273message ClusterConfiguration {
274 // tpm_mode defines the TPM usage policy for cluster nodes. When nodes
275 // register into the cluster (and then join into it) they will report their
276 // TPM availability, and in return the cluster will respond whether they
277 // should use that TPM or not.
278 //
279 // If a node is instructed to use its TPM, it will use it to encrypt its part
280 // of the disk encryption key when saving it to the EFI system partition.
281 // That means that the node will only be able to re-join the cluster if its
282 // secure boot configuration doesn't change.
283 //
284 // If a node is instructed to not use its TPM, it will save its part of the
285 // disk encryption key straight onto the EFI system partition without any
286 // further encryption. It still needs to connect to a working cluster to
287 // retrieve the other part of the key. This means that the configuration is
288 // secure vs. offline disk decryption attempts, but not secure if an
289 // attacker can connect to a cluster and impersonate the node in order to
290 // retrieve the other part of its key.
291 enum TPMMode {
292 TPM_MODE_INVALID = 0;
293 // Nodes need to join with a TPM2.0 device and will be instructed to
294 // use it.
295 TPM_MODE_REQUIRED = 1;
296 // Nodes will be allowed to join regardless of TPM2.0 presence, and will
297 // be instructed to use it if they have one.
298 TPM_MODE_BEST_EFFORT = 2;
299 // Regardless of the node's local TPM presence it will be instructed to
300 // not use it.
301 TPM_MODE_DISABLED = 3;
302 }
303 TPMMode tpm_mode = 1;
304}