9
9
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10
10
kerrors "k8s.io/apimachinery/pkg/util/errors"
11
11
utilfeature "k8s.io/apiserver/pkg/util/feature"
12
- kubeproxyoptions "k8s.io/kubernetes/cmd/kube-proxy/app"
13
12
kubeletoptions "k8s.io/kubernetes/cmd/kubelet/app/options"
14
13
"k8s.io/kubernetes/pkg/apis/componentconfig"
15
14
"k8s.io/kubernetes/pkg/features"
@@ -25,7 +24,7 @@ import (
25
24
26
25
// Build creates the core Kubernetes component configs for a given NodeConfig, or returns
27
26
// an error
28
- func Build (options configapi.NodeConfig ) (* kubeletoptions.KubeletServer , * componentconfig. KubeProxyConfiguration , error ) {
27
+ func Build (options configapi.NodeConfig ) (* kubeletoptions.KubeletServer , error ) {
29
28
imageTemplate := variable .NewDefaultImageTemplate ()
30
29
imageTemplate .Format = options .ImageConfig .Format
31
30
imageTemplate .Latest = options .ImageConfig .Latest
@@ -39,11 +38,11 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
39
38
40
39
kubeAddressStr , kubePortStr , err := net .SplitHostPort (options .ServingInfo .BindAddress )
41
40
if err != nil {
42
- return nil , nil , fmt .Errorf ("cannot parse node address: %v" , err )
41
+ return nil , fmt .Errorf ("cannot parse node address: %v" , err )
43
42
}
44
43
kubePort , err := strconv .Atoi (kubePortStr )
45
44
if err != nil {
46
- return nil , nil , fmt .Errorf ("cannot parse node port: %v" , err )
45
+ return nil , fmt .Errorf ("cannot parse node port: %v" , err )
47
46
}
48
47
49
48
// Defaults are tested in TestKubeletDefaults
@@ -91,7 +90,7 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
91
90
// Setup auth
92
91
authnTTL , err := time .ParseDuration (options .AuthConfig .AuthenticationCacheTTL )
93
92
if err != nil {
94
- return nil , nil , err
93
+ return nil , err
95
94
}
96
95
server .Authentication = componentconfig.KubeletAuthentication {
97
96
X509 : componentconfig.KubeletX509Authentication {
@@ -107,7 +106,7 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
107
106
}
108
107
authzTTL , err := time .ParseDuration (options .AuthConfig .AuthorizationCacheTTL )
109
108
if err != nil {
110
- return nil , nil , err
109
+ return nil , err
111
110
}
112
111
server .Authorization = componentconfig.KubeletAuthorization {
113
112
Mode : componentconfig .KubeletAuthorizationModeWebhook ,
@@ -121,13 +120,13 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
121
120
// TODO: this should be done in config validation (along with the above) so we can provide
122
121
// proper errors
123
122
if err := cmdflags .Resolve (options .KubeletArguments , server .AddFlags ); len (err ) > 0 {
124
- return nil , nil , kerrors .NewAggregate (err )
123
+ return nil , kerrors .NewAggregate (err )
125
124
}
126
125
127
126
// terminate early if feature gate is incorrect on the node
128
127
if len (server .FeatureGates ) > 0 {
129
128
if err := utilfeature .DefaultFeatureGate .Set (server .FeatureGates ); err != nil {
130
- return nil , nil , err
129
+ return nil , err
131
130
}
132
131
}
133
132
if utilfeature .DefaultFeatureGate .Enabled (features .RotateKubeletServerCertificate ) {
@@ -138,11 +137,6 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
138
137
}
139
138
}
140
139
141
- proxyconfig , err := buildKubeProxyConfig (options )
142
- if err != nil {
143
- return nil , nil , err
144
- }
145
-
146
140
if network .IsOpenShiftNetworkPlugin (options .NetworkConfig .NetworkPluginName ) {
147
141
// SDN plugin pod setup/teardown is implemented as a CNI plugin
148
142
server .NetworkPluginName = kubeletcni .CNIPluginName
@@ -152,72 +146,7 @@ func Build(options configapi.NodeConfig) (*kubeletoptions.KubeletServer, *compon
152
146
server .HairpinMode = componentconfig .HairpinNone
153
147
}
154
148
155
- return server , proxyconfig , nil
156
- }
157
-
158
- func buildKubeProxyConfig (options configapi.NodeConfig ) (* componentconfig.KubeProxyConfiguration , error ) {
159
- proxyOptions , err := kubeproxyoptions .NewOptions ()
160
- if err != nil {
161
- return nil , err
162
- }
163
- // get default config
164
- proxyconfig := proxyOptions .GetConfig ()
165
-
166
- // BindAddress - Override default bind address from our config
167
- addr := options .ServingInfo .BindAddress
168
- host , _ , err := net .SplitHostPort (addr )
169
- if err != nil {
170
- return nil , fmt .Errorf ("The provided value to bind to must be an ip:port %q" , addr )
171
- }
172
- ip := net .ParseIP (host )
173
- if ip == nil {
174
- return nil , fmt .Errorf ("The provided value to bind to must be an ip:port: %q" , addr )
175
- }
176
- proxyconfig .BindAddress = ip .String ()
177
- // MetricsBindAddress - disable
178
- proxyconfig .MetricsBindAddress = ""
179
-
180
- // OOMScoreAdj, ResourceContainer - clear, we don't run in a container
181
- oomScoreAdj := int32 (0 )
182
- proxyconfig .OOMScoreAdj = & oomScoreAdj
183
- proxyconfig .ResourceContainer = ""
184
-
185
- // use the same client as the node
186
- proxyconfig .ClientConnection .KubeConfigFile = options .MasterKubeConfig
187
-
188
- // ProxyMode, set to iptables
189
- proxyconfig .Mode = "iptables"
190
-
191
- // IptablesSyncPeriod, set to our config value
192
- syncPeriod , err := time .ParseDuration (options .IPTablesSyncPeriod )
193
- if err != nil {
194
- return nil , fmt .Errorf ("Cannot parse the provided ip-tables sync period (%s) : %v" , options .IPTablesSyncPeriod , err )
195
- }
196
- proxyconfig .IPTables .SyncPeriod = metav1.Duration {
197
- Duration : syncPeriod ,
198
- }
199
- masqueradeBit := int32 (0 )
200
- proxyconfig .IPTables .MasqueradeBit = & masqueradeBit
201
-
202
- // PortRange, use default
203
- // HostnameOverride, use default
204
- // ConfigSyncPeriod, use default
205
- // MasqueradeAll, use default
206
- // CleanupAndExit, use default
207
- // KubeAPIQPS, use default, doesn't apply until we build a separate client
208
- // KubeAPIBurst, use default, doesn't apply until we build a separate client
209
- // UDPIdleTimeout, use default
210
-
211
- // Resolve cmd flags to add any user overrides
212
- if err := cmdflags .Resolve (options .ProxyArguments , proxyOptions .AddFlags ); len (err ) > 0 {
213
- return nil , kerrors .NewAggregate (err )
214
- }
215
-
216
- if err := proxyOptions .Complete (); err != nil {
217
- return nil , err
218
- }
219
-
220
- return proxyconfig , nil
149
+ return server , nil
221
150
}
222
151
223
152
func ToFlags (config * kubeletoptions.KubeletServer ) []string {
0 commit comments