-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
cluster_types.go
1211 lines (982 loc) · 56.6 KB
/
cluster_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2021 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.
*/
package v1beta1
import (
"fmt"
"net"
"strings"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
capierrors "sigs.k8s.io/cluster-api/errors"
)
const (
// ClusterFinalizer is the finalizer used by the cluster controller to
// cleanup the cluster resources when a Cluster is being deleted.
ClusterFinalizer = "cluster.cluster.x-k8s.io"
// ClusterKind represents the Kind of Cluster.
ClusterKind = "Cluster"
)
// Cluster's Available condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterAvailableV1Beta2Condition is true if the Cluster is not deleted, and RemoteConnectionProbe, InfrastructureReady,
// ControlPlaneAvailable, WorkersAvailable, TopologyReconciled (if present) conditions are true.
// If conditions are defined in spec.availabilityGates, those conditions must be true as well.
// Note:
// - When summarizing TopologyReconciled, all reasons except TopologyReconcileFailed and ClusterClassNotReconciled will
// be treated as info. This is because even if topology is not fully reconciled, this is an expected temporary state
// and it doesn't impact availability.
// - When summarizing InfrastructureReady, ControlPlaneAvailable, in case the Cluster is deleting, the absence of the
// referenced object won't be considered as an issue.
ClusterAvailableV1Beta2Condition = AvailableV1Beta2Condition
// ClusterAvailableV1Beta2Reason surfaces when the cluster availability criteria is met.
ClusterAvailableV1Beta2Reason = AvailableV1Beta2Reason
// ClusterNotAvailableV1Beta2Reason surfaces when the cluster availability criteria is not met (and thus the machine is not available).
ClusterNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason
// ClusterAvailableUnknownV1Beta2Reason surfaces when at least one cluster availability criteria is unknown
// and no availability criteria is not met.
ClusterAvailableUnknownV1Beta2Reason = AvailableUnknownV1Beta2Reason
// ClusterAvailableInternalErrorV1Beta2Reason surfaces unexpected error when computing the Available condition.
ClusterAvailableInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's TopologyReconciled condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterTopologyReconciledV1Beta2Condition is true if the topology controller is working properly.
// Note: This condition is added only if the Cluster is referencing a ClusterClass / defining a managed Topology.
ClusterTopologyReconciledV1Beta2Condition = "TopologyReconciled"
// ClusterTopologyReconcileSucceededV1Beta2Reason documents the reconciliation of a Cluster topology succeeded.
ClusterTopologyReconcileSucceededV1Beta2Reason = "ReconcileSucceeded"
// ClusterTopologyReconciledFailedV1Beta2Reason documents the reconciliation of a Cluster topology
// failing due to an error.
ClusterTopologyReconciledFailedV1Beta2Reason = "ReconcileFailed"
// ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because Control Plane is not yet updated to match the desired topology spec.
ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason = "ControlPlaneUpgradePending"
// ClusterTopologyReconciledMachineDeploymentsCreatePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because at least one of the MachineDeployments is yet to be created.
// This generally happens because new MachineDeployment creations are held off while the ControlPlane is not stable.
ClusterTopologyReconciledMachineDeploymentsCreatePendingV1Beta2Reason = "MachineDeploymentsCreatePending"
// ClusterTopologyReconciledMachineDeploymentsUpgradePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because at least one of the MachineDeployments is not yet updated to match the desired topology spec.
ClusterTopologyReconciledMachineDeploymentsUpgradePendingV1Beta2Reason = "MachineDeploymentsUpgradePending"
// ClusterTopologyReconciledMachineDeploymentsUpgradeDeferredV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because the upgrade for at least one of the MachineDeployments has been deferred.
ClusterTopologyReconciledMachineDeploymentsUpgradeDeferredV1Beta2Reason = "MachineDeploymentsUpgradeDeferred"
// ClusterTopologyReconciledMachinePoolsUpgradePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because at least one of the MachinePools is not yet updated to match the desired topology spec.
ClusterTopologyReconciledMachinePoolsUpgradePendingV1Beta2Reason = "MachinePoolsUpgradePending"
// ClusterTopologyReconciledMachinePoolsCreatePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because at least one of the MachinePools is yet to be created.
// This generally happens because new MachinePool creations are held off while the ControlPlane is not stable.
ClusterTopologyReconciledMachinePoolsCreatePendingV1Beta2Reason = "MachinePoolsCreatePending"
// ClusterTopologyReconciledMachinePoolsUpgradeDeferredV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because the upgrade for at least one of the MachinePools has been deferred.
ClusterTopologyReconciledMachinePoolsUpgradeDeferredV1Beta2Reason = "MachinePoolsUpgradeDeferred"
// ClusterTopologyReconciledHookBlockingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because at least one of the lifecycle hooks is blocking.
ClusterTopologyReconciledHookBlockingV1Beta2Reason = "LifecycleHookBlocking"
// ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason documents reconciliation of a Cluster topology not
// yet completed because the ClusterClass has not reconciled yet. If this condition persists there may be an issue
// with the ClusterClass surfaced in the ClusterClass status or controller logs.
ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason = "ClusterClassNotReconciled"
// ClusterTopologyReconciledDeletingV1Beta2Reason surfaces when the Cluster is deleting because the
// DeletionTimestamp is set.
ClusterTopologyReconciledDeletingV1Beta2Reason = DeletingV1Beta2Reason
// ClusterTopologyReconcilePausedV1Beta2Reason surfaces when the Cluster is paused.
ClusterTopologyReconcilePausedV1Beta2Reason = PausedV1Beta2Reason
)
// Cluster's InfrastructureReady condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterInfrastructureReadyV1Beta2Condition mirrors Cluster's infrastructure Ready condition.
ClusterInfrastructureReadyV1Beta2Condition = InfrastructureReadyV1Beta2Condition
// ClusterInfrastructureReadyV1Beta2Reason surfaces when the cluster infrastructure is ready.
ClusterInfrastructureReadyV1Beta2Reason = ReadyV1Beta2Reason
// ClusterInfrastructureNotReadyV1Beta2Reason surfaces when the cluster infrastructure is not ready.
ClusterInfrastructureNotReadyV1Beta2Reason = NotReadyV1Beta2Reason
// ClusterInfrastructureInvalidConditionReportedV1Beta2Reason surfaces a infrastructure Ready condition (read from an infra cluster object) which is invalid
// (e.g. its status is missing).
ClusterInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
// ClusterInfrastructureInternalErrorV1Beta2Reason surfaces unexpected failures when reading an infra cluster object.
ClusterInfrastructureInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
// ClusterInfrastructureDoesNotExistV1Beta2Reason surfaces when a referenced infrastructure object does not exist.
// Note: this could happen when creating the Cluster. However, this state should be treated as an error if it lasts indefinitely.
ClusterInfrastructureDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
// ClusterInfrastructureDeletedV1Beta2Reason surfaces when a referenced infrastructure object has been deleted.
// Note: controllers can't identify if the infrastructure object was deleted by the controller itself, e.g.
// during the deletion workflow, or by a users.
ClusterInfrastructureDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
)
// Cluster's ControlPlaneInitialized condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterControlPlaneInitializedV1Beta2Condition is true when the Cluster's control plane is functional enough
// to accept requests. This information is usually used as a signal for starting all the provisioning operations
// that depends on a functional API server, but do not require a full HA control plane to exists.
// Note: Once set to true, this condition will never change.
ClusterControlPlaneInitializedV1Beta2Condition = "ControlPlaneInitialized"
// ClusterControlPlaneInitializedV1Beta2Reason surfaces when the cluster control plane is initialized.
ClusterControlPlaneInitializedV1Beta2Reason = "Initialized"
// ClusterControlPlaneNotInitializedV1Beta2Reason surfaces when the cluster control plane is not yet initialized.
ClusterControlPlaneNotInitializedV1Beta2Reason = "NotInitialized"
// ClusterControlPlaneInitializedInternalErrorV1Beta2Reason surfaces unexpected failures when computing the
// ControlPlaneInitialized condition.
ClusterControlPlaneInitializedInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's ControlPlaneAvailable condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterControlPlaneAvailableV1Beta2Condition is a mirror of Cluster's control plane Available condition.
ClusterControlPlaneAvailableV1Beta2Condition = "ControlPlaneAvailable"
// ClusterControlPlaneAvailableV1Beta2Reason surfaces when the cluster control plane is available.
ClusterControlPlaneAvailableV1Beta2Reason = AvailableV1Beta2Reason
// ClusterControlPlaneNotAvailableV1Beta2Reason surfaces when the cluster control plane is not available.
ClusterControlPlaneNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason
// ClusterControlPlaneInvalidConditionReportedV1Beta2Reason surfaces a control plane Available condition (read from a control plane object) which is invalid.
// (e.g. its status is missing).
ClusterControlPlaneInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
// ClusterControlPlaneInternalErrorV1Beta2Reason surfaces unexpected failures when reading a control plane object.
ClusterControlPlaneInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
// ClusterControlPlaneDoesNotExistV1Beta2Reason surfaces when a referenced control plane object does not exist.
// Note: this could happen when creating the Cluster. However, this state should be treated as an error if it lasts indefinitely.
ClusterControlPlaneDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
// ClusterControlPlaneDeletedV1Beta2Reason surfaces when a referenced control plane object has been deleted.
// Note: controllers can't identify if the control plane object was deleted by the controller itself, e.g.
// during the deletion workflow, or by a users.
ClusterControlPlaneDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
)
// Cluster's WorkersAvailable condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterWorkersAvailableV1Beta2Condition is the summary of MachineDeployment and MachinePool's Available conditions.
// Note: Stand-alone MachineSets and stand-alone Machines are not included in this condition.
ClusterWorkersAvailableV1Beta2Condition = "WorkersAvailable"
// ClusterWorkersAvailableV1Beta2Reason surfaces when all MachineDeployment and MachinePool's Available conditions are true.
ClusterWorkersAvailableV1Beta2Reason = AvailableV1Beta2Reason
// ClusterWorkersNotAvailableV1Beta2Reason surfaces when at least one of the MachineDeployment and MachinePool's Available
// conditions is false.
ClusterWorkersNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason
// ClusterWorkersAvailableUnknownV1Beta2Reason surfaces when at least one of the MachineDeployment and MachinePool's Available
// conditions is unknown and none of those Available conditions is false.
ClusterWorkersAvailableUnknownV1Beta2Reason = AvailableUnknownV1Beta2Reason
// ClusterWorkersAvailableNoWorkersV1Beta2Reason surfaces when no MachineDeployment and MachinePool exist for the Cluster.
ClusterWorkersAvailableNoWorkersV1Beta2Reason = "NoWorkers"
// ClusterWorkersAvailableInternalErrorV1Beta2Reason surfaces unexpected failures when listing MachineDeployment and MachinePool
// or aggregating conditions from those objects.
ClusterWorkersAvailableInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's ControlPlaneMachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterControlPlaneMachinesReadyV1Beta2Condition surfaces detail of issues on control plane machines, if any.
ClusterControlPlaneMachinesReadyV1Beta2Condition = "ControlPlaneMachinesReady"
// ClusterControlPlaneMachinesReadyV1Beta2Reason surfaces when all control plane machine's Ready conditions are true.
ClusterControlPlaneMachinesReadyV1Beta2Reason = ReadyV1Beta2Reason
// ClusterControlPlaneMachinesNotReadyV1Beta2Reason surfaces when at least one of control plane machine's Ready conditions is false.
ClusterControlPlaneMachinesNotReadyV1Beta2Reason = NotReadyV1Beta2Reason
// ClusterControlPlaneMachinesReadyUnknownV1Beta2Reason surfaces when at least one of control plane machine's Ready conditions is unknown
// and none of control plane machine's Ready conditions is false.
ClusterControlPlaneMachinesReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason
// ClusterControlPlaneMachinesReadyNoReplicasV1Beta2Reason surfaces when no control plane machines exist for the Cluster.
ClusterControlPlaneMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
// ClusterControlPlaneMachinesReadyInternalErrorV1Beta2Reason surfaces unexpected failures when listing control plane machines
// or aggregating control plane machine's conditions.
ClusterControlPlaneMachinesReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's WorkerMachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterWorkerMachinesReadyV1Beta2Condition surfaces detail of issues on the worker machines, if any.
ClusterWorkerMachinesReadyV1Beta2Condition = "WorkerMachinesReady"
// ClusterWorkerMachinesReadyV1Beta2Reason surfaces when all the worker machine's Ready conditions are true.
ClusterWorkerMachinesReadyV1Beta2Reason = ReadyV1Beta2Reason
// ClusterWorkerMachinesNotReadyV1Beta2Reason surfaces when at least one of the worker machine's Ready conditions is false.
ClusterWorkerMachinesNotReadyV1Beta2Reason = NotReadyV1Beta2Reason
// ClusterWorkerMachinesReadyUnknownV1Beta2Reason surfaces when at least one of the worker machine's Ready conditions is unknown
// and none of the worker machine's Ready conditions is false.
ClusterWorkerMachinesReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason
// ClusterWorkerMachinesReadyNoReplicasV1Beta2Reason surfaces when no worker machines exist for the Cluster.
ClusterWorkerMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
// ClusterWorkerMachinesReadyInternalErrorV1Beta2Reason surfaces unexpected failures when listing worker machines
// or aggregating worker machine's conditions.
ClusterWorkerMachinesReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's ControlPlaneMachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterControlPlaneMachinesUpToDateV1Beta2Condition surfaces details of control plane machines not up to date, if any.
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
ClusterControlPlaneMachinesUpToDateV1Beta2Condition = "ControlPlaneMachinesUpToDate"
// ClusterControlPlaneMachinesUpToDateV1Beta2Reason surfaces when all the control plane machine's UpToDate conditions are true.
ClusterControlPlaneMachinesUpToDateV1Beta2Reason = UpToDateV1Beta2Reason
// ClusterControlPlaneMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the control plane machine's UpToDate conditions is false.
ClusterControlPlaneMachinesNotUpToDateV1Beta2Reason = NotUpToDateV1Beta2Reason
// ClusterControlPlaneMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the control plane machine's UpToDate conditions is unknown
// and none of the control plane machine's UpToDate conditions is false.
ClusterControlPlaneMachinesUpToDateUnknownV1Beta2Reason = UpToDateUnknownV1Beta2Reason
// ClusterControlPlaneMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no control plane machines exist for the Cluster.
ClusterControlPlaneMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
// ClusterControlPlaneMachinesUpToDateInternalErrorV1Beta2Reason surfaces unexpected failures when listing control plane machines
// or aggregating status.
ClusterControlPlaneMachinesUpToDateInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's WorkerMachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterWorkerMachinesUpToDateV1Beta2Condition surfaces details of worker machines not up to date, if any.
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
ClusterWorkerMachinesUpToDateV1Beta2Condition = "WorkerMachinesUpToDate"
// ClusterWorkerMachinesUpToDateV1Beta2Reason surfaces when all the worker machine's UpToDate conditions are true.
ClusterWorkerMachinesUpToDateV1Beta2Reason = UpToDateV1Beta2Reason
// ClusterWorkerMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the worker machine's UpToDate conditions is false.
ClusterWorkerMachinesNotUpToDateV1Beta2Reason = NotUpToDateV1Beta2Reason
// ClusterWorkerMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the worker machine's UpToDate conditions is unknown
// and none of the worker machine's UpToDate conditions is false.
ClusterWorkerMachinesUpToDateUnknownV1Beta2Reason = UpToDateUnknownV1Beta2Reason
// ClusterWorkerMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no worker machines exist for the Cluster.
ClusterWorkerMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
// ClusterWorkerMachinesUpToDateInternalErrorV1Beta2Reason surfaces unexpected failures when listing worker machines
// or aggregating status.
ClusterWorkerMachinesUpToDateInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's RemoteConnectionProbe condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterRemoteConnectionProbeV1Beta2Condition is true when control plane can be reached; in case of connection problems.
// The condition turns to false only if the cluster cannot be reached for 50s after the first connection problem
// is detected (or whatever period is defined in the --remote-connection-grace-period flag).
ClusterRemoteConnectionProbeV1Beta2Condition = "RemoteConnectionProbe"
// ClusterRemoteConnectionProbeFailedV1Beta2Reason surfaces issues with the connection to the workload cluster.
ClusterRemoteConnectionProbeFailedV1Beta2Reason = "ProbeFailed"
// ClusterRemoteConnectionProbeSucceededV1Beta2Reason is used to report a working connection with the workload cluster.
ClusterRemoteConnectionProbeSucceededV1Beta2Reason = "ProbeSucceeded"
)
// Cluster's RollingOut condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterRollingOutV1Beta2Condition is the summary of `RollingOut` conditions from ControlPlane, MachineDeployments
// and MachinePools.
ClusterRollingOutV1Beta2Condition = RollingOutV1Beta2Condition
// ClusterRollingOutV1Beta2Reason surfaces when at least one of the Cluster's control plane, MachineDeployments,
// or MachinePools are rolling out.
ClusterRollingOutV1Beta2Reason = RollingOutV1Beta2Reason
// ClusterNotRollingOutV1Beta2Reason surfaces when none of the Cluster's control plane, MachineDeployments,
// or MachinePools are rolling out.
ClusterNotRollingOutV1Beta2Reason = NotRollingOutV1Beta2Reason
// ClusterRollingOutUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// or MachinePools rolling out condition is unknown, and none true.
ClusterRollingOutUnknownV1Beta2Reason = "RollingOutUnknown"
// ClusterRollingOutInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or computing the RollingOut condition.
ClusterRollingOutInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterScalingUpV1Beta2Condition is the summary of `ScalingUp` conditions from ControlPlane, MachineDeployments,
// MachinePools and stand-alone MachineSets.
ClusterScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
// ClusterScalingUpV1Beta2Reason surfaces when at least one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling up.
ClusterScalingUpV1Beta2Reason = ScalingUpV1Beta2Reason
// ClusterNotScalingUpV1Beta2Reason surfaces when none of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling up.
ClusterNotScalingUpV1Beta2Reason = NotScalingUpV1Beta2Reason
// ClusterScalingUpUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets scaling up condition is unknown, and none true.
ClusterScalingUpUnknownV1Beta2Reason = "ScalingUpUnknown"
// ClusterScalingUpInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or computing the ScalingUp condition.
ClusterScalingUpInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's ScalingDown condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterScalingDownV1Beta2Condition is the summary of `ScalingDown` conditions from ControlPlane, MachineDeployments,
// MachinePools and stand-alone MachineSets.
ClusterScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition
// ClusterScalingDownV1Beta2Reason surfaces when at least one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling down.
ClusterScalingDownV1Beta2Reason = ScalingDownV1Beta2Reason
// ClusterNotScalingDownV1Beta2Reason surfaces when none of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling down.
ClusterNotScalingDownV1Beta2Reason = NotScalingDownV1Beta2Reason
// ClusterScalingDownUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets scaling down condition is unknown, and none true.
ClusterScalingDownUnknownV1Beta2Reason = "ScalingDownUnknown"
// ClusterScalingDownInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or computing the ScalingDown condition.
ClusterScalingDownInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's Remediating condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterRemediatingV1Beta2Condition surfaces details about ongoing remediation of the controlled machines, if any.
ClusterRemediatingV1Beta2Condition = RemediatingV1Beta2Condition
// ClusterRemediatingV1Beta2Reason surfaces when the Cluster has at least one machine with HealthCheckSucceeded set to false
// and with the OwnerRemediated condition set to false.
ClusterRemediatingV1Beta2Reason = RemediatingV1Beta2Reason
// ClusterNotRemediatingV1Beta2Reason surfaces when the Cluster does not have any machine with HealthCheckSucceeded set to false
// and with the OwnerRemediated condition set to false.
ClusterNotRemediatingV1Beta2Reason = NotRemediatingV1Beta2Reason
// ClusterRemediatingInternalErrorV1Beta2Reason surfaces unexpected failures when computing the Remediating condition.
ClusterRemediatingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// Cluster's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// ClusterDeletingV1Beta2Condition surfaces details about ongoing deletion of the cluster.
ClusterDeletingV1Beta2Condition = DeletingV1Beta2Condition
// ClusterNotDeletingV1Beta2Reason surfaces when the Cluster is not deleting because the
// DeletionTimestamp is not set.
ClusterNotDeletingV1Beta2Reason = NotDeletingV1Beta2Reason
// ClusterDeletingWaitingForBeforeDeleteHookV1Beta2Reason surfaces when the Cluster deletion
// waits for the ClusterDelete hooks to allow deletion to complete.
ClusterDeletingWaitingForBeforeDeleteHookV1Beta2Reason = "WaitingForBeforeDeleteHook"
// ClusterDeletingWaitingForWorkersDeletionV1Beta2Reason surfaces when the Cluster deletion
// waits for the workers Machines and the object controlling those machines (MachinePools, MachineDeployments, MachineSets)
// to be deleted.
ClusterDeletingWaitingForWorkersDeletionV1Beta2Reason = "WaitingForWorkersDeletion"
// ClusterDeletingWaitingForControlPlaneDeletionV1Beta2Reason surfaces when the Cluster deletion
// waits for the ControlPlane to be deleted.
ClusterDeletingWaitingForControlPlaneDeletionV1Beta2Reason = "WaitingForControlPlaneDeletion"
// ClusterDeletingWaitingForInfrastructureDeletionV1Beta2Reason surfaces when the Cluster deletion
// waits for the InfraCluster to be deleted.
ClusterDeletingWaitingForInfrastructureDeletionV1Beta2Reason = "WaitingForInfrastructureDeletion"
// ClusterDeletingDeletionCompletedV1Beta2Reason surfaces when the Cluster deletion has been completed.
// This reason is set right after the `cluster.cluster.x-k8s.io` finalizer is removed.
// This means that the object will go away (i.e. be removed from etcd), except if there are other
// finalizers on the Cluster object.
ClusterDeletingDeletionCompletedV1Beta2Reason = DeletionCompletedV1Beta2Reason
// ClusterDeletingInternalErrorV1Beta2Reason surfaces unexpected failures when deleting a cluster.
ClusterDeletingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
// ANCHOR: ClusterSpec
// ClusterSpec defines the desired state of Cluster.
type ClusterSpec struct {
// paused can be used to prevent controllers from processing the Cluster and all its associated objects.
// +optional
Paused bool `json:"paused,omitempty"`
// Cluster network configuration.
// +optional
ClusterNetwork *ClusterNetwork `json:"clusterNetwork,omitempty"`
// controlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint APIEndpoint `json:"controlPlaneEndpoint,omitempty"`
// controlPlaneRef is an optional reference to a provider-specific resource that holds
// the details for provisioning the Control Plane for a Cluster.
// +optional
ControlPlaneRef *corev1.ObjectReference `json:"controlPlaneRef,omitempty"`
// infrastructureRef is a reference to a provider-specific resource that holds the details
// for provisioning infrastructure for a cluster in said provider.
// +optional
InfrastructureRef *corev1.ObjectReference `json:"infrastructureRef,omitempty"`
// This encapsulates the topology for the cluster.
// NOTE: It is required to enable the ClusterTopology
// feature gate flag to activate managed topologies support;
// this feature is highly experimental, and parts of it might still be not implemented.
// +optional
Topology *Topology `json:"topology,omitempty"`
// availabilityGates specifies additional conditions to include when evaluating Cluster Available condition.
//
// NOTE: this field is considered only for computing v1beta2 conditions.
// +optional
// +listType=map
// +listMapKey=conditionType
// +kubebuilder:validation:MaxItems=32
AvailabilityGates []ClusterAvailabilityGate `json:"availabilityGates,omitempty"`
}
// ClusterAvailabilityGate contains the type of a Cluster condition to be used as availability gate.
type ClusterAvailabilityGate struct {
// conditionType refers to a positive polarity condition (status true means good) with matching type in the Cluster's condition list.
// If the conditions doesn't exist, it will be treated as unknown.
// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as availability gates.
// +required
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
// +kubebuilder:validation:MaxLength=316
// +kubebuilder:validation:MinLength=1
ConditionType string `json:"conditionType"`
}
// Topology encapsulates the information of the managed resources.
type Topology struct {
// The name of the ClusterClass object to create the topology.
Class string `json:"class"`
// The Kubernetes version of the cluster.
Version string `json:"version"`
// rolloutAfter performs a rollout of the entire cluster one component at a time,
// control plane first and then machine deployments.
//
// Deprecated: This field has no function and is going to be removed in the next apiVersion.
//
// +optional
RolloutAfter *metav1.Time `json:"rolloutAfter,omitempty"`
// controlPlane describes the cluster control plane.
// +optional
ControlPlane ControlPlaneTopology `json:"controlPlane,omitempty"`
// workers encapsulates the different constructs that form the worker nodes
// for the cluster.
// +optional
Workers *WorkersTopology `json:"workers,omitempty"`
// variables can be used to customize the Cluster through
// patches. They must comply to the corresponding
// VariableClasses defined in the ClusterClass.
// +optional
// +listType=map
// +listMapKey=name
Variables []ClusterVariable `json:"variables,omitempty"`
}
// ControlPlaneTopology specifies the parameters for the control plane nodes in the cluster.
type ControlPlaneTopology struct {
// metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane
// if the ControlPlaneTemplate referenced by the ClusterClass is machine based. If not, it
// is applied only to the ControlPlane.
// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
// +optional
Metadata ObjectMeta `json:"metadata,omitempty"`
// replicas is the number of control plane nodes.
// If the value is nil, the ControlPlane object is created without the number of Replicas
// and it's assumed that the control plane controller does not implement support for this field.
// When specified against a control plane provider that lacks support for this field, this value will be ignored.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// machineHealthCheck allows to enable, disable and override
// the MachineHealthCheck configuration in the ClusterClass for this control plane.
// +optional
MachineHealthCheck *MachineHealthCheckTopology `json:"machineHealthCheck,omitempty"`
// nodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
// nodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
// nodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
// Defaults to 10 seconds.
// +optional
NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
// variables can be used to customize the ControlPlane through patches.
// +optional
Variables *ControlPlaneVariables `json:"variables,omitempty"`
}
// WorkersTopology represents the different sets of worker nodes in the cluster.
type WorkersTopology struct {
// machineDeployments is a list of machine deployments in the cluster.
// +optional
// +listType=map
// +listMapKey=name
MachineDeployments []MachineDeploymentTopology `json:"machineDeployments,omitempty"`
// machinePools is a list of machine pools in the cluster.
// +optional
// +listType=map
// +listMapKey=name
MachinePools []MachinePoolTopology `json:"machinePools,omitempty"`
}
// MachineDeploymentTopology specifies the different parameters for a set of worker nodes in the topology.
// This set of nodes is managed by a MachineDeployment object whose lifecycle is managed by the Cluster controller.
type MachineDeploymentTopology struct {
// metadata is the metadata applied to the MachineDeployment and the machines of the MachineDeployment.
// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
// +optional
Metadata ObjectMeta `json:"metadata,omitempty"`
// class is the name of the MachineDeploymentClass used to create the set of worker nodes.
// This should match one of the deployment classes defined in the ClusterClass object
// mentioned in the `Cluster.Spec.Class` field.
Class string `json:"class"`
// name is the unique identifier for this MachineDeploymentTopology.
// The value is used with other unique identifiers to create a MachineDeployment's Name
// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
// the values are hashed together.
Name string `json:"name"`
// failureDomain is the failure domain the machines will be created in.
// Must match a key in the FailureDomains map stored on the cluster object.
// +optional
FailureDomain *string `json:"failureDomain,omitempty"`
// replicas is the number of worker nodes belonging to this set.
// If the value is nil, the MachineDeployment is created without the number of Replicas (defaulting to 1)
// and it's assumed that an external entity (like cluster autoscaler) is responsible for the management
// of this value.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// machineHealthCheck allows to enable, disable and override
// the MachineHealthCheck configuration in the ClusterClass for this MachineDeployment.
// +optional
MachineHealthCheck *MachineHealthCheckTopology `json:"machineHealthCheck,omitempty"`
// nodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
// nodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
// nodeDeletionTimeout defines how long the controller will attempt to delete the Node that the Machine
// hosts after the Machine is marked for deletion. A duration of 0 will retry deletion indefinitely.
// Defaults to 10 seconds.
// +optional
NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
// Minimum number of seconds for which a newly created machine should
// be ready.
// Defaults to 0 (machine will be considered available as soon as it
// is ready)
// +optional
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`
// The deployment strategy to use to replace existing machines with
// new ones.
// +optional
Strategy *MachineDeploymentStrategy `json:"strategy,omitempty"`
// variables can be used to customize the MachineDeployment through patches.
// +optional
Variables *MachineDeploymentVariables `json:"variables,omitempty"`
}
// MachineHealthCheckTopology defines a MachineHealthCheck for a group of machines.
type MachineHealthCheckTopology struct {
// enable controls if a MachineHealthCheck should be created for the target machines.
//
// If false: No MachineHealthCheck will be created.
//
// If not set(default): A MachineHealthCheck will be created if it is defined here or
// in the associated ClusterClass. If no MachineHealthCheck is defined then none will be created.
//
// If true: A MachineHealthCheck is guaranteed to be created. Cluster validation will
// block if `enable` is true and no MachineHealthCheck definition is available.
// +optional
Enable *bool `json:"enable,omitempty"`
// MachineHealthCheckClass defines a MachineHealthCheck for a group of machines.
// If specified (any field is set), it entirely overrides the MachineHealthCheckClass defined in ClusterClass.
MachineHealthCheckClass `json:",inline"`
}
// MachinePoolTopology specifies the different parameters for a pool of worker nodes in the topology.
// This pool of nodes is managed by a MachinePool object whose lifecycle is managed by the Cluster controller.
type MachinePoolTopology struct {
// metadata is the metadata applied to the MachinePool.
// At runtime this metadata is merged with the corresponding metadata from the ClusterClass.
// +optional
Metadata ObjectMeta `json:"metadata,omitempty"`
// class is the name of the MachinePoolClass used to create the pool of worker nodes.
// This should match one of the deployment classes defined in the ClusterClass object
// mentioned in the `Cluster.Spec.Class` field.
Class string `json:"class"`
// name is the unique identifier for this MachinePoolTopology.
// The value is used with other unique identifiers to create a MachinePool's Name
// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
// the values are hashed together.
Name string `json:"name"`
// failureDomains is the list of failure domains the machine pool will be created in.
// Must match a key in the FailureDomains map stored on the cluster object.
// +optional
FailureDomains []string `json:"failureDomains,omitempty"`
// nodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
// nodeVolumeDetachTimeout is the total amount of time that the controller will spend on waiting for all volumes
// to be detached. The default value is 0, meaning that the volumes can be detached without any time limitations.
// +optional
NodeVolumeDetachTimeout *metav1.Duration `json:"nodeVolumeDetachTimeout,omitempty"`
// nodeDeletionTimeout defines how long the controller will attempt to delete the Node that the MachinePool
// hosts after the MachinePool is marked for deletion. A duration of 0 will retry deletion indefinitely.
// Defaults to 10 seconds.
// +optional
NodeDeletionTimeout *metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
// Minimum number of seconds for which a newly created machine pool should
// be ready.
// Defaults to 0 (machine will be considered available as soon as it
// is ready)
// +optional
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`
// replicas is the number of nodes belonging to this pool.
// If the value is nil, the MachinePool is created without the number of Replicas (defaulting to 1)
// and it's assumed that an external entity (like cluster autoscaler) is responsible for the management
// of this value.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// variables can be used to customize the MachinePool through patches.
// +optional
Variables *MachinePoolVariables `json:"variables,omitempty"`
}
// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a
// Variable definition in the ClusterClass `status` variables.
type ClusterVariable struct {
// name of the variable.
Name string `json:"name"`
// definitionFrom specifies where the definition of this Variable is from.
//
// Deprecated: This field is deprecated, must not be set anymore and is going to be removed in the next apiVersion.
//
// +optional
DefinitionFrom string `json:"definitionFrom,omitempty"`
// value of the variable.
// Note: the value will be validated against the schema of the corresponding ClusterClassVariable
// from the ClusterClass.
// Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a
// hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools,
// i.e. it is not possible to have no type field.
// Ref: https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111
Value apiextensionsv1.JSON `json:"value"`
}
// ControlPlaneVariables can be used to provide variables for the ControlPlane.
type ControlPlaneVariables struct {
// overrides can be used to override Cluster level variables.
// +optional
// +listType=map
// +listMapKey=name
Overrides []ClusterVariable `json:"overrides,omitempty"`
}
// MachineDeploymentVariables can be used to provide variables for a specific MachineDeployment.
type MachineDeploymentVariables struct {
// overrides can be used to override Cluster level variables.
// +optional
// +listType=map
// +listMapKey=name
Overrides []ClusterVariable `json:"overrides,omitempty"`
}
// MachinePoolVariables can be used to provide variables for a specific MachinePool.
type MachinePoolVariables struct {
// overrides can be used to override Cluster level variables.
// +optional
// +listType=map
// +listMapKey=name
Overrides []ClusterVariable `json:"overrides,omitempty"`
}
// ANCHOR_END: ClusterSpec
// ANCHOR: ClusterNetwork
// ClusterNetwork specifies the different networking
// parameters for a cluster.
type ClusterNetwork struct {
// apiServerPort specifies the port the API Server should bind to.
// Defaults to 6443.
// +optional
APIServerPort *int32 `json:"apiServerPort,omitempty"`
// The network ranges from which service VIPs are allocated.
// +optional
Services *NetworkRanges `json:"services,omitempty"`
// The network ranges from which Pod networks are allocated.
// +optional
Pods *NetworkRanges `json:"pods,omitempty"`
// Domain name for services.
// +optional
ServiceDomain string `json:"serviceDomain,omitempty"`
}
// ANCHOR_END: ClusterNetwork
// ANCHOR: NetworkRanges
// NetworkRanges represents ranges of network addresses.
type NetworkRanges struct {
CIDRBlocks []string `json:"cidrBlocks"`
}
func (n NetworkRanges) String() string {
if len(n.CIDRBlocks) == 0 {
return ""
}
return strings.Join(n.CIDRBlocks, ",")
}
// ANCHOR_END: NetworkRanges
// ANCHOR: ClusterStatus
// ClusterStatus defines the observed state of Cluster.
type ClusterStatus struct {
// failureDomains is a slice of failure domain objects synced from the infrastructure provider.
// +optional
FailureDomains FailureDomains `json:"failureDomains,omitempty"`
// failureReason indicates that there is a fatal problem reconciling the
// state, and will be set to a token value suitable for
// programmatic interpretation.
//
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
// +optional
FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"`
// failureMessage indicates that there is a fatal problem reconciling the
// state, and will be set to a descriptive error message.
//
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`
// phase represents the current phase of cluster actuation.
// E.g. Pending, Running, Terminating, Failed etc.
// +optional
Phase string `json:"phase,omitempty"`
// infrastructureReady is the state of the infrastructure provider.
// +optional
InfrastructureReady bool `json:"infrastructureReady"`
// controlPlaneReady denotes if the control plane became ready during initial provisioning
// to receive requests.
// NOTE: this field is part of the Cluster API contract and it is used to orchestrate provisioning.
// The value of this field is never updated after provisioning is completed. Please use conditions
// to check the operational state of the control plane.
// +optional
ControlPlaneReady bool `json:"controlPlaneReady"`
// conditions defines current service state of the cluster.
// +optional
Conditions Conditions `json:"conditions,omitempty"`
// observedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// v1beta2 groups all the fields that will be added or modified in Cluster's status with the V1Beta2 version.
// +optional
V1Beta2 *ClusterV1Beta2Status `json:"v1beta2,omitempty"`
}
// ClusterV1Beta2Status groups all the fields that will be added or modified in Cluster with the V1Beta2 version.
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
type ClusterV1Beta2Status struct {
// conditions represents the observations of a Cluster's current state.
// Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady
// MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused.
// Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology.
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=32
Conditions []metav1.Condition `json:"conditions,omitempty"`
// controlPlane groups all the observations about Cluster's ControlPlane current state.
// +optional
ControlPlane *ClusterControlPlaneStatus `json:"controlPlane,omitempty"`
// workers groups all the observations about Cluster's Workers current state.
// +optional
Workers *WorkersStatus `json:"workers,omitempty"`
}
// ClusterControlPlaneStatus groups all the observations about control plane current state.
type ClusterControlPlaneStatus struct {
// desiredReplicas is the total number of desired control plane machines in this cluster.
// +optional
DesiredReplicas *int32 `json:"desiredReplicas,omitempty"`
// replicas is the total number of control plane machines in this cluster.
// NOTE: replicas also includes machines still being provisioned or being deleted.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// upToDateReplicas is the number of up-to-date control plane machines in this cluster. A machine is considered up-to-date when Machine's UpToDate condition is true.
// +optional
UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"`
// readyReplicas is the total number of ready control plane machines in this cluster. A machine is considered ready when Machine's Ready condition is true.
// +optional
ReadyReplicas *int32 `json:"readyReplicas,omitempty"`
// availableReplicas is the total number of available control plane machines in this cluster. A machine is considered available when Machine's Available condition is true.
// +optional
AvailableReplicas *int32 `json:"availableReplicas,omitempty"`
}
// WorkersStatus groups all the observations about workers current state.
type WorkersStatus struct {
// desiredReplicas is the total number of desired worker machines in this cluster.
// +optional
DesiredReplicas *int32 `json:"desiredReplicas,omitempty"`
// replicas is the total number of worker machines in this cluster.
// NOTE: replicas also includes machines still being provisioned or being deleted.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
// upToDateReplicas is the number of up-to-date worker machines in this cluster. A machine is considered up-to-date when Machine's UpToDate condition is true.
// +optional
UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"`
// readyReplicas is the total number of ready worker machines in this cluster. A machine is considered ready when Machine's Ready condition is true.
// +optional
ReadyReplicas *int32 `json:"readyReplicas,omitempty"`
// availableReplicas is the total number of available worker machines in this cluster. A machine is considered available when Machine's Available condition is true.
// +optional
AvailableReplicas *int32 `json:"availableReplicas,omitempty"`
}
// ANCHOR_END: ClusterStatus
// SetTypedPhase sets the Phase field to the string representation of ClusterPhase.
func (c *ClusterStatus) SetTypedPhase(p ClusterPhase) {
c.Phase = string(p)
}
// GetTypedPhase attempts to parse the Phase field and return
// the typed ClusterPhase representation as described in `machine_phase_types.go`.
func (c *ClusterStatus) GetTypedPhase() ClusterPhase {
switch phase := ClusterPhase(c.Phase); phase {
case
ClusterPhasePending,
ClusterPhaseProvisioning,
ClusterPhaseProvisioned,
ClusterPhaseDeleting,
ClusterPhaseFailed:
return phase
default:
return ClusterPhaseUnknown
}
}
// ANCHOR: APIEndpoint
// APIEndpoint represents a reachable Kubernetes API endpoint.
type APIEndpoint struct {