/
config.go
168 lines (139 loc) · 5.52 KB
/
config.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
// Copyright Istio 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 config
import (
"fmt"
"strings"
)
type Config struct {
InstallConfig InstallConfig
RepairConfig RepairConfig
}
// InstallConfig struct defines the Istio CNI installation options
type InstallConfig struct {
// Location of the CNI config files in the host's filesystem
CNINetDir string
// Location of the CNI config files in the container's filesystem (mount location of the CNINetDir)
MountedCNINetDir string
// Name of the CNI config file
CNIConfName string
// Whether to install CNI plugin as a chained or standalone
ChainedCNIPlugin bool
// CNI config template file
CNINetworkConfigFile string
// CNI config template string
CNINetworkConfig string
// Logging level
LogLevel string
// Name of the kubeconfig file used by the CNI plugin
KubeconfigFilename string
// The file mode to set when creating the kubeconfig file
KubeconfigMode int
// CA file for kubeconfig
KubeCAFile string
// Whether to use insecure TLS in the kubeconfig file
SkipTLSVerify bool
// KUBERNETES_SERVICE_PROTOCOL
K8sServiceProtocol string
// KUBERNETES_SERVICE_HOST
K8sServiceHost string
// KUBERNETES_SERVICE_PORT
K8sServicePort string
// KUBERNETES_NODE_NAME
K8sNodeName string
// Directory from where the CNI binaries should be copied
CNIBinSourceDir string
// Directories into which to copy the CNI binaries
CNIBinTargetDirs []string
// The HTTP port for monitoring
MonitoringPort int
// The UDS server address that CNI plugin will send log to.
LogUDSAddress string
// The watch server socket address that CNI plugin will forward CNI events to.
CNIEventAddress string
// The ztunnel server socket address that the ztunnel will connect to.
ZtunnelUDSAddress string
// Whether ambient is enabled
AmbientEnabled bool
// Whether ambient DNS capture is enabled
AmbientDNSCapture bool
// Whether ipv6 is enabled for ambient capture
AmbientIPv6 bool
}
// RepairConfig struct defines the Istio CNI race repair configuration
type RepairConfig struct {
// Whether to enable CNI race repair
Enabled bool
// The node name that the CNI DaemonSet runs on
NodeName string
// Key and value for broken pod label
LabelKey string
LabelValue string
// Whether to fix race condition by repairing them
RepairPods bool
// Whether to fix race condition by delete broken pods
DeletePods bool
// Whether to label broken pods
LabelPods bool
// Filters for race repair, including name of sidecar annotation, name of init container,
// init container termination message and exit code.
SidecarAnnotation string
InitContainerName string
InitTerminationMsg string
InitExitCode int
// Label and field selectors to select pods managed by race repair.
LabelSelectors string
FieldSelectors string
}
func (c InstallConfig) String() string {
var b strings.Builder
b.WriteString("CNINetDir: " + c.CNINetDir + "\n")
b.WriteString("MountedCNINetDir: " + c.MountedCNINetDir + "\n")
b.WriteString("CNIConfName: " + c.CNIConfName + "\n")
b.WriteString("ChainedCNIPlugin: " + fmt.Sprint(c.ChainedCNIPlugin) + "\n")
b.WriteString("CNINetworkConfigFile: " + c.CNINetworkConfigFile + "\n")
b.WriteString("CNINetworkConfig: " + c.CNINetworkConfig + "\n")
b.WriteString("LogLevel: " + c.LogLevel + "\n")
b.WriteString("KubeconfigFilename: " + c.KubeconfigFilename + "\n")
b.WriteString("KubeconfigMode: " + fmt.Sprintf("%#o", c.KubeconfigMode) + "\n")
b.WriteString("KubeCAFile: " + c.KubeCAFile + "\n")
b.WriteString("SkipTLSVerify: " + fmt.Sprint(c.SkipTLSVerify) + "\n")
b.WriteString("K8sServiceProtocol: " + c.K8sServiceProtocol + "\n")
b.WriteString("K8sServiceHost: " + c.K8sServiceHost + "\n")
b.WriteString("K8sServicePort: " + fmt.Sprint(c.K8sServicePort) + "\n")
b.WriteString("K8sNodeName: " + c.K8sNodeName + "\n")
b.WriteString("MonitoringPort: " + fmt.Sprint(c.MonitoringPort) + "\n")
b.WriteString("CNIEventAddress: " + fmt.Sprint(c.CNIEventAddress) + "\n")
b.WriteString("LogUDSAddress: " + fmt.Sprint(c.LogUDSAddress) + "\n")
b.WriteString("AmbientEnabled: " + fmt.Sprint(c.AmbientEnabled) + "\n")
b.WriteString("AmbientDNSCapture: " + fmt.Sprint(c.AmbientDNSCapture) + "\n")
b.WriteString("AmbientIPv6: " + fmt.Sprint(c.AmbientIPv6) + "\n")
return b.String()
}
func (c RepairConfig) String() string {
var b strings.Builder
b.WriteString("Enabled: " + fmt.Sprint(c.Enabled) + "\n")
b.WriteString("NodeName: " + c.NodeName + "\n")
b.WriteString("LabelKey: " + c.LabelKey + "\n")
b.WriteString("LabelValue: " + c.LabelValue + "\n")
b.WriteString("DeletePods: " + fmt.Sprint(c.DeletePods) + "\n")
b.WriteString("LabelPods: " + fmt.Sprint(c.LabelPods) + "\n")
b.WriteString("SidecarAnnotation: " + c.SidecarAnnotation + "\n")
b.WriteString("InitContainerName: " + c.InitContainerName + "\n")
b.WriteString("InitTerminationMsg: " + c.InitTerminationMsg + "\n")
b.WriteString("InitExitCode: " + fmt.Sprint(c.InitExitCode) + "\n")
b.WriteString("LabelSelectors: " + c.LabelSelectors + "\n")
b.WriteString("FieldSelectors: " + c.FieldSelectors + "\n")
return b.String()
}