/
types.go
1455 lines (1270 loc) · 40.5 KB
/
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
/*
* Tencent is pleased to support the open source community by making TKEStack
* available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* 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
*
* https://opensource.org/licenses/Apache-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 OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package platform
import (
"fmt"
"math/rand"
"net"
"os"
"path"
"strings"
pkgerrors "github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/rest"
applicationv1 "tkestack.io/tke/api/application/v1"
)
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Cluster is a Kubernetes cluster in TKE.
type Cluster struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// Spec defines the desired identities of clusters in this set.
// +optional
Spec ClusterSpec
// +optional
Status ClusterStatus
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterList is the whole list of all clusters which owned by a tenant.
type ClusterList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// List of clusters
Items []Cluster
}
// ClusterMachine is the master machine definition of cluster.
type ClusterMachine struct {
IP string
Port int32
Username string
Password []byte
PrivateKey []byte
PassPhrase []byte
Labels map[string]string
Taints []corev1.Taint
}
// KubeVendorType describe the kubernetes provider of the cluster
// ref https://github.com/open-cluster-management/multicloud-operators-foundation/blob/e94b719de6d5f3541e948dd70ad8f1ff748aa452/pkg/apis/internal.open-cluster-management.io/v1beta1/clusterinfo_types.go#L137
type KubeVendorType string
const (
// KubeVendorTKE TKE
KubeVendorTKE KubeVendorType = "TKE"
// KubeVendorOpenShift OpenShift
KubeVendorOpenShift KubeVendorType = "OpenShift"
// KubeVendorAKS Azure Kuberentes Service
KubeVendorAKS KubeVendorType = "AKS"
// KubeVendorEKS Elastic Kubernetes Service
KubeVendorEKS KubeVendorType = "EKS"
// KubeVendorGKE Google Kubernetes Engine
KubeVendorGKE KubeVendorType = "GKE"
// KubeVendorICP IBM Cloud Private
KubeVendorICP KubeVendorType = "ICP"
// KubeVendorIKS IBM Kubernetes Service
KubeVendorIKS KubeVendorType = "IKS"
// KubeVendorOSD OpenShiftDedicated
KubeVendorOSD KubeVendorType = "OpenShiftDedicated"
// KubeVendorOther other (unable to auto detect)
KubeVendorOther KubeVendorType = "Other"
)
// ClusterSpec is a description of a cluster.
type ClusterSpec struct {
// Finalizers is an opaque list of values that must be empty to permanently remove object from storage.
// +optional
Finalizers []FinalizerName
TenantID string
// +optional
DisplayName string
Type string
Version string
// +optional
NetworkType NetworkType
// +optional
NetworkDevice string
// +optional
ClusterCIDR string
// ServiceCIDR is used to set a separated CIDR for k8s service, it's exclusive with MaxClusterServiceNum.
// +optional
ServiceCIDR *string
// +optional
// DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local".
DNSDomain string
// +optional
PublicAlternativeNames []string
// +optional
Features ClusterFeature
// +optional
Properties ClusterProperty
// +optional
Machines []ClusterMachine
// +optional
ScalingMachines []ClusterMachine
// +optional
DockerExtraArgs map[string]string
// +optional
KubeletExtraArgs map[string]string
// +optional
APIServerExtraArgs map[string]string
// +optional
ControllerManagerExtraArgs map[string]string
// +optional
SchedulerExtraArgs map[string]string
// ClusterCredentialRef for isolate sensitive information.
// If not specified, cluster controller will create one;
// If specified, provider must make sure is valid.
// +optional
ClusterCredentialRef *corev1.LocalObjectReference
// Etcd holds configuration for etcd.
// +optional
Etcd *Etcd
// If true will use hostname as nodename, if false will use machine IP as nodename.
// +optional
HostnameAsNodename bool
// +optional
NetworkArgs map[string]string
// BootstrapApps will install apps during creating cluster
// +optional
BootstrapApps BootstrapApps
}
// ClusterStatus represents information about the status of a cluster.
type ClusterStatus struct {
// +optional
Locked *bool
// +optional
Version string
// +optional
Phase ClusterPhase
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []ClusterCondition
// A human readable message indicating details about why the cluster is in this condition.
// +optional
Message string
// A brief CamelCase message indicating details about why the cluster is in this state.
// +optional
Reason string
// List of addresses reachable to the cluster.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Addresses []ClusterAddress
// +optional
Resource ClusterResource
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Components []ClusterComponent
// +optional
ServiceCIDR string
// +optional
NodeCIDRMaskSize int32
// +optional
DNSIP string
// +optional
RegistryIPs []string
// +optional
ClusterCIDR string
// +optional
SecondaryServiceCIDR string
// +optional
SecondaryClusterCIDR string
// +optional
NodeCIDRMaskSizeIPv4 int32
// +optional
NodeCIDRMaskSizeIPv6 int32
// +optional
KubeVendor KubeVendorType
}
// FinalizerName is the name identifying a finalizer during cluster lifecycle.
type FinalizerName string
const (
// ClusterFinalize is an internal finalizer values to Cluster.
ClusterFinalize FinalizerName = "cluster"
// MachineFinalize is an internal finalizer values to Machine.
MachineFinalize FinalizerName = "machine"
)
// NetworkType defines the network type of cluster.
type NetworkType string
// GPUType defines the gpu type of cluster.
type GPUType string
const (
// GPUPhysical indicates the gpu type of cluster is physical.
GPUPhysical GPUType = "Physical"
// GPUVirtual indicates the gpu type of cluster is virtual.
GPUVirtual GPUType = "Virtual"
)
type ContainerRuntimeType = string
const (
Containerd ContainerRuntimeType = "containerd"
Docker ContainerRuntimeType = "docker"
)
// ClusterPhase defines the phase of cluster constructor.
type ClusterPhase string
const (
// ClusterInitializing is the initialize phase.
ClusterInitializing ClusterPhase = "Initializing"
// ClusterRunning is the normal running phase.
ClusterRunning ClusterPhase = "Running"
// ClusterFailed is the failed phase.
ClusterFailed ClusterPhase = "Failed"
// ClusterUpgrading means that the cluster is in upgrading process.
ClusterUpgrading ClusterPhase = "Upgrading"
// ClusterTerminating means the cluster is undergoing graceful termination.
ClusterTerminating ClusterPhase = "Terminating"
// ClusterUpscaling means the cluster is undergoing graceful up scaling.
ClusterUpscaling ClusterPhase = "Upscaling"
// ClusterDownscaling means the cluster is undergoing graceful down scaling.
ClusterDownscaling ClusterPhase = "Downscaling"
)
// ClusterCondition contains details for the current condition of this cluster.
type ClusterCondition struct {
// Type is the type of the condition.
Type string
// Status is the status of the condition.
// Can be True, False, Unknown.
Status ConditionStatus
// Last time we probed the condition.
// +optional
LastProbeTime metav1.Time
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime metav1.Time
// Unique, one-word, CamelCase reason for the condition's last transition.
// +optional
Reason string
// Human-readable message indicating details about last transition.
// +optional
Message string
}
// AddressType indicates the type of cluster apiserver access address.
type AddressType string
// These are valid address type of node.
const (
// AddressPublic indicates the address of the apiserver accessed from the external network.(such as public lb)
AddressPublic AddressType = "Public"
// AddressAdvertise indicates the address of the apiserver accessed from the worker node.(such as internal lb)
AddressAdvertise AddressType = "Advertise"
// AddressReal indicates the real address of one apiserver
AddressReal AddressType = "Real"
// AddressInternal indicates the address of the apiserver accessed from TKE control plane.
AddressInternal AddressType = "Internal"
// AddressSupport used for vpc lb which bind to JNS gateway as known AddressInternal
AddressSupport AddressType = "Support"
)
// ClusterAddress contains information for the cluster's address.
type ClusterAddress struct {
// Cluster address type, one of Public, ExternalIP or InternalIP.
Type AddressType
// The cluster address.
Host string
Port int32
Path string
}
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterCredential records the credential information needed to access the cluster.
type ClusterCredential struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
TenantID string
ClusterName string
// For TKE in global reuse
// +optional
ETCDCACert []byte
// +optional
ETCDCAKey []byte
// +optional
ETCDAPIClientCert []byte
// +optional
ETCDAPIClientKey []byte
// For validate the server cert
// +optional
CACert []byte
// +optional
CAKey []byte
// For kube-apiserver X509 auth
// +optional
ClientCert []byte
// For kube-apiserver X509 auth
// +optional
ClientKey []byte
// For kube-apiserver token auth
// +optional
Token *string
// For kubeadm init or join
// +optional
BootstrapToken *string
// For kubeadm init or join
// +optional
CertificateKey *string
// Username is the username for basic authentication to the kubernetes cluster.
// +optional
Username string
// Impersonate is the username to act-as.
// +optional
Impersonate string
// ImpersonateGroups is the groups to imperonate.
// +optional
ImpersonateGroups []string
// ImpersonateUserExtra contains additional information for impersonated user.
// +optional
ImpersonateUserExtra ImpersonateUserExtra
}
type ImpersonateUserExtra map[string]string
func (i ImpersonateUserExtra) ExtraToHeaders() map[string][]string {
res := map[string][]string{}
for k, v := range i {
res[k] = strings.Split(v, ",")
}
return res
}
func (cc ClusterCredential) RESTConfig(cls *Cluster) *rest.Config {
config := &rest.Config{}
if cls != nil {
host := clusterHost(cls)
if len(host) != 0 {
config.Host = fmt.Sprintf("https://%s", host)
}
}
// If api-server does not sign the ip in address, set ca then request, it will report x509 certificate error, need to ignore the certificate
if os.Getenv("TKE_IGNORE_CA") != "true" && cc.CACert != nil {
config.TLSClientConfig.CAData = cc.CACert
} else {
config.TLSClientConfig.Insecure = true
}
if cc.ClientCert != nil && cc.ClientKey != nil {
config.TLSClientConfig.CertData = cc.ClientCert
config.TLSClientConfig.KeyData = cc.ClientKey
}
if cc.Token != nil {
config.BearerToken = *cc.Token
}
config.Impersonate.UserName = cc.Impersonate
config.Impersonate.Groups = cc.ImpersonateGroups
config.Impersonate.Extra = cc.ImpersonateUserExtra.ExtraToHeaders()
return config
}
func clusterHost(cluster *Cluster) string {
address, err := clusterAddress(cluster)
if err != nil {
return ""
}
result := net.JoinHostPort(address.Host, fmt.Sprintf("%d", address.Port))
if address.Path != "" {
result = path.Join(result, address.Path)
}
return result
}
func clusterAddress(cluster *Cluster) (*ClusterAddress, error) {
addrs := make(map[AddressType][]ClusterAddress)
for _, one := range cluster.Status.Addresses {
addrs[one.Type] = append(addrs[one.Type], one)
}
var address *ClusterAddress
if len(addrs[AddressInternal]) != 0 {
address = &addrs[AddressInternal][rand.Intn(len(addrs[AddressInternal]))]
} else if len(addrs[AddressAdvertise]) != 0 {
address = &addrs[AddressAdvertise][rand.Intn(len(addrs[AddressAdvertise]))]
} else {
if len(addrs[AddressReal]) != 0 {
address = &addrs[AddressReal][rand.Intn(len(addrs[AddressReal]))]
}
}
if address == nil {
return nil, pkgerrors.New("no valid address for the cluster")
}
return address, nil
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterCredentialList is the whole list of all ClusterCredential which owned by a tenant.
type ClusterCredentialList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// List of clusters
Items []ClusterCredential
}
// ClusterFeature records the features that are enabled by the cluster.
type ClusterFeature struct {
// +optional
IPVS *bool
// +optional
PublicLB *bool
// +optional
InternalLB *bool
// +optional
GPUType *GPUType
// +optional
EnableMasterSchedule bool
// +optional
HA *HA
// +optional
SkipConditions []string
// +optional
Files []File
// +optional
Hooks map[HookType]string
// +optional
CSIOperator *CSIOperatorFeature
// For kube-apiserver authorization webhook
// +optional
AuthzWebhookAddr *AuthzWebhookAddr
// +optional
EnableMetricsServer bool
// +optional
EnableCilium bool
ContainerRuntime ContainerRuntimeType
// +optional
IPv6DualStack bool
// Upgrade control upgrade process.
// +optional
Upgrade Upgrade
}
type BootstrapApps []BootstapApp
type BootstapApp struct {
App App
}
type App struct {
// +optional
metav1.ObjectMeta
// +optional
Spec applicationv1.AppSpec
}
type HA struct {
TKEHA *TKEHA
ThirdPartyHA *ThirdPartyHA
}
type TKEHA struct {
VIP string
VRID *int32
}
type ThirdPartyHA struct {
VIP string
VPort int32
}
type File struct {
Src string // Only support regular file
Dst string
}
type HookType string
type CSIOperatorFeature struct {
Version string
}
type AuthzWebhookAddr struct {
// +optional
Builtin *BuiltinAuthzWebhookAddr
// +optional
External *ExternalAuthzWebhookAddr
}
type BuiltinAuthzWebhookAddr struct{}
type ExternalAuthzWebhookAddr struct {
IP string `json:"ip" protobuf:"bytes,1,name=ip"`
Port int32 `json:"port" protobuf:"varint,2,name=port"`
}
const (
// node lifecycle hook
HookPreInstall HookType = "PreInstall"
HookPostInstall HookType = "PostInstall"
HookPreUpgrade HookType = "PreUpgrade"
HookPostUpgrade HookType = "PostUpgrade"
// cluster lifecycle hook
HookPreClusterInstall HookType = "PreClusterInstall"
HookPostClusterInstall HookType = "PostClusterInstall"
HookPreClusterUpgrade HookType = "PreClusterUpgrade"
HookPostClusterUpgrade HookType = "PostClusterUpgrade"
HookPreClusterDelete HookType = "PreClusterDelete"
HookPostClusterDelete HookType = "PostClusterDelete"
)
// ClusterProperty records the attribute information of the cluster.
type ClusterProperty struct {
// +optional
MaxClusterServiceNum *int32
// +optional
MaxNodePodNum *int32
// +optional
OversoldRatio map[string]string
}
// Etcd contains elements describing Etcd configuration.
type Etcd struct {
// Local provides configuration knobs for configuring the local etcd instance
// Local and External are mutually exclusive
Local *LocalEtcd
// External describes how to connect to an external etcd cluster
// Local and External are mutually exclusive
External *ExternalEtcd
}
// LocalEtcd describes that kubeadm should run an etcd cluster locally
type LocalEtcd struct {
// DataDir is the directory etcd will place its data.
// Defaults to "/var/lib/etcd".
DataDir string
// ExtraArgs are extra arguments provided to the etcd binary
// when run inside a static pod.
ExtraArgs map[string]string
// ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert.
ServerCertSANs []string
// PeerCertSANs sets extra Subject Alternative Names for the etcd peer signing cert.
PeerCertSANs []string
}
// ExternalEtcd describes an external etcd cluster
type ExternalEtcd struct {
// Endpoints of etcd members. Useful for using external etcd.
// If not provided, kubeadm will run etcd in a static pod.
Endpoints []string
// CAFile is an SSL Certificate Authority file used to secure etcd communication.
CAFile string
// CertFile is an SSL certification file used to secure etcd communication.
CertFile string
// KeyFile is an SSL key file used to secure etcd communication.
KeyFile string
}
type Upgrade struct {
// Upgrade mode, default value is Auto.
Mode UpgradeMode
// Upgrade strategy config.
Strategy UpgradeStrategy
}
type UpgradeMode string
const (
// Upgrade nodes automatically.
UpgradeModeAuto = UpgradeMode("Auto")
// Manual upgrade nodes which means user need label node with `platform.tkestack.io/need-upgrade`.
UpgradeModeManual = UpgradeMode("Manual")
)
// UpgradeStrategy used to control the upgrade process.
type UpgradeStrategy struct {
// The maximum number of pods that can be unready during the upgrade.
// 0% means all pods need to be ready after evition.
// 100% means ignore any pods unready which may be used in one worker node, use this carefully!
// default value is 0%.
MaxUnready intstr.IntOrString
// Whether drain node before upgrade.
// Draining node before upgrade is recommended.
// But not all pod running as cows, a few running as pets.
// If your pod can not accept be expelled from current node, this value should be false.
DrainNodeBeforeUpgrade bool
}
// ResourceList is a set of (resource name, quantity) pairs.
type ResourceList map[string]resource.Quantity
// ResourceRequirements describes the compute resource requirements.
type ResourceRequirements struct {
Limits ResourceList
Requests ResourceList
}
// ClusterResource records the current available and maximum resource quota
// information for the cluster.
type ClusterResource struct {
// Capacity represents the total resources of a cluster.
// +optional
Capacity ResourceList
// Allocatable represents the resources of a cluster that are available for scheduling.
// Defaults to Capacity.
// +optional
Allocatable ResourceList
// +optional
Allocated ResourceList
}
// ClusterComponent records the number of copies of each component of the
// cluster master.
type ClusterComponent struct {
Type string
Replicas ClusterComponentReplicas
}
// ClusterComponentReplicas records the number of copies of each state of each
// component of the cluster master.
type ClusterComponentReplicas struct {
Desired int32
Current int32
Available int32
Updated int32
}
// AddonLevel indicates the level of cluster addon.
type AddonLevel string
// These are valid level of addon.
const (
// LevelBasic is level for basic of cluster.
LevelBasic AddonLevel = "Basic"
// LevelEnhance is level for enhance of cluster.
LevelEnhance AddonLevel = "Enhance"
)
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=list,get
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterAddon contains the Addon component for the current kubernetes cluster
type ClusterAddon struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// Spec defines the desired identities of addons in this set.
// +optional
Spec ClusterAddonSpec
// +optional
Status ClusterAddonStatus
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterAddonList is the whole list of all ClusterAddon.
type ClusterAddonList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// List of ClusterAddon
Items []ClusterAddon
}
// ClusterAddonSpec indicates the specifications of the ClusterAddon.
type ClusterAddonSpec struct {
// Addon type, one of PersistentEvent or LogCollector etc.
Type string
// AddonLevel is level of cluster addon.
Level AddonLevel
// Version
Version string
}
// ClusterAddonStatus is information about the current status of a ClusterAddon.
type ClusterAddonStatus struct {
// +optional
Version string
// Phase is the current lifecycle phase of the addon of cluster.
// +optional
Phase string
// Reason is a brief CamelCase string that describes any failure.
// +optional
Reason string
}
// +genclient
// +genclient:nonNamespaced
// +genclient:onlyVerbs=list
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterAddonType records the all addons of cluster available.
type ClusterAddonType struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// Addon type, one of PersistentEvent or LogCollector etc.
Type string
// AddonLevel is level of cluster addon.
Level AddonLevel
// LatestVersion is latest version of the addon.
LatestVersion string
// Description is desc of the addon.
Description string
CompatibleClusterType []string
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterAddonTypeList is a resource containing a list of ClusterAddonType objects.
type ClusterAddonTypeList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// +optional
Items []ClusterAddonType
}
// +k8s:conversion-gen:explicit-from=net/url.Values
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterApplyOptions is the query options to a kube-apiserver proxy call for cluster object.
type ClusterApplyOptions struct {
metav1.TypeMeta
// +optional
NotUpdate bool
}
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Registry records the third-party image repository information stored by the
// user.
type Registry struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// +optional
Spec RegistrySpec
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RegistryList is a resource containing a list of Registry objects.
type RegistryList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// +optional
Items []Registry
}
// RegistrySpec indicates the specifications of the third-party image repository.
type RegistrySpec struct {
// +optional
TenantID string
// +optional
DisplayName string
// +optional
ClusterName string
// +optional
URL string
// +optional
UserName *string
// +optional
Password *string
}
// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=deleteCollection
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PersistentEvent is a recorder of kubernetes event.
type PersistentEvent struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// Spec defines the desired identities of clusters in this set.
// +optional
Spec PersistentEventSpec
// +optional
Status PersistentEventStatus
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PersistentEventList is the whole list of all clusters which owned by a tenant.
type PersistentEventList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
// List of PersistentEvents
Items []PersistentEvent
}
// PersistentEventSpec describes the attributes on a PersistentEvent.
type PersistentEventSpec struct {
TenantID string
ClusterName string
PersistentBackEnd PersistentBackEnd
Version string
}
// PersistentEventStatus is information about the current status of a
// PersistentEvent.
type PersistentEventStatus struct {
// +optional
Version string
// Phase is the current lifecycle phase of the persistent event of cluster.
// +optional
Phase AddonPhase
// Reason is a brief CamelCase string that describes any failure.
// +optional
Reason string
// RetryCount is a int between 0 and 5 that describes the time of retrying initializing.
// +optional
RetryCount int32
// LastReInitializingTimestamp is a timestamp that describes the last time of retrying initializing.
// +optional
LastReInitializingTimestamp metav1.Time
}
// PersistentBackEnd indicates the backend type and attributes of the persistent
// log store.
type PersistentBackEnd struct {
CLS *StorageBackEndCLS
ES *StorageBackEndES
}
// StorageBackEndCLS records the attributes required when the backend storage
// type is CLS.
type StorageBackEndCLS struct {
LogSetID string
TopicID string
}
// StorageBackEndES records the attributes required when the backend storage
// type is ElasticSearch.
type StorageBackEndES struct {
IP string
Port int32
Scheme string
IndexName string
User string
Password string
ReserveDays int32
}
// +k8s:conversion-gen:explicit-from=net/url.Values
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ProxyOptions is the query options to a proxy call.
type ProxyOptions struct {
metav1.TypeMeta
// Path is the URL path to use for the current proxy request to helm-api.
// +optional
Path string
}
// AddonPhase defines the phase of addon
type AddonPhase string
const (
// AddonPhaseInitializing means is wait initializing.
AddonPhaseInitializing AddonPhase = "Initializing"
// AddonPhaseReinitializing means is reinitializing.
AddonPhaseReinitializing AddonPhase = "Reinitializing"
// AddonPhaseChecking means is wait checking.
AddonPhaseChecking AddonPhase = "Checking"
// AddonPhaseRunning means is running.
AddonPhaseRunning AddonPhase = "Running"
// AddonPhaseUpgrading means is upgrading.
AddonPhaseUpgrading AddonPhase = "Upgrading"
// AddonPhaseFailed means has been failed.
AddonPhaseFailed AddonPhase = "Failed"
// AddonPhasePending means the controller is proceeding deploying
AddonPhasePending AddonPhase = "Pending"
// AddonPhaseUnhealthy means some pods of GPUManager is partial running
AddonPhaseUnhealthy AddonPhase = "Unhealthy"
// AddonPhaseTerminating means addon terminating
AddonPhaseTerminating AddonPhase = "Terminating"
// AddonPhaseUnknown means addon unknown
AddonPhaseUnknown AddonPhase = "Unknown"
)
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConfigMap holds configuration data for tke to consume.
type ConfigMap struct {
metav1.TypeMeta
// +optional
metav1.ObjectMeta
// Data contains the configuration data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// Values with non-UTF-8 byte sequences must use the BinaryData field.
// The keys stored in Data must not overlap with the keys in
// the BinaryData field, this is enforced during validation process.
// +optional
Data map[string]string
// BinaryData contains the binary data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// BinaryData can contain byte sequences that are not in the UTF-8 range.
// The keys stored in BinaryData must not overlap with the ones in
// the Data field, this is enforced during validation process.
// +optional
BinaryData map[string][]byte
}
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConfigMapList is a resource containing a list of ConfigMap objects.
type ConfigMapList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta