/
types.go
231 lines (206 loc) · 8.18 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
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
)
type ClusterConditionType string
const (
// ClusterConditionReady Cluster ready to serve API (healthy when true, unehalthy when false)
ClusterConditionReady = "Ready"
// ClusterConditionProvisioned Cluster is provisioned
ClusterConditionProvisioned = "Provisioned"
// ClusterConditionUpdating Cluster is being updating (upgrading, scaling up)
ClusterConditionUpdating = "Updating"
// ClusterConditionSufficientDisk true when all cluster nodes have sufficient disk
ClusterConditionSufficientDisk = "SufficientDisk"
// ClusterConditionSufficientMemory true when all cluster nodes have sufficient memory
ClusterConditionSufficientMemory = "SufficientMemory"
// ClusterConditionNoDiskPressure true when all cluster nodes have no disk pressure
ClusterConditionNoDiskPressure = "NoDiskPressure"
// More conditions can be added if unredlying controllers request it
)
type Cluster struct {
metav1.TypeMeta `json:",inline"`
// Standard object’s metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec ClusterSpec `json:"spec"`
// Most recent observed status of the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Status *ClusterStatus `json:"status"`
}
type ClusterList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ListMeta `json:"metadata,omitempty"`
// List of Clusters
Items []*Cluster `json:"items"`
}
type ClusterSpec struct {
GKEConfig *GKEConfig `json:"gkeConfig,omitempty"`
AKSConfig *AKSConfig `json:"aksConfig,omitempty"`
RKEConfig *RKEConfig `json:"rkeConfig,omitempty"`
}
type ClusterStatus struct {
//Conditions represent the latest available observations of an object's current state:
//More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties
Conditions []ClusterCondition `json:"conditions,omitempty"`
//Component statuses will represent cluster's components (etcd/controller/scheduler) health
// https://kubernetes.io/docs/api-reference/v1.8/#componentstatus-v1-core
ComponentStatuses v1.ComponentStatusList
APIEndpoint string `json:"apiEndpoint,omitempty"`
ServiceAccountToken string `json:"serviceAccountToken,omitempty"`
CACert string `json:"caCert,omitempty"`
Capacity v1.ResourceList `json:"capacity,omitempty"`
Allocatable v1.ResourceList `json:"allocatable,omitempty"`
}
type ClusterCondition struct {
// Type of cluster condition.
Type ClusterConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status v1.ConditionStatus `json:"status"`
// The last time this condition was updated.
LastUpdateTime string `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
LastTransitionTime string `json:"lastTransitionTime,omitempty"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty"`
}
type GKEConfig struct {
// ProjectID is the ID of your project to use when creating a cluster
ProjectID string `json:"projectId,omitempty"`
// The zone to launch the cluster
Zone string `json:"zone,omitempty"`
// The IP address range of the container pods
ClusterIpv4Cidr string `json:"clusterIpv4Cidr,omitempty"`
// An optional description of this cluster
Description string `json:"description,omitempty"`
// The number of nodes to create in this cluster
InitialNodeCount int64 `json:"initialNodeCount,omitempty"`
// Size of the disk attached to each node
DiskSizeGb int64 `json:"diskSizeGb,omitempty"`
// The name of a Google Compute Engine
MachineType string `json:"machineType,omitempty"`
// the initial kubernetes version
InitialClusterVersion string `json:"initialClusterVersion,omitempty"`
// The map of Kubernetes labels (key/value pairs) to be applied
// to each node.
Labels map[string]string `json:"labels,omitempty"`
// The path to the credential file(key.json)
CredentialPath string `json:"credentialPath,omitempty"`
// Enable alpha feature
EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty"`
// NodePool id
NodePoolID string `json:"nodePoolId,omitempty"`
// Update Config
UpdateConfig gkeUpdateConfig `json:"updateConfig,omitempty"`
}
type gkeUpdateConfig struct {
// the number of node
NodeCount int64 `json:"nodeCount,omitempty"`
// Master kubernetes version
MasterVersion string `json:"masterVersion,omitempty"`
// Node kubernetes version
NodeVersion string `json:"nodeVersion,omitempty"`
}
type AKSConfig struct {
//TBD
}
type RKEConfig struct {
// Kubernetes nodes
Hosts []RKEConfigHost `yaml:"hosts"`
// Kubernetes components
Services RKEConfigServices `yaml:"services"`
// Network plugin used in the kubernetes cluster (flannel, calico)
NetworkPlugin string `yaml:"network_plugin"`
// Authentication type used in the cluster (default: x509)
AuthType string `yaml:"auth_type"`
}
type RKEConfigHost struct {
// SSH IP address of the host
IP string `yaml:"ip"`
// Advertised address that will be used for components communication
AdvertiseAddress string `yaml:"advertise_address"`
// Host role in kubernetes cluster (controlplane, worker, or etcd)
Role []string `yaml:"role"`
// Hostname of the host
Hostname string `yaml:"hostname"`
// SSH usesr that will be used by RKE
User string `yaml:"user"`
// Docker socket on the host that will be used in tunneling
DockerSocket string `yaml:"docker_socket"`
}
type RKEConfigServices struct {
// Etcd Service
Etcd ETCDService `yaml:"etcd"`
// KubeAPI Service
KubeAPI KubeAPIService `yaml:"kube-api"`
// KubeController Service
KubeController KubeControllerService `yaml:"kube-controller"`
// Scheduler Service
Scheduler SchedulerService `yaml:"scheduler"`
// Kubelet Service
Kubelet KubeletService `yaml:"kubelet"`
// KubeProxy Service
Kubeproxy KubeproxyService `yaml:"kubeproxy"`
}
type ETCDService struct {
// Base service properties
baseService `yaml:",inline"`
}
type KubeAPIService struct {
// Base service properties
baseService `yaml:",inline"`
// Virtual IP range that will be used by Kubernetes services
ServiceClusterIPRange string `yaml:"service_cluster_ip_range"`
}
type KubeControllerService struct {
// Base service properties
baseService `yaml:",inline"`
// CIDR Range for Pods in cluster
ClusterCIDR string `yaml:"cluster_cidr"`
// Virtual IP range that will be used by Kubernetes services
ServiceClusterIPRange string `yaml:"service_cluster_ip_range"`
}
type KubeletService struct {
// Base service properties
baseService `yaml:",inline"`
// Domain of the cluster (default: "cluster.local")
ClusterDomain string `yaml:"cluster_domain"`
// The image whose network/ipc namespaces containers in each pod will use
InfraContainerImage string `yaml:"infra_container_image"`
// Cluster DNS service ip
ClusterDNSServer string `yaml:"cluster_dns_server"`
}
type KubeproxyService struct {
// Base service properties
baseService `yaml:",inline"`
}
type SchedulerService struct {
// Base service properties
baseService `yaml:",inline"`
}
type baseService struct {
// Docker image of the service
Image string `yaml:"image"`
}
type ClusterNode struct {
v1.Node
}
type ClusterNodeMetadata struct {
// Standard object’s metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
}
type ClusterNodeList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ListMeta `json:"metadata,omitempty"`
// List of Clusters
Items []*Cluster `json:"items"`
}