Skip to content

Commit 09eefc5

Browse files
Merge pull request #5055 from juanluisvaladas/kubeproxy-extraargs
Add extraArgs to kube-proxy
2 parents 9ea9b88 + 0220baa commit 09eefc5

File tree

6 files changed

+64
-18
lines changed

6 files changed

+64
-18
lines changed

docs/configuration.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ spec:
118118
| `onlyBindToAddress` | The API server binds too all interfaces by default. With this option set to `true`, the API server will only listen on the IP address configured by the `address` option (first non-local address by default). This can be necessary with multi-homed control plane nodes. |
119119
| `externalAddress` | The loadbalancer address (for k0s controllers running behind a loadbalancer). Configures all cluster components to connect to this address and also configures this address for use when joining new nodes to the cluster. |
120120
| `sans` | List of additional addresses to push to API servers serving the certificate. |
121-
| `extraArgs` | Map of key-values (strings) for any extra arguments to pass down to Kubernetes api-server process. |
121+
| `extraArgs` | Map of key-values (strings) for any extra arguments to pass down to Kubernetes api-server process. Any behavior triggered by these parameters is outside k0s support. |
122122
| `port`¹ | Custom port for kube-api server to listen on (default: 6443) |
123123
| `k0sApiPort`¹ | Custom port for k0s-api server to listen on (default: 9443) |
124124
@@ -130,7 +130,7 @@ spec:
130130
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
131131
| `type` | Type of the data store (valid values:`etcd` or `kine`). **Note**: Type `etcd` will cause k0s to create and manage an elastic etcd cluster within the controller nodes. |
132132
| `etcd.peerAddress` | Node address used for etcd cluster peering. |
133-
| `etcd.extraArgs` | Map of key-values (strings) for any extra arguments to pass down to etcd process. |
133+
| `etcd.extraArgs` | Map of key-values (strings) for any extra arguments to pass down to etcd process. Any behavior triggered by these parameters is outside k0s support. |
134134
| `kine.dataSource` | [kine](https://github.com/k3s-io/kine) datasource URL. |
135135
| `etcd.externalCluster` | Configuration when etcd is externally managed, i.e. running on dedicated nodes. See [`spec.storage.etcd.externalCluster`](#specstorageetcdexternalcluster) |
136136
@@ -231,14 +231,16 @@ CALICO_IPV6POOL_CIDR: "{{ spec.network.dualStack.IPv6podCIDR }}"
231231
232232
#### `spec.network.kubeProxy`
233233
234-
| Element | Description |
235-
|---------------------|---------------------------------------------------------------------------------------------------------------|
236-
| `disabled` | Disable kube-proxy altogether (default: `false`). |
237-
| `mode` | Kube proxy operating mode, supported modes `iptables`, `ipvs`, `nftables`, `userspace` (default: `iptables`) |
238-
| `iptables` | Kube proxy iptables settings |
239-
| `ipvs` | Kube proxy ipvs settings |
240-
| `nftables` | Kube proxy nftables settings |
241-
| `nodePortAddresses` | Kube proxy [nodePortAddresses](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/) |
234+
| Element | Description |
235+
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
236+
| `disabled` | Disable kube-proxy altogether (default: `false`). |
237+
| `mode` | Kube proxy operating mode, supported modes `iptables`, `ipvs`, `nftables`, `userspace` (default: `iptables`) |
238+
| `iptables` | Kube proxy iptables settings |
239+
| `ipvs` | Kube proxy ipvs settings |
240+
| `nftables` | Kube proxy nftables settings |
241+
| `nodePortAddresses` | Kube proxy [nodePortAddresses](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/) |
242+
| `nodePortAddresses` | Kube proxy [nodePortAddresses](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/) |
243+
| `extraArgs` . | Map of key-values (strings) for any extra arguments to pass down to kube-proxy process. Any behavior triggered by these parameters is outside k0s support. |
242244
243245
Default kube-proxy iptables settings:
244246
@@ -349,13 +351,13 @@ Configuration options required for using VRRP to configure VIPs in control plane
349351
350352
| Element | Description |
351353
| ----------- | ----------------------------------------------------------------------------------------------------------------------- |
352-
| `extraArgs` | Map of key-values (strings) for any extra arguments you want to pass down to the Kubernetes controller manager process. |
354+
| `extraArgs` | Map of key-values (strings) for any extra arguments you want to pass down to the Kubernetes controller manager process. Any behavior triggered by these parameters is outside k0s support. |
353355
354356
### `spec.scheduler`
355357
356358
| Element | Description |
357359
| ----------- | ---------------------------------------------------------------------------------------------------------- |
358-
| `extraArgs` | Map of key-values (strings) for any extra arguments you want to pass down to Kubernetes scheduler process. |
360+
| `extraArgs` | Map of key-values (strings) for any extra arguments you want to pass down to Kubernetes scheduler process. Any behavior triggered by these parameters is outside k0s support. |
359361
360362
### `spec.workerProfiles`
361363

inttest/extraargs/extraargs_test.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ func (s *ExtraArgsSuite) TestK0sGetsUp() {
4646
s.T().Log("waiting to see kube-router pods ready")
4747
s.NoError(common.WaitForKubeRouterReady(s.Context(), kc), "kube-router did not start")
4848

49-
ssh, err := s.SSH(s.Context(), s.ControllerNode(0))
50-
defer ssh.Disconnect()
49+
sshCtrl, err := s.SSH(s.Context(), s.ControllerNode(0))
50+
defer sshCtrl.Disconnect()
5151
s.NoError(err)
5252

53-
s.checkFlag(ssh, "/var/lib/k0s/bin/kube-apiserver", "--disable-admission-plugins=PodSecurity")
54-
s.checkFlag(ssh, "/var/lib/k0s/bin/etcd", "--logger=zap")
53+
s.checkFlag(sshCtrl, "/var/lib/k0s/bin/kube-apiserver", "--disable-admission-plugins=PodSecurity")
54+
s.checkFlag(sshCtrl, "/var/lib/k0s/bin/etcd", "--logger=zap")
55+
56+
sshWorker, err := s.SSH(s.Context(), s.WorkerNode(0))
57+
defer sshWorker.Disconnect()
58+
s.NoError(err)
59+
60+
s.checkFlag(sshWorker, "/usr/local/bin/kube-proxy", "--config-sync-period=12m0s")
5561

5662
}
5763
func (s *ExtraArgsSuite) checkFlag(ssh *common.SSHConnection, processName string, flag string) {
@@ -88,4 +94,8 @@ spec:
8894
etcd:
8995
extraArgs:
9096
logger: zap
97+
network:
98+
kubeProxy:
99+
extraArgs:
100+
config-sync-period: 12m0s
91101
`

pkg/apis/k0s/v1beta1/kubeproxy.go

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ type KubeProxy struct {
4242
IPVS KubeProxyIPVSConfiguration `json:"ipvs,omitempty"`
4343
NFTables KubeProxyNFTablesConfiguration `json:"nftables,omitempty"`
4444
NodePortAddresses []string `json:"nodePortAddresses,omitempty"`
45+
46+
// Map of key-values (strings) for any extra arguments to pass down to kube-proxy process
47+
// Any behavior triggered by these parameters is outside k0s support.
48+
ExtraArgs map[string]string `json:"extraArgs,omitempty"`
4549
}
4650

4751
// KubeProxyIPTablesConfiguration contains iptables-related kube-proxy configuration

pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/component/controller/kubeproxy.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"reflect"
2727

2828
"github.com/k0sproject/k0s/internal/pkg/dir"
29+
"github.com/k0sproject/k0s/internal/pkg/stringmap"
2930
"github.com/k0sproject/k0s/internal/pkg/templatewriter"
3031
"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
3132
"github.com/k0sproject/k0s/pkg/component/manager"
@@ -132,6 +133,17 @@ func (k *KubeProxy) getConfig(clusterConfig *v1beta1.ClusterConfig) (proxyConfig
132133
k.log.Warnf("Unsupported node-local load balancer type (%q), using %q as control plane endpoint", controlPlaneEndpoint)
133134
}
134135
}
136+
args := stringmap.StringMap{
137+
"config": "/var/lib/kube-proxy/config.conf",
138+
"hostname-override": "$(NODE_NAME)",
139+
}
140+
141+
for name, value := range clusterConfig.Spec.Network.KubeProxy.ExtraArgs {
142+
if _, ok := args[name]; ok {
143+
logrus.Warnf("overriding kube-proxy flag with user provided value: %s", name)
144+
}
145+
args[name] = value
146+
}
135147

136148
cfg := proxyConfig{
137149
ClusterCIDR: clusterConfig.Spec.Network.BuildPodCIDR(),
@@ -142,6 +154,7 @@ func (k *KubeProxy) getConfig(clusterConfig *v1beta1.ClusterConfig) (proxyConfig
142154
Mode: clusterConfig.Spec.Network.KubeProxy.Mode,
143155
MetricsBindAddress: clusterConfig.Spec.Network.KubeProxy.MetricsBindAddress,
144156
FeatureGates: clusterConfig.Spec.FeatureGates.AsMap("kube-proxy"),
157+
Args: args.ToDashedArgs(),
145158
}
146159

147160
nodePortAddresses, err := json.Marshal(clusterConfig.Spec.Network.KubeProxy.NodePortAddresses)
@@ -184,6 +197,7 @@ type proxyConfig struct {
184197
NFTables string
185198
FeatureGates map[string]bool
186199
NodePortAddresses string
200+
Args []string
187201
}
188202

189203
const proxyTemplate = `
@@ -335,8 +349,10 @@ spec:
335349
imagePullPolicy: {{ .PullPolicy }}
336350
command:
337351
- /usr/local/bin/kube-proxy
338-
- --config=/var/lib/kube-proxy/config.conf
339-
- --hostname-override=$(NODE_NAME)
352+
args:
353+
{{ range .Args}}
354+
- {{ . }}
355+
{{ end }}
340356
securityContext:
341357
privileged: true
342358
volumeMounts:

static/_crds/k0s/k0s.k0sproject.io_clusterconfigs.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ spec:
654654
properties:
655655
disabled:
656656
type: boolean
657+
extraArgs:
658+
additionalProperties:
659+
type: string
660+
description: |-
661+
Map of key-values (strings) for any extra arguments to pass down to kube-proxy process
662+
Any behavior triggered by these parameters is outside k0s support.
663+
type: object
657664
iptables:
658665
description: |-
659666
KubeProxyIPTablesConfiguration contains iptables-related kube-proxy configuration

0 commit comments

Comments
 (0)