-
Notifications
You must be signed in to change notification settings - Fork 15
/
cluster.go
668 lines (590 loc) · 20.3 KB
/
cluster.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
package cke
import (
"encoding/json"
"errors"
"fmt"
"net"
"path/filepath"
"regexp"
"strings"
"github.com/containernetworking/cni/libcni"
corev1 "k8s.io/api/core/v1"
apivalidation "k8s.io/apimachinery/pkg/api/validation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
v1validation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
proxyv1alpha1 "k8s.io/kube-proxy/config/v1alpha1"
schedulerv1 "k8s.io/kube-scheduler/config/v1"
kubeletv1beta1 "k8s.io/kubelet/config/v1beta1"
"sigs.k8s.io/yaml"
)
// Node represents a node in Kubernetes.
type Node struct {
Address string `json:"address"`
Hostname string `json:"hostname"`
User string `json:"user"`
ControlPlane bool `json:"control_plane"`
Annotations map[string]string `json:"annotations"`
Labels map[string]string `json:"labels"`
Taints []corev1.Taint `json:"taints"`
}
// Nodename returns a hostname or address if hostname is empty
func (n *Node) Nodename() string {
if len(n.Hostname) == 0 {
return n.Address
}
return n.Hostname
}
// BindPropagation is bind propagation option for Docker
// https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation
type BindPropagation string
// Bind propagation definitions
const (
PropagationShared = BindPropagation("shared")
PropagationSlave = BindPropagation("slave")
PropagationPrivate = BindPropagation("private")
PropagationRShared = BindPropagation("rshared")
PropagationRSlave = BindPropagation("rslave")
PropagationRPrivate = BindPropagation("rprivate")
)
func (p BindPropagation) String() string {
return string(p)
}
// SELinuxLabel is selinux label of the host file or directory
// https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label
type SELinuxLabel string
// SELinux Label definitions
const (
LabelShared = SELinuxLabel("z")
LabelPrivate = SELinuxLabel("Z")
)
func (l SELinuxLabel) String() string {
return string(l)
}
// Mount is volume mount information
type Mount struct {
Source string `json:"source"`
Destination string `json:"destination"`
ReadOnly bool `json:"read_only"`
Propagation BindPropagation `json:"propagation"`
Label SELinuxLabel `json:"selinux_label"`
}
// Equal returns true if the mount is equals to other one, otherwise return false
func (m Mount) Equal(o Mount) bool {
return m.Source == o.Source && m.Destination == o.Destination && m.ReadOnly == o.ReadOnly
}
// ServiceParams is a common set of extra parameters for k8s components.
type ServiceParams struct {
ExtraArguments []string `json:"extra_args"`
ExtraBinds []Mount `json:"extra_binds"`
ExtraEnvvar map[string]string `json:"extra_env"`
}
// Equal returns true if the services params is equals to other one, otherwise return false
func (s ServiceParams) Equal(o ServiceParams) bool {
return compareStrings(s.ExtraArguments, o.ExtraArguments) &&
compareMounts(s.ExtraBinds, o.ExtraBinds) &&
compareStringMap(s.ExtraEnvvar, o.ExtraEnvvar)
}
// EtcdParams is a set of extra parameters for etcd.
type EtcdParams struct {
ServiceParams `json:",inline"`
VolumeName string `json:"volume_name"`
}
// APIServerParams is a set of extra parameters for kube-apiserver.
type APIServerParams struct {
ServiceParams `json:",inline"`
AuditLogEnabled bool `json:"audit_log_enabled"`
AuditLogPolicy string `json:"audit_log_policy"`
AuditLogPath string `json:"audit_log_path"`
}
// CNIConfFile is a config file for CNI plugin deployed on worker nodes by CKE.
type CNIConfFile struct {
Name string `json:"name"`
Content string `json:"content"`
}
// SchedulerParams is a set of extra parameters for kube-scheduler.
type SchedulerParams struct {
ServiceParams `json:",inline"`
Config *unstructured.Unstructured `json:"config,omitempty"`
}
// MergeConfig merges the input struct `base`.
func (p SchedulerParams) MergeConfig(base *schedulerv1.KubeSchedulerConfiguration) (*schedulerv1.KubeSchedulerConfiguration, error) {
// FOR IMPLEMENTORS.
// DO NOT SUPPORT MORE THAN ONE ComponentConfig VERSIONS.
// When we need to upgrade the component config version, users will
// stop CKE, update cluster.yml in etcd, then start the new CKE.
// So, CKE should only support the latest config version.
cfg := *base.DeepCopy()
if p.Config == nil {
return &cfg, nil
}
if p.Config.GetAPIVersion() != schedulerv1.SchemeGroupVersion.String() {
return nil, fmt.Errorf("unexpected kube-scheduler API version: %s", p.Config.GetAPIVersion())
}
if p.Config.GetKind() != "KubeSchedulerConfiguration" {
return nil, fmt.Errorf("wrong kind for kube-scheduler config: %s", p.Config.GetKind())
}
data, err := json.Marshal(p.Config)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &cfg)
if err != nil {
return nil, err
}
cfg.TypeMeta = metav1.TypeMeta{}
return &cfg, nil
}
// ProxyParams is a set of extra parameters for kube-proxy.
type ProxyParams struct {
ServiceParams `json:",inline"`
Disable bool `json:"disable,omitempty"`
Config *unstructured.Unstructured `json:"config,omitempty"`
}
// GetMode returns the proxy mode.
func (p ProxyParams) GetMode() string {
mode := p.Config.UnstructuredContent()["Mode"].(string)
if len(mode) == 0 {
return string(ProxyModeIPVS)
}
return mode
}
// MergeConfig merges the input struct with `base`.
func (p ProxyParams) MergeConfig(base *proxyv1alpha1.KubeProxyConfiguration) (*proxyv1alpha1.KubeProxyConfiguration, error) {
// FOR IMPLEMENTORS.
// DO NOT SUPPORT MORE THAN ONE ComponentConfig VERSIONS.
// When we need to upgrade the component config version, users will
// stop CKE, update cluster.yml in etcd, then start the new CKE.
// So, CKE should only support the latest config version.
cfg := *base.DeepCopy()
if p.Config == nil {
return &cfg, nil
}
if p.Config.GetAPIVersion() != proxyv1alpha1.SchemeGroupVersion.String() {
return nil, fmt.Errorf("unexpected kube-proxy API version: %s", p.Config.GetAPIVersion())
}
if p.Config.GetKind() != "KubeProxyConfiguration" {
return nil, fmt.Errorf("wrong kind for kube-proxy config: %s", p.Config.GetKind())
}
data, err := json.Marshal(p.Config)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &cfg)
if err != nil {
return nil, err
}
cfg.TypeMeta = metav1.TypeMeta{}
return &cfg, nil
}
// ProxyMode is a type for kube-proxy's --proxy-mode argument.
type ProxyMode string
const (
ProxyModeUserspace proxyv1alpha1.ProxyMode = "userspace"
ProxyModeIptables proxyv1alpha1.ProxyMode = "iptables"
ProxyModeIPVS proxyv1alpha1.ProxyMode = "ipvs"
)
// ValidateProxyMode validates ProxyMode
func ValidateProxyMode(mode proxyv1alpha1.ProxyMode) error {
switch mode {
case ProxyModeUserspace, ProxyModeIptables, ProxyModeIPVS:
return nil
}
return errors.New("invalid proxy mode " + string(mode))
}
// KubeletParams is a set of extra parameters for kubelet.
type KubeletParams struct {
ServiceParams `json:",inline"`
BootTaints []corev1.Taint `json:"boot_taints"`
CNIConfFile CNIConfFile `json:"cni_conf_file"`
Config *unstructured.Unstructured `json:"config,omitempty"`
CRIEndpoint string `json:"cri_endpoint"`
}
// MergeConfig merges the input struct with `base`.
func (p KubeletParams) MergeConfig(base *kubeletv1beta1.KubeletConfiguration) (*kubeletv1beta1.KubeletConfiguration, error) {
// FOR IMPLEMENTORS.
// DO NOT SUPPORT MORE THAN ONE ComponentConfig VERSIONS.
// When we need to upgrade the component config version, users will
// stop CKE, update cluster.yml in etcd, then start the new CKE.
// So, CKE should only support the latest config version.
cfg := *base.DeepCopy()
if p.Config == nil {
return &cfg, nil
}
if p.Config.GetAPIVersion() != kubeletv1beta1.SchemeGroupVersion.String() {
return nil, fmt.Errorf("unexpected kubelet API version: %s", p.Config.GetAPIVersion())
}
if p.Config.GetKind() != "KubeletConfiguration" {
return nil, fmt.Errorf("wrong kind for kubelet config: %s", p.Config.GetKind())
}
data, err := json.Marshal(p.Config)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &cfg)
if err != nil {
return nil, err
}
cfg.TypeMeta = metav1.TypeMeta{}
return &cfg, nil
}
// Reboot is a set of configurations for reboot.
type Reboot struct {
RebootCommand []string `json:"reboot_command"`
BootCheckCommand []string `json:"boot_check_command"`
MaxConcurrentReboots *int `json:"max_concurrent_reboots,omitempty"`
EvictionTimeoutSeconds *int `json:"eviction_timeout_seconds,omitempty"`
CommandTimeoutSeconds *int `json:"command_timeout_seconds,omitempty"`
CommandRetries *int `json:"command_retries"`
CommandInterval *int `json:"command_interval"`
EvictRetries *int `json:"evict_retries"`
EvictInterval *int `json:"evict_interval"`
ProtectedNamespaces *metav1.LabelSelector `json:"protected_namespaces,omitempty"`
}
const DefaultRebootEvictionTimeoutSeconds = 600
const DefaultMaxConcurrentReboots = 1
type Repair struct {
RepairProcedures []RepairProcedure `json:"repair_procedures"`
MaxConcurrentRepairs *int `json:"max_concurrent_repairs,omitempty"`
ProtectedNamespaces *metav1.LabelSelector `json:"protected_namespaces,omitempty"`
EvictRetries *int `json:"evict_retries,omitempty"`
EvictInterval *int `json:"evict_interval,omitempty"`
EvictionTimeoutSeconds *int `json:"eviction_timeout_seconds,omitempty"`
}
type RepairProcedure struct {
MachineTypes []string `json:"machine_types"`
RepairOperations []RepairOperation `json:"repair_operations"`
}
type RepairOperation struct {
Operation string `json:"operation"`
RepairSteps []RepairStep `json:"repair_steps"`
HealthCheckCommand []string `json:"health_check_command"`
CommandTimeoutSeconds *int `json:"command_timeout_seconds,omitempty"`
}
type RepairStep struct {
RepairCommand []string `json:"repair_command"`
CommandTimeoutSeconds *int `json:"command_timeout_seconds,omitempty"`
CommandRetries *int `json:"command_retries,omitempty"`
CommandInterval *int `json:"command_interval,omitempty"`
NeedDrain bool `json:"need_drain,omitempty"`
WatchSeconds *int `json:"watch_seconds,omitempty"`
}
const DefaultMaxConcurrentRepairs = 1
const DefaultRepairEvictionTimeoutSeconds = 600
const DefaultRepairHealthCheckCommandTimeoutSeconds = 30
const DefaultRepairCommandTimeoutSeconds = 30
// Options is a set of optional parameters for k8s components.
type Options struct {
Etcd EtcdParams `json:"etcd"`
Rivers ServiceParams `json:"rivers"`
EtcdRivers ServiceParams `json:"etcd-rivers"`
APIServer APIServerParams `json:"kube-api"`
ControllerManager ServiceParams `json:"kube-controller-manager"`
Scheduler SchedulerParams `json:"kube-scheduler"`
Proxy ProxyParams `json:"kube-proxy"`
Kubelet KubeletParams `json:"kubelet"`
}
// Cluster is a set of configurations for a etcd/Kubernetes cluster.
type Cluster struct {
Name string `json:"name"`
Nodes []*Node `json:"nodes"`
TaintCP bool `json:"taint_control_plane"`
CPTolerations []string `json:"control_plane_tolerations"`
ServiceSubnet string `json:"service_subnet"`
DNSServers []string `json:"dns_servers"`
DNSService string `json:"dns_service"`
Reboot Reboot `json:"reboot"`
Repair Repair `json:"repair"`
Options Options `json:"options"`
}
// Validate validates the cluster definition.
func (c *Cluster) Validate(isTmpl bool) error {
if len(c.Name) == 0 {
return errors.New("cluster name is empty")
}
_, _, err := net.ParseCIDR(c.ServiceSubnet)
if err != nil {
return err
}
fldPath := field.NewPath("nodes")
nodeAddressSet := make(map[string]struct{})
for i, n := range c.Nodes {
err := validateNode(n, isTmpl, fldPath.Index(i))
if err != nil {
return err
}
if _, ok := nodeAddressSet[n.Address]; ok {
return errors.New("duplicate node address: " + n.Address)
}
if !isTmpl {
nodeAddressSet[n.Address] = struct{}{}
}
}
fldPath = field.NewPath("control_plane_tolerations")
err = validateTolerationKeys(c.CPTolerations, fldPath)
if err != nil {
return err
}
for _, a := range c.DNSServers {
if net.ParseIP(a) == nil {
return errors.New("invalid IP address: " + a)
}
}
if len(c.DNSService) > 0 {
fields := strings.Split(c.DNSService, "/")
if len(fields) != 2 {
return errors.New("invalid DNS service (no namespace?): " + c.DNSService)
}
}
err = validateReboot(c.Reboot)
if err != nil {
return err
}
err = validateOptions(c.Options)
if err != nil {
return err
}
return nil
}
func validateNode(n *Node, isTmpl bool, fldPath *field.Path) error {
if isTmpl {
if len(n.Address) != 0 {
return errors.New("address is not empty: " + n.Address)
}
} else {
if net.ParseIP(n.Address) == nil {
return errors.New("invalid IP address: " + n.Address)
}
}
if len(n.User) == 0 {
return errors.New("user name is empty")
}
if err := validateNodeLabels(n, fldPath.Child("labels")); err != nil {
return err
}
if err := validateNodeAnnotations(n, fldPath.Child("annotations")); err != nil {
return err
}
if err := validateNodeTaints(n, fldPath.Child("taints")); err != nil {
return err
}
return nil
}
// validateNodeLabels validates label names and values with
// rules described in:
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
func validateNodeLabels(n *Node, fldPath *field.Path) error {
el := v1validation.ValidateLabels(n.Labels, fldPath)
if len(el) == 0 {
return nil
}
return el.ToAggregate()
}
// validateNodeAnnotations validates annotation names.
// The validation logic references:
// https://github.com/kubernetes/apimachinery/blob/v0.21.7/pkg/api/validation/objectmeta.go#L186
func validateNodeAnnotations(n *Node, fldPath *field.Path) error {
el := apivalidation.ValidateAnnotations(n.Annotations, fldPath)
if len(el) == 0 {
return nil
}
return el.ToAggregate()
}
// validateNodeTaints validates taint names, values, and effects.
func validateNodeTaints(n *Node, fldPath *field.Path) error {
for i, taint := range n.Taints {
err := validateTaint(taint, fldPath.Index(i))
if err != nil {
return err
}
}
return nil
}
// validateTaint validates a taint name, value, and effect.
// The validation logic references:
// https://github.com/kubernetes/kubernetes/blob/7cbb9995189c5ecc8182da29cd0e30188c911401/pkg/apis/core/validation/validation.go#L4105
func validateTaint(taint corev1.Taint, fldPath *field.Path) error {
el := v1validation.ValidateLabelName(taint.Key, fldPath.Child("key"))
if msgs := validation.IsValidLabelValue(taint.Value); len(msgs) > 0 {
el = append(el, field.Invalid(fldPath.Child("value"), taint.Value, strings.Join(msgs, ";")))
}
switch taint.Effect {
case corev1.TaintEffectNoSchedule:
case corev1.TaintEffectPreferNoSchedule:
case corev1.TaintEffectNoExecute:
default:
el = append(el, field.Invalid(fldPath.Child("effect"), string(taint.Effect), "invalid effect"))
}
if len(el) > 0 {
return el.ToAggregate()
}
return nil
}
func validateTolerationKeys(keys []string, fldPath *field.Path) error {
var el field.ErrorList
for i, key := range keys {
el = append(el, v1validation.ValidateLabelName(key, fldPath.Index(i))...)
}
if len(el) > 0 {
return el.ToAggregate()
}
return nil
}
// ControlPlanes returns control planes []*Node
func ControlPlanes(nodes []*Node) []*Node {
return filterNodes(nodes, func(n *Node) bool {
return n.ControlPlane
})
}
// Workers returns workers []*Node
func Workers(nodes []*Node) []*Node {
return filterNodes(nodes, func(n *Node) bool {
return !n.ControlPlane
})
}
func filterNodes(nodes []*Node, f func(n *Node) bool) []*Node {
var filtered []*Node
for _, n := range nodes {
if f(n) {
filtered = append(filtered, n)
}
}
return filtered
}
func validateReboot(reboot Reboot) error {
if reboot.EvictionTimeoutSeconds != nil && *reboot.EvictionTimeoutSeconds <= 0 {
return errors.New("eviction_timeout_seconds must be positive")
}
if reboot.CommandTimeoutSeconds != nil && *reboot.CommandTimeoutSeconds < 0 {
return errors.New("command_timeout_seconds must not be negative")
}
if reboot.CommandRetries != nil && *reboot.CommandRetries < 0 {
return errors.New("command_retries must not be negative")
}
if reboot.CommandInterval != nil && *reboot.CommandInterval < 0 {
return errors.New("command_interval must not be negative")
}
if reboot.EvictRetries != nil && *reboot.EvictRetries < 0 {
return errors.New("evict_retries must not be negative")
}
if reboot.EvictInterval != nil && *reboot.EvictInterval < 0 {
return errors.New("evict_interval must not be negative")
}
if reboot.MaxConcurrentReboots != nil && *reboot.MaxConcurrentReboots <= 0 {
return errors.New("max_concurrent_reboots must be positive")
}
// nil is safe for LabelSelectorAsSelector
_, err := metav1.LabelSelectorAsSelector(reboot.ProtectedNamespaces)
if err != nil {
return fmt.Errorf("invalid label selector: %w", err)
}
return nil
}
func validateOptions(opts Options) error {
v := func(binds []Mount) error {
for _, m := range binds {
if !filepath.IsAbs(m.Source) {
return errors.New("source path must be absolute: " + m.Source)
}
if !filepath.IsAbs(m.Destination) {
return errors.New("destination path must be absolute: " + m.Destination)
}
}
return nil
}
err := v(opts.Etcd.ExtraBinds)
if err != nil {
return err
}
err = v(opts.APIServer.ExtraBinds)
if err != nil {
return err
}
err = v(opts.ControllerManager.ExtraBinds)
if err != nil {
return err
}
err = v(opts.Scheduler.ExtraBinds)
if err != nil {
return err
}
err = v(opts.Proxy.ExtraBinds)
if err != nil {
return err
}
err = v(opts.Kubelet.ExtraBinds)
if err != nil {
return err
}
base := &kubeletv1beta1.KubeletConfiguration{}
kubeletConfig, err := opts.Kubelet.MergeConfig(base)
if err != nil {
return err
}
fldPath := field.NewPath("options", "kubelet")
if len(kubeletConfig.ClusterDomain) > 0 {
msgs := validation.IsDNS1123Subdomain(kubeletConfig.ClusterDomain)
if len(msgs) > 0 {
return field.Invalid(fldPath.Child("domain"),
kubeletConfig.ClusterDomain, strings.Join(msgs, ";"))
}
}
if len(opts.Kubelet.CRIEndpoint) == 0 {
return errors.New("kubelet.cri_endpoint should not be empty")
}
if len(opts.Kubelet.CNIConfFile.Content) != 0 && len(opts.Kubelet.CNIConfFile.Name) == 0 {
return fmt.Errorf("kubelet.cni_conf_file.name should not be empty when kubelet.cni_conf_file.content is not empty")
}
if filename := opts.Kubelet.CNIConfFile.Name; len(filename) != 0 {
matched, err := regexp.Match(`^[0-9A-Za-z_.-]+$`, []byte(filename))
if err != nil {
return err
}
if !matched {
return errors.New(filename + " is invalid as file name")
}
if filepath.Ext(opts.Kubelet.CNIConfFile.Name) == ".conflist" {
_, err = libcni.ConfListFromBytes([]byte(opts.Kubelet.CNIConfFile.Content))
if err != nil {
return err
}
} else {
_, err = libcni.ConfFromBytes([]byte(opts.Kubelet.CNIConfFile.Content))
if err != nil {
return err
}
}
}
fldPath = fldPath.Child("boot_taints")
for i, taint := range opts.Kubelet.BootTaints {
err := validateTaint(taint, fldPath.Index(i))
if err != nil {
return err
}
}
if opts.APIServer.AuditLogEnabled && len(opts.APIServer.AuditLogPolicy) == 0 {
return errors.New("audit_log_policy should not be empty")
}
if len(opts.APIServer.AuditLogPolicy) != 0 {
policy := make(map[string]interface{})
err = yaml.Unmarshal([]byte(opts.APIServer.AuditLogPolicy), &policy)
if err != nil {
return err
}
}
if _, err := opts.Scheduler.MergeConfig(&schedulerv1.KubeSchedulerConfiguration{}); err != nil {
return err
}
p, err := opts.Proxy.MergeConfig(&proxyv1alpha1.KubeProxyConfiguration{})
if err != nil {
return err
}
if len(p.Mode) != 0 {
if err := ValidateProxyMode(p.Mode); err != nil {
return err
}
}
return nil
}