2022-06-29 09:26:29 -04:00
|
|
|
# Bootstrapper
|
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
The bootstrapper integrates the instance it is running on as node into the Kubernetes
|
|
|
|
cluster. It is running on every new instance that is created.
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
![bootstrapper architecture](./bootstrapping_arch.svg)
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
The bootstrapper has two active components:
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
## Init Flow
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
The InitServer is a gRPC server that is listining for initialization requests.
|
|
|
|
The first instance needs to be initialized by the user, see the [initproto](./initproto)
|
|
|
|
for a description of the initialization protocol. The client that talks to this server
|
|
|
|
is part of Constellation's CLI.
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
On an initialization request, the InitServer initializes a new Kubernetes cluster, essentially
|
|
|
|
calling the InitCluster function of our Kubernetes library, which does a `kubeadm init`.
|
2022-06-29 09:26:29 -04:00
|
|
|
|
2022-07-05 08:14:11 -04:00
|
|
|
## Join Flow
|
|
|
|
|
|
|
|
The JoinClient is a gRPC client that is trying to connect to an JoinService, which might be running
|
2022-07-08 04:59:59 -04:00
|
|
|
in an already existing cluster as DaemonSet. The JoinService is validating the instance which wants to join the cluster using
|
2022-07-05 08:14:11 -04:00
|
|
|
aTLS. For details on the used protocol and the verification of a joining instances measurements, see the
|
|
|
|
[joinservice](./../joinservice) package.
|
|
|
|
|
2022-07-08 04:59:59 -04:00
|
|
|
If the JoinService successfully verifies the instance, it issues a join ticket. The JoinClient then
|
2022-07-05 08:14:11 -04:00
|
|
|
joins the cluster by calling the `kubeadm join` command, using the token and other needed information
|
|
|
|
from the join ticket.
|
|
|
|
|
|
|
|
## Synchronization, state machine, lifetime
|
|
|
|
|
|
|
|
The bootstrapper is automatically started on every new instance. Both InitServer and JoinClient are
|
|
|
|
started and running in parallel. At some point during either the initialization or the join, a shared
|
|
|
|
lock between the two components is acquired. This lock is used as point of no return. It is a state
|
|
|
|
machine with two states (unlocked, locked) and a single transition from unlocked to locked. There is no
|
|
|
|
way to unlock the node afterward (see [nodelock](./internal/nodelock) package).
|
|
|
|
|
|
|
|
After the bootstrapping, the bootstrapper is stopped.
|