diff --git a/.gitignore b/.gitignore index ed9b68f77c66..2629c11a9572 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,4 @@ docs/book/node_modules/ config/ci/rbac/role_binding.yaml config/ci/rbac/role.yaml config/ci/manager/manager.yaml - config/crds-v1alpha1 - diff --git a/docs/proposals/images/machine-states-preboot/Figure3.plantuml b/docs/proposals/images/machine-states-preboot/Figure3.plantuml new file mode 100644 index 000000000000..406535c3bd70 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure3.plantuml @@ -0,0 +1,58 @@ +@startuml +title Figure 3: User creates a machine with kubeadm bootstrapper +actor User + +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #lightblue +participant "Cluster API Machine Controller" +end box + +' -- GROUPS END --- + +User->"API Server":kubectl apply -f machine.yaml +"API Server"-->>"Cluster API Machine Controller": New Machine + +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Machine Controller Reconcile +activate "Cluster API Machine Controller" + + +note over "Cluster API Machine Controller": - ✅ Machine.Status.Phase is empty\n- ✅ Machine.Spec.Bootstrap.Data is \n- ✅ Machine.Spec.Bootstrap.ConfigRef is populated\n- ✅ Machine.Spec.Bootstrap.ConfigRef -> Status.Phase is not "Ready" + +opt Required only if the object hasn't been seen before +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Add watcher for \nMachine.Spec.Bootstrap.ConfigRef.Kind objects +end + +opt Required only if the object hasn't been seen before +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Add watcher for \nMachine.Spec.InfrastructureRef.Kind objects +end + +opt Required only if the object hasn't been seen before +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Add watcher for \nMachine.Spec.Bootstrap.ConfigRef.Kind objects +end + +opt Required only if the object doesn't have a Machine owner reference +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Set Machine.Spec.Bootstrap.ConfigRef -> OwnerReferences[0] to Machine +"Cluster API Machine Controller"->"API Server": Update KubeadmBootstrapConfig +"Cluster API Machine Controller"<<--"API Server": Response +end + +opt Required only if the object doesn't have a Machine owner reference +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Set Machine.Spec.InfrastructureRef -> OwnerReferences[0] to Machine +"Cluster API Machine Controller"->"API Server": Update AWSInfrastructureConfig +"Cluster API Machine Controller"<<--"API Server": Response +end + +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Set Machine.Status.Phase = "Pending" + +"Cluster API Machine Controller"->"API Server": Update Machine Status +"Cluster API Machine Controller"<<--"API Server": Response + +deactivate "Cluster API Machine Controller" + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure3.png b/docs/proposals/images/machine-states-preboot/Figure3.png index 21c004ee0854..2a12ae893aa4 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure3.png and b/docs/proposals/images/machine-states-preboot/Figure3.png differ diff --git a/docs/proposals/images/machine-states-preboot/Figure4.plantuml b/docs/proposals/images/machine-states-preboot/Figure4.plantuml new file mode 100644 index 000000000000..861889aa9365 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure4.plantuml @@ -0,0 +1,45 @@ +@startuml +title Figure 4: User creates a machine with kubeadm bootstrapper + +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #pink +participant "Kubeadm Bootstrap Controller" +end box + +' -- GROUPS END --- + +note right of "Kubeadm Bootstrap Controller":Watches KubeadmBootstrapConfig\nand Machine events with mapFunc + +"API Server"-->>"Kubeadm Bootstrap Controller": Machine Updated + +"Kubeadm Bootstrap Controller"-> "Kubeadm Bootstrap Controller":Enqueues KubeadmBootstrapConfig Reconcile + +"Kubeadm Bootstrap Controller"-> "Kubeadm Bootstrap Controller":KubeadmBootstrapConfig Controller Reconcile +activate "Kubeadm Bootstrap Controller" + +note over "Kubeadm Bootstrap Controller": - ✅ KubeadmBootstrapConfigStatus.OwnerReferences \ncontains a Machine + +"Kubeadm Bootstrap Controller"->"API Server": Get Machine +"Kubeadm Bootstrap Controller"<<--"API Server": Response + +"Kubeadm Bootstrap Controller"->"API Server": Get Cluster +"Kubeadm Bootstrap Controller"<<--"API Server": Response + +note over "Kubeadm Bootstrap Controller": - ✅ Machine.Status.Phase is "Pending" \n- ✅ Machine.Spec.Bootstrap.Data is \n- ✅ KubeadmBootstrapConfig instance is valid + +note over "Kubeadm Bootstrap Controller": Uses Cluster and Machine information\nto generate a cloud-init based script\nto be used by an infrastructure provider\nin a startup/userdata field. + +"Kubeadm Bootstrap Controller"-> "Kubeadm Bootstrap Controller":Generate bootstrap data and set\nKubeadmBootstrapConfig.Status.BootstrapData + +"Kubeadm Bootstrap Controller"-> "Kubeadm Bootstrap Controller":Set KubeadmBootstrapConfig.Status.Phase = "Ready" + +"Kubeadm Bootstrap Controller"->"API Server": Update KubeadmBootstrapConfig +"Kubeadm Bootstrap Controller"<<--"API Server": Response + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure4.png b/docs/proposals/images/machine-states-preboot/Figure4.png index 9588b3e02dab..2f8985099994 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure4.png and b/docs/proposals/images/machine-states-preboot/Figure4.png differ diff --git a/docs/proposals/images/machine-states-preboot/Figure5.plantuml b/docs/proposals/images/machine-states-preboot/Figure5.plantuml new file mode 100644 index 000000000000..a57387e1cb61 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure5.plantuml @@ -0,0 +1,37 @@ +@startuml +title Figure 5: User creates a machine with kubeadm bootstrapper + +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #lightblue +participant "Cluster API Machine Controller" +end box + +' -- GROUPS END --- + +"API Server"-->>"Cluster API Machine Controller": KubeadmBootstrapConfig updated + +"Cluster API Machine Controller"-> "Cluster API Machine Controller": Enqueue Reconcile\nfor Machine + + +"Cluster API Machine Controller"-> "Cluster API Machine Controller": Machine Controller Reconcile +activate "Cluster API Machine Controller" + +"Cluster API Machine Controller"->"API Server": Get Machine +"Cluster API Machine Controller"<<--"API Server": Response + +note over "Cluster API Machine Controller": - ✅ Machine.Status.Phase is "Pending" \n- ✅ Machine.Spec.Bootstrap.ConfigRef -> Status.Phase is "Ready"\n- ✅ Machine.Bootstrap.ConfigRef -> Status.BootstrapData is populated (not ) + +"Cluster API Machine Controller"-> "Cluster API Machine Controller": Copy Machine.Spec.Bootstrap.ConfigRef -> Status.BootstrapData\nto Machine.Spec.Bootstrap.Data + +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Set Machine.Status.Phase = "Provisioning" + +"Cluster API Machine Controller"->"API Server": Update Machine +"Cluster API Machine Controller"<<--"API Server": Response + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure5.png b/docs/proposals/images/machine-states-preboot/Figure5.png index 87c463b370e4..eb0775727f9c 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure5.png and b/docs/proposals/images/machine-states-preboot/Figure5.png differ diff --git a/docs/proposals/images/machine-states-preboot/Figure6.plantuml b/docs/proposals/images/machine-states-preboot/Figure6.plantuml new file mode 100644 index 000000000000..0cd5b8a2f46e --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure6.plantuml @@ -0,0 +1,49 @@ +@startuml +title Figure 6: User creates a machine with kubeadm bootstrapper + + +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #lightsalmon +participant "AWS Infrastructure Controller" +end box + +' -- GROUPS END --- + +entity AWS + +note over "AWS Infrastructure Controller": Watches AWSInfrastructureConfig\nand Machine events with mapFunc + +"API Server"-->>"AWS Infrastructure Controller": Machine updated + +"AWS Infrastructure Controller"-> "AWS Infrastructure Controller": Enqueues AWSInfrastructureConfig Reconcile + +"AWS Infrastructure Controller"-> "AWS Infrastructure Controller": AWSInfrastructureConfig Controller Reconcile +activate "AWS Infrastructure Controller" + +note over "AWS Infrastructure Controller": - ✅ AWSInfrastructureConfig.OwnerReferences \ncontains a Machine + +"AWS Infrastructure Controller"->"API Server": Get Machine +"AWS Infrastructure Controller"<<--"API Server": Response + +"AWS Infrastructure Controller"->"API Server": Get Cluster +"AWS Infrastructure Controller"<<--"API Server": Response + +note over "AWS Infrastructure Controller": - ✅ Machine.Status.Phase is "Provisioning" \n- ✅ Machine.Spec.Bootstrap.Data is populated (not )\n- ✅ AWS supports user-data\n- ✅ AWSInfrastructureConfig is valid\n- ✅ AWSInfrastructureConfig.Status.Phase is empty or + +"AWS Infrastructure Controller"-> "AWS Infrastructure Controller": Copy Machine.Spec.Bootstrap.Data to *ec2.RunInstancesInput + +"AWS Infrastructure Controller"-> AWS: RunInstances(*ec2.RunInstancesInput) +"AWS Infrastructure Controller"<<--AWS: Response + +"AWS Infrastructure Controller"-> "AWS Infrastructure Controller":Set AWSInfrastructureConfig.Status.Phase = "Ready" + +"AWS Infrastructure Controller"->"API Server": Update AWSInfrastructureConfig +"AWS Infrastructure Controller"<<--"API Server": Response + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure6.png b/docs/proposals/images/machine-states-preboot/Figure6.png index 6ae5f5c5ea06..8e040a09024e 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure6.png and b/docs/proposals/images/machine-states-preboot/Figure6.png differ diff --git a/docs/proposals/images/machine-states-preboot/Figure7.plantuml b/docs/proposals/images/machine-states-preboot/Figure7.plantuml new file mode 100644 index 000000000000..f8e2453dd5c1 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure7.plantuml @@ -0,0 +1,32 @@ +@startuml +title Figure 7: User creates a machine with kubeadm bootstrapper +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #lightblue +participant "Cluster API Machine Controller" +end box + + +' -- GROUPS END --- + + +"API Server"-->>"Cluster API Machine Controller": AWSInfrastructureConfig updated + +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Machine Controller Reconcile +activate "Cluster API Machine Controller" + +note over "Cluster API Machine Controller": - ✅ Machine.Status.Phase is "Provisioning" \n- ✅ Machine.Spec.InfrastructureRef -> Status.Phase is "Ready"\n- ✅ Machine.Spec.InfrastructureRef -> Status.Addresses is not empty + +"Cluster API Machine Controller"->"Cluster API Machine Controller": Set Machine.Status.Phase to "Provisioned" + +"Cluster API Machine Controller"->"API Server": Update Machine +"Cluster API Machine Controller"<--"API Server": Response + +deactivate "Cluster API Machine Controller" + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure7.png b/docs/proposals/images/machine-states-preboot/Figure7.png index 57dd716dcf43..6b391e4b6e03 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure7.png and b/docs/proposals/images/machine-states-preboot/Figure7.png differ diff --git a/docs/proposals/images/machine-states-preboot/Figure8.plantuml b/docs/proposals/images/machine-states-preboot/Figure8.plantuml new file mode 100644 index 000000000000..f03be62c96d6 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Figure8.plantuml @@ -0,0 +1,44 @@ +@startuml +title Figure 8: User creates a machine with kubeadm bootstrapper + +' -- GROUPS START --- + +box #lightgreen +participant "API Server" +end box + +box #lightblue +participant "Cluster API Machine Controller" +end box + +box #lightgreen +participant "Workload Cluster API Server" +end box + +' -- GROUPS END --- + + +"API Server"-->>"Cluster API Machine Controller": AWSInfrastructureConfig updated + +"Cluster API Machine Controller"-> "Cluster API Machine Controller":Machine Controller Reconcile +activate "Cluster API Machine Controller" + +note over "Cluster API Machine Controller": - ✅ Machine.Status.Phase is "Provisioned" \n- ✅ Machine.Spec.InfrastructureRef -> Status.Phase is "Ready"\n- ✅ Machine.Spec.InfrastructureRef -> Status.Addresses is not empty + +loop until timeout or Node's status is Ready +"Cluster API Machine Controller"->"Workload Cluster API Server": Get Node +"Cluster API Machine Controller"<<--"Workload Cluster API Server": Response +note over "Cluster API Machine Controller":Loop conditions:\n- ✅ Node.Spec.ProviderID matches Machine.Spec.ProviderID\n- ✅ Node status is "Ready" +end + +"Cluster API Machine Controller"->"Cluster API Machine Controller": Set Machine.Status.NodeRef + +"Cluster API Machine Controller"->"Cluster API Machine Controller": Set Machine.Status.Phase to "Ready" + +"Cluster API Machine Controller"->"API Server": Update Machine +"Cluster API Machine Controller"<--"API Server": Response + +deactivate "Cluster API Machine Controller" + +hide footbox +@enduml \ No newline at end of file diff --git a/docs/proposals/images/machine-states-preboot/Figure8.png b/docs/proposals/images/machine-states-preboot/Figure8.png index 3ba56922714c..9216be074c83 100644 Binary files a/docs/proposals/images/machine-states-preboot/Figure8.png and b/docs/proposals/images/machine-states-preboot/Figure8.png differ diff --git a/docs/proposals/images/machine-states-preboot/Makefile b/docs/proposals/images/machine-states-preboot/Makefile new file mode 100644 index 000000000000..d461d876c5c1 --- /dev/null +++ b/docs/proposals/images/machine-states-preboot/Makefile @@ -0,0 +1,30 @@ +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SOURCES := $(shell ls *.plantuml) +FIGURES := $(SOURCES:%.plantuml=%.png) + +figures: $(FIGURES) + +# --user ensures the output files are owned by the user invoking docker on the host +# TODO: Publish docker image owned by CAPI project: https://github.com/kubernetes-sigs/cluster-api/issues/1070 +%.png: %.plantuml + docker run \ + --rm \ + --volume ${PWD}:/figures \ + --user $(shell id --user):$(shell id --group) \ + dpf9/plantuml:1.2019.6 \ + -v /figures/$^ + +.PHONY: figures