This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
/
main.go
1405 lines (1370 loc) · 54.7 KB
/
main.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 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.
*/
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"gitlab.com/chuckh/cluster-api-provider-kind/execer"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)
type machineOptions struct {
name, namespace, clusterName, set, version *string
}
func (mo *machineOptions) initFlags(fs *flag.FlagSet) {
mo.name = fs.String("name", "my-machine", "The name of the machine")
mo.namespace = fs.String("namespace", "my-namespace", "The namespece of the machine")
mo.clusterName = fs.String("cluster-name", "my-cluster", "The name of the cluster the machine belongs to")
mo.set = fs.String("set", "worker", "The role of the machine. Valid entries ['worker', 'control-plane']")
mo.version = fs.String("version", "v1.14.2", "The Kubernetes version to run")
}
func main() {
setup := flag.NewFlagSet("setup", flag.ExitOnError)
managementClusterName := setup.String("cluster-name", "kind", "The name of the management cluster")
// crds takes no args
capk := flag.NewFlagSet("capk", flag.ExitOnError)
capkImage := capk.String("capk-image", "gcr.io/kubernetes1-226021/capk-manager:latest", "The capk manager image to run")
capiImage := capk.String("capi-image", "gcr.io/k8s-cluster-api/cluster-api-controller:0.1.1", "The capi manager image to run")
controlPlane := flag.NewFlagSet("control-plane", flag.ExitOnError)
controlPlaneOpts := new(machineOptions)
controlPlaneOpts.initFlags(controlPlane)
*controlPlaneOpts.set = "control-plane"
worker := flag.NewFlagSet("worker", flag.ExitOnError)
workerOpts := new(machineOptions)
workerOpts.initFlags(worker)
*workerOpts.set = "worker"
cluster := flag.NewFlagSet("cluster", flag.ExitOnError)
clusterName := cluster.String("cluster-name", "my-cluster", "The name of the cluster")
clusterNamespace := cluster.String("namespace", "my-namespace", "The namespace the cluster belongs to")
if len(os.Args) < 2 {
fmt.Println("At least one subcommand is requied.")
fmt.Println(usage())
}
switch os.Args[1] {
case "setup":
setup.Parse(os.Args[2:])
makeManagementCluster(*managementClusterName)
case "crds":
printCRDs()
case "capk":
capk.Parse(os.Args[2:])
printClusterAPIPlane(*capkImage, *capiImage)
case "control-plane":
controlPlane.Parse(os.Args[2:])
fmt.Fprintf(os.Stdout, machineYAML(controlPlaneOpts))
case "worker":
worker.Parse(os.Args[2:])
fmt.Fprintf(os.Stdout, machineYAML(workerOpts))
case "cluster":
cluster.Parse(os.Args[2:])
fmt.Fprintf(os.Stdout, clusterYAML(*clusterName, *clusterNamespace))
case "help":
fmt.Println(usage())
default:
fmt.Println(usage())
os.Exit(1)
}
}
func usage() string {
return `capkctl gets you up and running with capk
subcommands are:
setup - Create a management cluster
example: capkctl setup --name my-management-cluster-name
crds - Write Cluster API CRDs required to run capk to stdout
example: capkctl crds | kubectl apply -f -
capk - Write capk kubernetes components that run necessary managers to stdout
example: capkctl capk -capk-image gcr.io/kubernetes1-226021/capk-manager:latest -capi-image gcr.io/k8s-cluster-api/cluster-api-controller:0.1.2 | kubeclt apply -f -
control-plane - Write a capk control plane machine to stdout
example: capkctl control-plane -name my-control-plane -namespace my-namespace -cluster-name my-cluster -version v1.14.1 | kubectl apply -f -
worker - Write a capk worker machine to stdout
example: capkctl worker -name my-worker -namespace my-namespace -cluster-name my-cluster -version 1.14.2 | kubectl apply -f -
cluster - Write a capk cluster object to stdout
example: capkctl cluster -cluster-name my-cluster -namespace my-namespace | kubectl apply -f -
`
}
func clusterYAML(name, namespace string) string {
return fmt.Sprintf(`apiVersion: "cluster.k8s.io/v1alpha1"
kind: Cluster
metadata:
name: %s
namespace: %s
spec:
clusterNetwork:
services:
cidrBlocks: ["10.96.0.0/12"]
pods:
cidrBlocks: ["192.168.0.0/16"]
serviceDomain: "cluster.local"
providerSpec: {}`, name, namespace)
}
func machineYAML(opts *machineOptions) string {
machine := v1alpha1.Machine{
TypeMeta: metav1.TypeMeta{
Kind: "Machine",
APIVersion: "cluster.k8s.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: *opts.name,
Namespace: *opts.namespace,
Labels: map[string]string{
"cluster.k8s.io/cluster-name": *opts.clusterName,
},
Annotations: map[string]string{
"set": *opts.set,
},
},
Spec: v1alpha1.MachineSpec{
ProviderSpec: v1alpha1.ProviderSpec{},
},
}
// TODO: 🤔
if *opts.set == "control-plane" {
machine.Spec.Versions.ControlPlane = *opts.version
}
if *opts.set == "worker" {
machine.Spec.Versions.Kubelet = *opts.version
}
b, err := json.Marshal(machine)
// TODO don't panic on the error
if err != nil {
panic(err)
}
return string(b)
}
func makeManagementCluster(clusterName string) {
kind := execer.NewClient("kind")
// start kind with docker mount
kindConfig, err := kindConfigFile()
if err != nil {
panic(err)
}
if err := kind.RunCommand("create", "cluster", "--name", clusterName, "--config", kindConfig); err != nil {
panic(err)
}
}
// TODO if possible, use the kind library instead of the command line tool
func kindConfigFile() (string, error) {
kfg := `kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
extraMounts:
- containerPath: /var/run/docker.sock
hostPath: /var/run/docker.sock
`
f, err := ioutil.TempFile("", "*-kind-config.yaml")
if err != nil {
return "", err
}
defer f.Close()
if _, err := f.WriteString(kfg); err != nil {
return "", err
}
return f.Name(), nil
}
func printCRDs() {
fmt.Fprintln(os.Stdout, crds)
}
func printClusterAPIPlane(capkImage, capiImage string) {
fmt.Fprintln(os.Stdout, getCAPKPlane(capkImage, capiImage))
}
func getCAPKPlane(capkImage, capiImage string) string {
return fmt.Sprintf(capiPlane, capkImage, capiImage)
}
var capiPlane = `
apiVersion: v1
kind: Namespace
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: kind-provider-system
---
apiVersion: v1
kind: Namespace
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: cluster-api-system
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
control-plane: controller-manager
name: kind-provider-controller-manager
namespace: kind-provider-system
spec:
selector:
matchLabels:
control-plane: controller-manager
serviceName: kind-provider-controller-manager-service
template:
metadata:
labels:
control-plane: controller-manager
spec:
containers:
- name: capk-manager
image: %s
command:
- capk-manager
volumeMounts:
- mountPath: /var/run/docker.sock
name: dockersock
- mountPath: /var/lib/docker
name: dockerlib
securityContext:
privileged: true
volumes:
- name: dockersock
hostPath:
path: /var/run/docker.sock
type: Socket
- name: dockerlib
hostPath:
path: /var/lib/docker
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/notReady
operator: Exists
- effect: NoExecute
key: node.alpha.kubernetes.io/unreachable
operator: Exists
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
control-plane: controller-manager
controller-tools.k8s.io: "1.0"
name: cluster-api-controller-manager
namespace: cluster-api-system
spec:
selector:
matchLabels:
control-plane: controller-manager
controller-tools.k8s.io: "1.0"
serviceName: cluster-api-controller-manager-service
template:
metadata:
labels:
control-plane: controller-manager
controller-tools.k8s.io: "1.0"
spec:
containers:
- command:
- /manager
image: %s
name: manager
`
// TODO generate the CRDs
var crds = `
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: clusters.cluster.k8s.io
spec:
group: cluster.k8s.io
names:
kind: Cluster
plural: clusters
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
clusterNetwork:
description: Cluster network configuration
properties:
pods:
description: The network ranges from which Pod networks are allocated.
properties:
cidrBlocks:
items:
type: string
type: array
required:
- cidrBlocks
type: object
serviceDomain:
description: Domain name for services.
type: string
services:
description: The network ranges from which service VIPs are allocated.
properties:
cidrBlocks:
items:
type: string
type: array
required:
- cidrBlocks
type: object
required:
- services
- pods
- serviceDomain
type: object
providerSpec:
description: Provider-specific serialized configuration to use during
cluster creation. It is recommended that providers maintain their
own versioned API types that should be serialized/deserialized from
this field.
properties:
value:
description: Value is an inlined, serialized representation of the
resource configuration. It is recommended that providers maintain
their own versioned API types that should be serialized/deserialized
from this field, akin to component config.
type: object
valueFrom:
description: Source for the provider configuration. Cannot be used
if value is not empty.
properties:
machineClass:
description: The machine class from which the provider config
should be sourced.
properties:
provider:
description: Provider is the name of the cloud-provider
which MachineClass is intended for.
type: string
type: object
type: object
type: object
required:
- clusterNetwork
type: object
status:
properties:
apiEndpoints:
description: APIEndpoint represents the endpoint to communicate with
the IP.
items:
properties:
host:
description: The hostname on which the API server is serving.
type: string
port:
description: The port on which the API server is serving.
format: int64
type: integer
required:
- host
- port
type: object
type: array
errorMessage:
description: If set, indicates that there is a problem reconciling the
state, and will be set to a descriptive error message.
type: string
errorReason:
description: If set, indicates that there is a problem reconciling the
state, and will be set to a token value suitable for programmatic
interpretation.
type: string
providerStatus:
description: Provider-specific status. It is recommended that providers
maintain their own versioned API types that should be serialized/deserialized
from this field.
type: object
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: machineclasses.cluster.k8s.io
spec:
group: cluster.k8s.io
names:
kind: MachineClass
plural: machineclasses
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
providerSpec:
description: Provider-specific configuration to use during node creation.
type: object
required:
- providerSpec
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: machinedeployments.cluster.k8s.io
spec:
group: cluster.k8s.io
names:
kind: MachineDeployment
plural: machinedeployments
scope: Namespaced
subresources:
scale:
labelSelectorPath: .status.labelSelector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
minReadySeconds:
description: 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)
format: int32
type: integer
paused:
description: Indicates that the deployment is paused.
type: boolean
progressDeadlineSeconds:
description: The maximum time in seconds for a deployment to make progress
before it is considered to be failed. The deployment controller will
continue to process failed deployments and a condition with a ProgressDeadlineExceeded
reason will be surfaced in the deployment status. Note that progress
will not be estimated during the time a deployment is paused. Defaults
to 600s.
format: int32
type: integer
replicas:
description: Number of desired machines. Defaults to 1. This is a pointer
to distinguish between explicit zero and not specified.
format: int32
type: integer
revisionHistoryLimit:
description: The number of old MachineSets to retain to allow rollback.
This is a pointer to distinguish between explicit zero and not specified.
Defaults to 1.
format: int32
type: integer
selector:
description: Label selector for machines. Existing MachineSets whose
machines are selected by this will be the ones affected by this deployment.
It must match the machine template's labels.
type: object
strategy:
description: The deployment strategy to use to replace existing machines
with new ones.
properties:
rollingUpdate:
description: Rolling update config params. Present only if MachineDeploymentStrategyType
= RollingUpdate.
properties:
maxSurge:
description: 'The maximum number of machines that can be scheduled
above the desired number of machines. Value can be an absolute
number (ex: 5) or a percentage of desired machines (ex: 10%).
This can not be 0 if MaxUnavailable is 0. Absolute number
is calculated from percentage by rounding up. Defaults to
1. Example: when this is set to 30%, the new MachineSet can
be scaled up immediately when the rolling update starts, such
that the total number of old and new machines do not exceed
130% of desired machines. Once old machines have been killed,
new MachineSet can be scaled up further, ensuring that total
number of machines running at any time during the update is
at most 130% of desired machines.'
oneOf:
- type: string
- type: integer
maxUnavailable:
description: 'The maximum number of machines that can be unavailable
during the update. Value can be an absolute number (ex: 5)
or a percentage of desired machines (ex: 10%). Absolute number
is calculated from percentage by rounding down. This can not
be 0 if MaxSurge is 0. Defaults to 0. Example: when this is
set to 30%, the old MachineSet can be scaled down to 70% of
desired machines immediately when the rolling update starts.
Once new machines are ready, old MachineSet can be scaled
down further, followed by scaling up the new MachineSet, ensuring
that the total number of machines available at all times during
the update is at least 70% of desired machines.'
oneOf:
- type: string
- type: integer
type: object
type:
description: Type of deployment. Currently the only supported strategy
is "RollingUpdate". Default is RollingUpdate.
type: string
type: object
template:
description: Template describes the machines that will be created.
properties:
metadata:
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
type: object
spec:
description: 'Specification of the desired behavior of the machine.
More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status'
properties:
configSource:
description: ConfigSource is used to populate in the associated
Node for dynamic kubelet config. This field already exists
in Node, so any updates to it in the Machine spec will be
automatically copied to the linked NodeRef from the status.
The rest of dynamic kubelet config support should then work
as-is.
type: object
metadata:
description: ObjectMeta will autopopulate the Node created.
Use this to indicate what labels, annotations, name prefix,
etc., should be used when creating the Node.
type: object
providerID:
description: ProviderID is the identification ID of the machine
provided by the provider. This field must match the provider
ID as seen on the node object corresponding to this machine.
This field is required by higher level consumers of cluster-api.
Example use case is cluster autoscaler with cluster-api as
provider. Clean-up logic in the autoscaler compares machines
to nodes to find out machines at provider which could not
get registered as Kubernetes nodes. With cluster-api as a
generic out-of-tree provider for autoscaler, this field is
required by autoscaler to be able to have a provider view
of the list of machines. Another list of nodes is queried
from the k8s apiserver and then a comparison is done to find
out unregistered machines and are marked for delete. This
field will be set by the actuators and consumed by higher
level entities like autoscaler that will be interfacing with
cluster-api as generic provider.
type: string
providerSpec:
description: ProviderSpec details Provider-specific configuration
to use during node creation.
properties:
value:
description: Value is an inlined, serialized representation
of the resource configuration. It is recommended that
providers maintain their own versioned API types that
should be serialized/deserialized from this field, akin
to component config.
type: object
valueFrom:
description: Source for the provider configuration. Cannot
be used if value is not empty.
properties:
machineClass:
description: The machine class from which the provider
config should be sourced.
properties:
provider:
description: Provider is the name of the cloud-provider
which MachineClass is intended for.
type: string
type: object
type: object
type: object
taints:
description: Taints is the full, authoritative list of taints
to apply to the corresponding Node. This list will overwrite
any modifications made to the Node on an ongoing basis.
items:
type: object
type: array
versions:
description: Versions of key software to use. This field is
optional at cluster creation time, and omitting the field
indicates that the cluster installation tool should select
defaults for the user. These defaults may differ based on
the cluster installer, but the tool should populate the values
it uses when persisting Machine objects. A Machine spec missing
this field at runtime is invalid.
properties:
controlPlane:
description: ControlPlane is the semantic version of the
Kubernetes control plane to run. This should only be populated
when the machine is a control plane.
type: string
kubelet:
description: Kubelet is the semantic version of kubelet
to run
type: string
required:
- kubelet
type: object
required:
- providerSpec
type: object
type: object
required:
- selector
- template
type: object
status:
properties:
availableReplicas:
description: Total number of available machines (ready for at least
minReadySeconds) targeted by this deployment.
format: int32
type: integer
observedGeneration:
description: The generation observed by the deployment controller.
format: int64
type: integer
readyReplicas:
description: Total number of ready machines targeted by this deployment.
format: int32
type: integer
replicas:
description: Total number of non-terminated machines targeted by this
deployment (their labels match the selector).
format: int32
type: integer
unavailableReplicas:
description: Total number of unavailable machines targeted by this deployment.
This is the total number of machines that are still required for the
deployment to have 100% available capacity. They may either be machines
that are running but not yet available or machines that still have
not been created.
format: int32
type: integer
updatedReplicas:
description: Total number of non-terminated machines targeted by this
deployment that have the desired template spec.
format: int32
type: integer
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: machines.cluster.k8s.io
spec:
additionalPrinterColumns:
- JSONPath: .spec.providerID
description: Provider ID
name: ProviderID
type: string
- JSONPath: .status.phase
description: Machine status such as Terminating/Pending/Running/Failed etc
name: Phase
type: string
group: cluster.k8s.io
names:
kind: Machine
plural: machines
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
configSource:
description: ConfigSource is used to populate in the associated Node
for dynamic kubelet config. This field already exists in Node, so
any updates to it in the Machine spec will be automatically copied
to the linked NodeRef from the status. The rest of dynamic kubelet
config support should then work as-is.
type: object
metadata:
description: ObjectMeta will autopopulate the Node created. Use this
to indicate what labels, annotations, name prefix, etc., should be
used when creating the Node.
type: object
providerID:
description: ProviderID is the identification ID of the machine provided
by the provider. This field must match the provider ID as seen on
the node object corresponding to this machine. This field is required
by higher level consumers of cluster-api. Example use case is cluster
autoscaler with cluster-api as provider. Clean-up logic in the autoscaler
compares machines to nodes to find out machines at provider which
could not get registered as Kubernetes nodes. With cluster-api as
a generic out-of-tree provider for autoscaler, this field is required
by autoscaler to be able to have a provider view of the list of machines.
Another list of nodes is queried from the k8s apiserver and then comparison
is done to find out unregistered machines and are marked for delete.
This field will be set by the actuators and consumed by higher level
entities like autoscaler that will be interfacing with cluster-api
as generic provider.
type: string
providerSpec:
description: ProviderSpec details Provider-specific configuration to
use during node creation.
properties:
value:
description: Value is an inlined, serialized representation of the
resource configuration. It is recommended that providers maintain
their own versioned API types that should be serialized/deserialized
from this field, akin to component config.
type: object
valueFrom:
description: Source for the provider configuration. Cannot be used
if value is not empty.
properties:
machineClass:
description: The machine class from which the provider config
should be sourced.
properties:
provider:
description: Provider is the name of the cloud-provider
which MachineClass is intended for.
type: string
type: object
type: object
type: object
taints:
description: Taints is the full, authoritative list of taints to apply
to the corresponding Node. This list will overwrite any modifications
made to the Node on an ongoing basis.
items:
type: object
type: array
versions:
description: Versions of key software to use. This field is optional
at cluster creation time, and omitting the field indicates that the
cluster installation tool should select defaults for the user. These
defaults may differ based on the cluster installer, but the tool should
populate the values it uses when persisting Machine objects. A Machine
spec missing this field at runtime is invalid.
properties:
controlPlane:
description: ControlPlane is the semantic version of the Kubernetes
control plane to run. This should only be populated when the machine
is a control plane.
type: string
kubelet:
description: Kubelet is the semantic version of kubelet to run
type: string
required:
- kubelet
type: object
required:
- providerSpec
type: object
status:
properties:
addresses:
description: Addresses is a list of addresses assigned to the machine.
Queried from cloud provider, if available.
items:
type: object
type: array
conditions:
description: 'Conditions lists the conditions synced from the node conditions
of the corresponding node-object. Machine-controller is responsible
for keeping conditions up-to-date. MachineSet controller will be taking
these conditions as a signal to decide if machine is healthy or needs
to be replaced. Refer: https://kubernetes.io/docs/concepts/architecture/nodes/#condition'
items:
type: object
type: array
errorMessage:
description: ErrorMessage will be set in the event that there is a terminal
problem reconciling the Machine and will contain a more verbose string
suitable for logging and human consumption. This field should not
be set for transitive errors that a controller faces that are expected
to be fixed automatically over time (like service outages), but instead
indicate that something is fundamentally wrong with the Machine's
spec or the configuration of the controller, and that manual intervention
is required. Examples of terminal errors would be invalid combinations
of settings in the spec, values that are unsupported by the controller,
or the responsible controller itself being critically misconfigured. Any
transient errors that occur during the reconciliation of Machines
can be added as events to the Machine object and/or logged in the
controller's output.
type: string
errorReason:
description: ErrorReason will be set in the event that there is a terminal
problem reconciling the Machine and will contain a succinct value
suitable for machine interpretation. This field should not be set
for transitive errors that a controller faces that are expected to
be fixed automatically over time (like service outages), but instead
indicate that something is fundamentally wrong with the Machine's
spec or the configuration of the controller, and that manual intervention
is required. Examples of terminal errors would be invalid combinations
of settings in the spec, values that are unsupported by the controller,
or the responsible controller itself being critically misconfigured. Any
transient errors that occur during the reconciliation of Machines
can be added as events to the Machine object and/or logged in the
controller's output.
type: string
lastOperation:
description: LastOperation describes the last-operation performed by
the machine-controller. This API should be useful as a history in
terms of the latest operation performed on the specific machine. It
should also convey the state of the latest-operation for example if
it is still on-going, failed or completed successfully.
properties:
description:
description: Description is the human-readable description of the
last operation.
type: string
lastUpdated:
description: LastUpdated is the timestamp at which LastOperation
API was last-updated.
format: date-time
type: string
state:
description: State is the current status of the last performed operation.
E.g. Processing, Failed, Successful etc
type: string
type:
description: Type is the type of operation which was last performed.
E.g. Create, Delete, Update etc
type: string
type: object
lastUpdated:
description: LastUpdated identifies when this status was last observed.
format: date-time
type: string
nodeRef:
description: NodeRef will point to the corresponding Node if it exists.
type: object
phase:
description: Phase represents the current phase of machine actuation.
E.g. Pending, Running, Terminating, Failed etc.
type: string
providerStatus:
description: ProviderStatus details a Provider-specific status. It is
recommended that providers maintain their own versioned API types
that should be serialized/deserialized from this field.
type: object
versions:
description: 'Versions specifies the current versions of software on
the corresponding Node (if it exists). This is provided for a few
reasons: 1) It is more convenient than checking the NodeRef, traversing
it to the Node, and finding the appropriate field in Node.Status.NodeInfo (which
uses different field names and formatting). 2) It removes some of
the dependency on the structure of the Node, so that if the structure
of Node.Status.NodeInfo changes, only machine controllers need
to be updated, rather than every client of the Machines API. 3)
There is no other simple way to check the control plane version.
A client would have to connect directly to the apiserver running
on the target node in order to find out its version.'
properties:
controlPlane:
description: ControlPlane is the semantic version of the Kubernetes
control plane to run. This should only be populated when the machine
is a control plane.
type: string
kubelet:
description: Kubelet is the semantic version of kubelet to run
type: string
required:
- kubelet
type: object
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
name: machinesets.cluster.k8s.io