blob: ca4bfea5d2d5bb178f86208fa87aa4252b164533 [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 {
31 message KubernetesWorker {
32 }
Serge Bazanski5839e972021-11-16 15:46:19 +010033 message ConsensusMember {
34 // ca_certificate is a DER-encoded x509 certificate of the etcd
35 // cluster's CA. The member must use this certificate to verify the
36 // identity of the cluster it's connecting to.
37 bytes ca_certificate = 1;
38 // pper_certificate is a DER-encoded x509 certificate of this node's
39 // etcd peer listener. The member must serve member traffic using this
40 // certificate. The private key corresponding to this certificate is
41 // the same as the node's primary private keypair.
42 bytes peer_certificate = 2;
43 // initial_crl is a certificate revocation list that the etcd member
44 // should be started with. After startup, the member will maintain its
45 // own CRL by updating it from its primary storage location, and etcd
46 // value.
47 //
48 // TODO(q3k): don't pass this here, instead pass this over an etcd
49 // watcher and curator.Watch.
50 bytes initial_crl = 3;
51 message Peer {
52 string Name = 1;
53 string URL = 2;
54 }
55 repeated Peer peers = 4;
56 }
Serge Bazanski30653ee2021-06-17 15:44:29 +020057 KubernetesWorker kubernetes_worker = 1;
Serge Bazanski5839e972021-11-16 15:46:19 +010058 ConsensusMember consensus_member = 2;
Serge Bazanski30653ee2021-06-17 15:44:29 +020059}
60
61// NodeState is the state of a Metropolis node from the point of view of the
62// cluster it is a part of (or intending to be a part of).
63enum NodeState {
64 NODE_STATE_INVALID = 0;
65
66 // NEW: the node has established a first contact with the cluster and
67 // intends to register into it. The node's identity has not been verified
68 // and no hardware attestation of the new node was performed.
Mateusz Zalegad57ef1c2022-07-01 12:22:33 +020069 // The node has generated a CUK/NUK and set up storage encrypted with the
Serge Bazanski30653ee2021-06-17 15:44:29 +020070 // combination of both keys.
71 // The node has generated a private/public keypair, and that keypair has
72 // been used to contact the already running Cluster.
73 NODE_STATE_NEW = 1;
74 // STANDBY: the node has successfully passed identity and hardware
75 // attestation checks as defined by the cluster policy. The node still isn't
76 // part of the cluster, as it itself might perform checks against the
77 // running Cluster.
78 NODE_STATE_STANDBY = 2;
79 // UP: the node has passed all preconditions for STANDBY and has also
80 // performed a commit into the cluster by exchanging its CUK for a
81 // certificate issued by the cluster.
82 // The node is now ready to serve, and its certificate can be used to
83 // authenticate its identity cryptographically.
84 NODE_STATE_UP = 3;
85 // DISOWNED: the node has been rejected or decommissioned by the cluster.
86 // Any further contact from the node to the cluster will be rejected.
87 NODE_STATE_DISOWNED = 4;
88};
89
90// ClusterState is the state of the cluster from the point of view of a node.
91// Different subsystems can watch this state and depend on it for behaviour
92// (eg. start serving when HOME, maybe self-fence on SPLIT, etc.).
93enum ClusterState {
94 CLUSTER_STATE_INVALID = 0;
95
96 // UNKNOWN: the node has not yet determined the existence of a cluster it
97 // should join or start. This is a transient, initial state that should only
98 // manifest during boot.
99 CLUSTER_STATE_UNKNOWN = 1;
100 // FOREIGN: the node is attempting to register into an already existing
101 // cluster with which it managed to make preliminary contact, but which the
102 // cluster has not yet fully productionized (eg. the node is still being
103 // hardware attested, or the operator needs to confirm the
104 // registration of this node).
105 CLUSTER_STATE_FOREIGN = 2;
106 // TRUSTED: the node is attempting to register into an already registered
107 // cluster, and has been trusted by it. The node is now attempting to fully
108 // commit to registering into the cluster.
109 CLUSTER_STATE_TRUSTED = 3;
110 // HOME: the node is part of this cluster. This is the bulk of time in which
111 // this node will spend its time.
112 CLUSTER_STATE_HOME = 4;
113 // DISOWNING: the node has been disowned (ie., removed) by the cluster, and
114 // that it will not be ever part of any cluster again, and that it will be
115 // decommissioned by the operator.
116 CLUSTER_STATE_DISOWNING = 5;
117 // SPLIT:the node would usually be Home in a cluster, but has been split
118 // from the consensus of the cluster. This can happen for nodes running
119 // consensus when consensus is lost (eg. when there is no quorum or this
120 // node has been netsplit), and for other nodes if they have lost network
121 // connectivity to the consensus nodes. Clients should make their own
122 // decision what action to perform in this state, depending on the level of
123 // consistency required and whether it makes sense for the node to fence its
124 // services off.
125 CLUSTER_STATE_SPLIT = 6;
126}
Serge Bazanski2893e982021-09-09 13:06:16 +0200127
128// NodeStatus contains all fields self-reported by nodes. This data is
129// inherently less trusted than other data available about a node, as it can be
130// updated to any value by each node individually, including compromised nodes.
131message NodeStatus {
132 // external_address is the IP address that the node expects management,
133 // cluster and user traffic to arrive at (ie. the address on which it is
134 // listening for gRPC, and role-specific services like etcd and
135 // Kubernetes).
136 string external_address = 1;
Serge Bazanski966d40c2022-06-23 13:27:16 +0200137 // running_curator contains information about the curator service running
138 // on this node, or is nil if the service is not running.
139 message RunningCurator {
140 // port is the TCP port on which the curator is listening.
141 int32 port = 1;
142 }
143 RunningCurator running_curator = 3;
Mateusz Zalega312a2272022-04-25 12:03:58 +0200144 // timestamp is an epoch number associated with the last status update.
145 // It's set with a nanosecond granularity.
Mateusz Zalega28800ad2022-07-08 14:56:02 +0200146 google.protobuf.Timestamp timestamp = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200147}
148
149// The Cluster Directory is information about the network addressing of nodes
150// in a cluster. It is a serialized snapshot of some of the state within the
151// etcd cluster, and can be used by external processes (like a node Registering
152// into the cluster) to know how to reach this cluster over the network. It can
153// be thought of as a phonebook, or a static name/address configuration that
154// could live in /etc/hosts.
155//
156// The directory explicitly doesn't carry any information about the cluster's
157// identity or security - these should be configured and checked by higher
158// level configuration and processes. The directory can be stored and
159// transmitted in cleartext and without an integrity checks (like saved to the
160// EFI system partition across reboots) and any malicious change to it will
161// cause no more than a denial of service against the consumer of this
162// directory. This is because all nodes contacted must present a valid cluster
163// identity/certificate before they are trusted by the consumers of this
164// directory.
165message ClusterDirectory {
166 message Node {
167 bytes public_key = 1;
168 message Address {
169 string host = 1;
170 };
Serge Bazanskibc671d02021-10-05 17:53:32 +0200171 repeated Address addresses = 2;
Serge Bazanski2893e982021-09-09 13:06:16 +0200172 };
173 repeated Node nodes = 1;
174}