Skip to content

Commit 7a6fec3

Browse files
committed
kube-proxy: internal config: add Windows section
Introduce Windows section for internal configuration of kube-proxy adhering to the v1alpha2 version specifications as detailed in https://kep.k8s.io/784. This also introduces WindowsRunAsService to v1alpha1 configuration. Signed-off-by: Daman Arora <[email protected]>
1 parent 46aa895 commit 7a6fec3

File tree

9 files changed

+95
-28
lines changed

9 files changed

+95
-28
lines changed

cmd/kube-proxy/app/init_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func initForOS(windowsService bool) error {
3737
}
3838

3939
func (o *Options) addOSFlags(fs *pflag.FlagSet) {
40-
fs.BoolVar(&o.WindowsService, "windows-service", o.WindowsService, "Enable Windows Service Control Manager API integration")
40+
fs.BoolVar(&o.config.Windows.RunAsService, "windows-service", o.config.Windows.RunAsService, "Enable Windows Service Control Manager API integration")
4141
fs.StringVar(&o.config.Winkernel.SourceVip, "source-vip", o.config.Winkernel.SourceVip, "The IP address of the source VIP for non-DSR.")
4242
fs.StringVar(&o.config.Winkernel.NetworkName, "network-name", o.config.Winkernel.NetworkName, "The name of the cluster network.")
4343
fs.BoolVar(&o.config.Winkernel.EnableDSR, "enable-dsr", o.config.Winkernel.EnableDSR, "If true make kube-proxy apply DSR policies for service VIP")

cmd/kube-proxy/app/options.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ type Options struct {
5454
CleanupAndExit bool
5555
// InitAndExit, when true, makes the proxy server makes configurations that need privileged access, then exit.
5656
InitAndExit bool
57-
// WindowsService should be set to true if kube-proxy is running as a service on Windows.
58-
// Its corresponding flag only gets registered in Windows builds
59-
WindowsService bool
6057
// config is the proxy server's configuration object.
6158
config *kubeproxyconfig.KubeProxyConfiguration
6259
// watcher is used to watch on the update change of ConfigFile

cmd/kube-proxy/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ with the apiserver API to configure the proxy.`,
104104
RunE: func(cmd *cobra.Command, args []string) error {
105105
verflag.PrintAndExitIfRequested()
106106

107-
if err := initForOS(opts.WindowsService); err != nil {
107+
if err := initForOS(opts.config.Windows.RunAsService); err != nil {
108108
return fmt.Errorf("failed os init: %w", err)
109109
}
110110

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/proxy/apis/config/types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ import (
2222
logsapi "k8s.io/component-base/logs/api/v1"
2323
)
2424

25+
// KubeProxyWindowsConfiguration contains Windows platform related configuration details for the
26+
// Kubernetes proxy server that aren't specific to a particular backend
27+
type KubeProxyWindowsConfiguration struct {
28+
// runAsService, if true, enables Windows service control manager API integration.
29+
RunAsService bool
30+
}
31+
2532
// KubeProxyIPTablesConfiguration contains iptables-related configuration
2633
// details for the Kubernetes proxy server.
2734
type KubeProxyIPTablesConfiguration struct {
@@ -165,6 +172,9 @@ type DetectLocalConfiguration struct {
165172
type KubeProxyConfiguration struct {
166173
metav1.TypeMeta
167174

175+
// windows contains Windows-related configuration options.
176+
Windows KubeProxyWindowsConfiguration
177+
168178
// featureGates is a map of feature names to bools that enable or disable alpha/experimental features.
169179
FeatureGates map[string]bool
170180

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/conversion"
21+
"k8s.io/kube-proxy/config/v1alpha1"
22+
"k8s.io/kubernetes/pkg/proxy/apis/config"
23+
)
24+
25+
// Convert_config_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration is defined here, because public conversion is not auto-generated due to existing warnings.
26+
func Convert_config_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in *config.KubeProxyConfiguration, out *v1alpha1.KubeProxyConfiguration, scope conversion.Scope) error {
27+
if err := autoConvert_config_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in, out, scope); err != nil {
28+
return err
29+
}
30+
out.WindowsRunAsService = in.Windows.RunAsService
31+
return nil
32+
}
33+
34+
// Convert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguration is defined here, because public conversion is not auto-generated due to existing warnings.
35+
func Convert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguration(in *v1alpha1.KubeProxyConfiguration, out *config.KubeProxyConfiguration, scope conversion.Scope) error {
36+
if err := autoConvert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguration(in, out, scope); err != nil {
37+
return err
38+
}
39+
out.Windows.RunAsService = in.WindowsRunAsService
40+
return nil
41+
}

pkg/proxy/apis/config/v1alpha1/zz_generated.conversion.go

Lines changed: 15 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/proxy/apis/config/zz_generated.deepcopy.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ type KubeProxyConfiguration struct {
243243

244244
// portRange was previously used to configure the userspace proxy, but is now unused.
245245
PortRange string `json:"portRange"`
246+
247+
// windowsRunAsService, if true, enables Windows service control manager API integration.
248+
WindowsRunAsService bool `json:"windowsRunAsService,omitempty"`
246249
}
247250

248251
// ProxyMode represents modes used by the Kubernetes proxy server.

0 commit comments

Comments
 (0)