-
Notifications
You must be signed in to change notification settings - Fork 15
/
microk8sconfig_types.go
211 lines (165 loc) · 7.14 KB
/
microk8sconfig_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
/*
Copyright 2022.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
// JoinConfiguration contains elements describing a particular node.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ClusterConfiguration contains cluster-wide configuration for a kubeadm cluster.
type ClusterConfiguration struct {
metav1.TypeMeta `json:",inline"`
// cluster agent port (25000) and dqlite port (19001) set to use ports 30000 and 2379 respectively
// The default ports of cluster agent and dqlite are blocked by security groups and as a temporary
// workaround we reuse the etcd and calico ports that are open in the infra providers because kubeadm uses those.
// PortCompatibilityRemap switches the default ports used by cluster agent (25000) and dqlite (19001)
// to 30000 and 2379. The default ports are blocked via security groups in several infra providers.
// +kubebuilder:default:=true
// +optional
PortCompatibilityRemap bool `json:"portCompatibilityRemap,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type InitConfiguration struct {
metav1.TypeMeta `json:",inline"`
// The join token will expire after the specified seconds, defaults to 10 years
// +optional
// +kubebuilder:default:=315569260
// +kubebuilder:validation:Minimum:=1
JoinTokenTTLInSecs int64 `json:"joinTokenTTLInSecs,omitempty"`
// The optional https proxy configuration
// +optional
HTTPSProxy string `json:"httpsProxy,omitempty"`
// The optional http proxy configuration
// +optional
HTTPProxy string `json:"httpProxy,omitempty"`
// The optional no proxy configuration
// +optional
NoProxy string `json:"noProxy,omitempty"`
// List of addons to be enabled upon cluster creation
// +optional
Addons []string `json:"addons,omitempty"`
// The optional IPinIP configuration
// +optional
IPinIP bool `json:"IPinIP,omitempty"`
// The confinement (strict or classic) configuration
// +optional
// +kubebuilder:validation:Enum=classic;strict
Confinement string `json:"confinement,omitempty"`
// The risk-level (stable, candidate, beta, or edge) for the snaps
// +optional
// +kubebuilder:validation:Enum=stable;candidate;beta;edge
// +kubebuilder:default:=stable
RiskLevel string `json:"riskLevel,omitempty"`
// Whether or not to use the default CNI
// +optional
DisableDefaultCNI bool `json:"disableDefaultCNI,omitempty"`
// The snap store proxy domain's scheme, e.g. "http" or "https" without "://"
// Defaults to "http".
// +optional
SnapstoreProxyScheme string `json:"snapstoreProxyScheme,omitempty"`
// The snap store proxy domain
// +optional
SnapstoreProxyDomain string `json:"snapstoreProxyDomain,omitempty"`
// The snap store proxy ID
// +optional
SnapstoreProxyId string `json:"snapstoreProxyId,omitempty"`
// Optional http proxy configuration for the snap store
// +optional
SnapstoreHTTPProxy string `json:"snapstoreHTTPProxy,omitempty"`
// Optional https proxy configuration for the snap store
// +optional
SnapstoreHTTPSProxy string `json:"snapstoreHTTPSProxy,omitempty"`
// ExtraWriteFiles is a list of extra files to inject with cloud-init.
// +optional
ExtraWriteFiles []CloudInitWriteFile `json:"extraWriteFiles,omitempty"`
// ExtraKubeletArgs is a list of extra arguments to add to the kubelet.
// +optional
ExtraKubeletArgs []string `json:"extraKubeletArgs,omitempty"`
// BootCommands is a list of commands to run during boot.
// These will be injected into the `bootcmd` section of cloud-init.
BootCommands []string `json:"bootCommands,omitempty"`
// PreRunCommands is a list of commands to run before installing MicroK8s.
// These will be injected into the `runcmd` section of cloud-init.
// +optional
PreRunCommands []string `json:"preRunCommands,omitempty"`
// PostRunCommands is a list of commands to run after installing MicroK8s.
// These will be injected into the `runcmd` section of cloud-init.
// +optional
PostRunCommands []string `json:"postRunCommands,omitempty"`
}
// CloudInitWriteFile is a file that will be injected by cloud-init
type CloudInitWriteFile struct {
// Content of the file to create.
Content string `json:"content"`
// Path where the file should be created.
Path string `json:"path"`
// Permissions of the file to create, e.g. "0600"
Permissions string `json:"permissions"`
// Owner of the file to create, e.g. "root:root"
Owner string `json:"owner"`
}
// MicroK8sConfigSpec defines the desired state of MicroK8sConfig
type MicroK8sConfigSpec struct {
// InitConfiguration along with ClusterConfiguration are the configurations necessary for the init command
// +optional
ClusterConfiguration *ClusterConfiguration `json:"clusterConfiguration,omitempty"`
InitConfiguration *InitConfiguration `json:"initConfiguration,omitempty"`
}
// MicroK8sConfigStatus defines the observed state of MicroK8sConfig
type MicroK8sConfigStatus struct {
// Ready indicates the BootstrapData field is ready to be consumed
Ready bool `json:"ready,omitempty"`
// DataSecretName is the name of the secret that stores the bootstrap data script.
// +optional
DataSecretName *string `json:"dataSecretName,omitempty"`
// FailureReason will be set on non-retryable errors
// +optional
FailureReason string `json:"failureReason,omitempty"`
// FailureMessage will be set on non-retryable errors
// +optional
FailureMessage string `json:"failureMessage,omitempty"`
// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// MicroK8sConfig is the Schema for the microk8sconfigs API
type MicroK8sConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MicroK8sConfigSpec `json:"spec,omitempty"`
Status MicroK8sConfigStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// MicroK8sConfigList contains a list of MicroK8sConfig
type MicroK8sConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MicroK8sConfig `json:"items"`
}
func init() {
SchemeBuilder.Register(&MicroK8sConfig{}, &MicroK8sConfigList{})
}
// GetConditions returns the set of conditions for this object.
func (c *MicroK8sConfig) GetConditions() clusterv1.Conditions {
return c.Status.Conditions
}
// SetConditions sets the conditions on this object.
func (c *MicroK8sConfig) SetConditions(conditions clusterv1.Conditions) {
c.Status.Conditions = conditions
}