Skip to content

Commit c45a65d

Browse files
authored
Merge pull request kubernetes-sigs#678 from akutz/feature/api-endpoint-docs
Document the API endpoint discovery process
2 parents 1e0cac1 + 981533f commit c45a65d

File tree

2 files changed

+219
-0
lines changed

2 files changed

+219
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@startuml api-endpoint-discovery
2+
3+
4+
start;
5+
6+
fork
7+
#LightGreen:CAPI ""Cluster"" controller;
8+
:""Cluster"" controller enqueues a Reconcile call;
9+
repeat
10+
if (Is the infrastructure cluster [[https://github.com/kubernetes-sigs/cluster-api/blob/81cb54579d7d4848d715d0dbeb122c7501026687/controllers/cluster_controller_phases.go#L153-L163 ready?]]) then (yes)
11+
#LightBlue:Set ""Cluster.Status.InfrastructureReady"" to ""true"";
12+
endif
13+
if (Does the infrastructure cluster have [[https://github.com/kubernetes-sigs/cluster-api/blob/81cb54579d7d4848d715d0dbeb122c7501026687/controllers/cluster_controller_phases.go#L165-L174 API endpoints?]]) then (yes)
14+
#LightBlue:Copy the infrastructure cluster resource's ""status.apiEndpoints"" value to ""Cluster.Status.APIEndpoints"";
15+
endif
16+
repeat while (Reconcile returned RequeueError) is (yes)
17+
-> no;
18+
if (Reconcile returned error) then (yes)
19+
#Pink:Error reconciling ""Cluster"";
20+
else (no)
21+
#LightBlue:""Cluster"" is ready;
22+
endif
23+
fork again
24+
#LightGreen:CABPK ""KubeadmConfig"" controller;
25+
:""KubeadmConfig"" controller enqueues a Reconcile call;
26+
repeat
27+
if (Is the ""Cluster""'s [[https://github.com/kubernetes-sigs/cluster-api/blob/81cb54579d7d4848d715d0dbeb122c7501026687/controllers/cluster_controller_phases.go#L153-L163 infrastructure ready?]]) then (yes)
28+
if (Is the control plane initialized?) then (no)
29+
if (Is the ""Machine"" a control plane node?) then (yes)
30+
if (Is there a defined control plane endpoint?) then (no)
31+
if (The ""Cluster"" resource has one or more API endpoints?) then (yes)
32+
#LightBlue:[[https://github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm/blob/af8eedbeeb919e87799e9600a06a90a60172b9ae/controllers/kubeadmconfig_controller.go#L519-L525 Copy the first API endpoint]] from the ""Cluster"" to the ""KubeadmConfig"" resource's ""Spec.ClusterConfiguration.ControlPlaneEndpoint"" field;
33+
endif
34+
endif
35+
endif
36+
endif
37+
endif
38+
repeat while (Reconcile returned RequeueError) is (yes)
39+
-> no;
40+
if (Reconcile returned error) then (yes)
41+
#Pink:Error reconciling ""KubeadmConfig"";
42+
else (no)
43+
#LightBlue:""KubeadmConfig"" is ready;
44+
endif
45+
fork again
46+
#LightGreen:CAPV ""VSphereCluster"" controller;
47+
:""VSphereCluster"" controller enqueues a Reconcile call;
48+
repeat
49+
#LightBlue:Set ""VSphereCluster.Status.Ready"" to ""true"";
50+
note right
51+
The VSphereCluster controller does not currently deploy any
52+
infrastructure, so its ""Status.Ready"" value is always ""true"".
53+
54+
This also ensures that the CABPK controller [[https://github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm/blob/af8eedbeeb919e87799e9600a06a90a60172b9ae/controllers/kubeadmconfig_controller.go#L133 is not blocked]] from
55+
generating the bootstrap data necessary to unblock the deployment
56+
of the initial control plane node for a CAPV cluster.
57+
end note
58+
if (""VSphereCluster.Status.APIEndpoints"" is empty) then (yes)
59+
:Define ""APIEndpoint"" as a variable;
60+
:Get ""VSphereMachine"" control plane resources for cluster;
61+
repeat
62+
:Get next available ""VSphereMachine"" resource;
63+
:Get ""VSphereMachine"" resource's associated ""KubeadmConfig"" resource;
64+
note right
65+
We do **not** like inspecting the ""KubeadmConfig"" resource, but we
66+
were left with no choice ([[https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/issues/555 #555]]).
67+
68+
In fact, the linked issue is where we proposed explicitly defining the
69+
""ControlPlaneEndpoint"" as part of the CAPI ""Cluster"" spec.
70+
end note
71+
if (""KubeadmConfig.Spec.ClusterConfiguration.ControlPlaneEndpoint"" is set) then (yes)
72+
#LightBlue:Set ""APIEndpoint"" to value of ""KubeadmConfig.Spec.ClusterConfiguration.ControlPlaneEndpoint"";
73+
else if (""VSphereMachine"" has a [[https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/1e0cac1efef081fd8e4c9fd050a9a5b2ba9ba9eb/api/v1alpha2/types.go#L79-L82 preferred IP address]]) then (yes)
74+
note right
75+
The concept of a //preferred// IP address is more in-depth than
76+
can be explained here, but it boils down to specifying the CIDR
77+
of the network segment from which a DHCP server is expected to
78+
provide an IP address for the VM.
79+
80+
This allows the specification of multiple network devices and still
81+
enables the client-side selection of the IP address that was decided
82+
as [[https://github.com/vmware/cloud-init-vmware-guestinfo/blob/cb9e8e4790acacb06b1f473565535f6c6f4a595c/DataSourceVMwareGuestInfo.py#L342-L413 the local IP address]] by the vSphere GuestInfo cloud-init
83+
datasource.
84+
end note
85+
#LightBlue:Set ""APIEndpoint"" to value of ""VSphereMachine""'s preferred IP address;
86+
endif
87+
repeat while (""APIEndpoint"" is empty and there is another control plane machine?) is (yes)
88+
->no;
89+
if (""APIEndpoint"" is set) then (yes)
90+
#LightBlue:Set ""VSphereCluster.Status.APIEndpoints"" to value of ""APIEndpoint"";
91+
endif
92+
endif
93+
repeat while (Reconcile returned RequeueError) is (yes)
94+
-> no;
95+
if (Reconcile returned error) then (yes)
96+
#Pink:Error reconciling ""VSphereCluster"";
97+
else (no)
98+
#LightBlue:""VSphereCluster"" is ready;
99+
endif
100+
end fork
101+
stop;
102+
103+
@enduml

docs/design/api-endpoint-discovery.svg

Lines changed: 116 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)