Skip to content

Commit 50dccea

Browse files
committed
cluster: support setting externalTrafficPolicy for svc
Allow setting externalTrafficPolicy for the api service. useful when using NodePort and LoadBalancer types. Signed-off-by: Seena Fallah <seenafallah@gmail.com>
1 parent 6cec878 commit 50dccea

12 files changed

+86
-280
lines changed

api/k0smotron.io/v1beta1/k0smotroncluster_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package v1beta1
1919
import (
2020
"crypto/md5"
2121
"fmt"
22+
"strings"
23+
2224
"github.com/k0sproject/version"
2325
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
24-
"strings"
2526

2627
v1 "k8s.io/api/core/v1"
2728
"k8s.io/apimachinery/pkg/api/resource"
@@ -246,6 +247,10 @@ type ServiceSpec struct {
246247
// LoadBalancerClass defines the load balancer class to be used for the service. Used only when service type is LoadBalancer.
247248
//+kubebuilder:validation:Optional
248249
LoadBalancerClass *string `json:"loadBalancerClass,omitempty"`
250+
// ExternalTrafficPolicy defines the external traffic policy for the service. Used only when service type is NodePort or LoadBalancer.
251+
//+kubebuilder:validation:Optional
252+
//+kubebuilder:validation:Enum=Cluster;Local
253+
ExternalTrafficPolicy v1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"`
249254
}
250255

251256
//+kubebuilder:object:root=true

config/clusterapi/controlplane/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,6 +4488,14 @@ spec:
44884488
APIPort defines the kubernetes API port. If empty k0smotron
44894489
will pick it automatically.
44904490
type: integer
4491+
externalTrafficPolicy:
4492+
description: ExternalTrafficPolicy defines the external traffic
4493+
policy for the service. Used only when service type is NodePort
4494+
or LoadBalancer.
4495+
enum:
4496+
- Cluster
4497+
- Local
4498+
type: string
44914499
konnectivityPort:
44924500
default: 30132
44934501
description: |-

config/clusterapi/controlplane/bases/controlplane.cluster.x-k8s.io_k0smotroncontrolplanetemplates.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,14 @@ spec:
45324532
APIPort defines the kubernetes API port. If empty k0smotron
45334533
will pick it automatically.
45344534
type: integer
4535+
externalTrafficPolicy:
4536+
description: ExternalTrafficPolicy defines the external
4537+
traffic policy for the service. Used only when service
4538+
type is NodePort or LoadBalancer.
4539+
enum:
4540+
- Cluster
4541+
- Local
4542+
type: string
45354543
konnectivityPort:
45364544
default: 30132
45374545
description: |-

config/clusterapi/k0smotron.io/bases/k0smotron.io_clusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,6 +4450,14 @@ spec:
44504450
APIPort defines the kubernetes API port. If empty k0smotron
44514451
will pick it automatically.
44524452
type: integer
4453+
externalTrafficPolicy:
4454+
description: ExternalTrafficPolicy defines the external traffic
4455+
policy for the service. Used only when service type is NodePort
4456+
or LoadBalancer.
4457+
enum:
4458+
- Cluster
4459+
- Local
4460+
type: string
44534461
konnectivityPort:
44544462
default: 30132
44554463
description: |-

config/crd/bases/controlplane/controlplane.cluster.x-k8s.io_k0smotroncontrolplanes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,6 +4488,14 @@ spec:
44884488
APIPort defines the kubernetes API port. If empty k0smotron
44894489
will pick it automatically.
44904490
type: integer
4491+
externalTrafficPolicy:
4492+
description: ExternalTrafficPolicy defines the external traffic
4493+
policy for the service. Used only when service type is NodePort
4494+
or LoadBalancer.
4495+
enum:
4496+
- Cluster
4497+
- Local
4498+
type: string
44914499
konnectivityPort:
44924500
default: 30132
44934501
description: |-

config/crd/bases/controlplane/controlplane.cluster.x-k8s.io_k0smotroncontrolplanetemplates.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,14 @@ spec:
45324532
APIPort defines the kubernetes API port. If empty k0smotron
45334533
will pick it automatically.
45344534
type: integer
4535+
externalTrafficPolicy:
4536+
description: ExternalTrafficPolicy defines the external
4537+
traffic policy for the service. Used only when service
4538+
type is NodePort or LoadBalancer.
4539+
enum:
4540+
- Cluster
4541+
- Local
4542+
type: string
45354543
konnectivityPort:
45364544
default: 30132
45374545
description: |-

config/crd/bases/k0smotron.io/k0smotron.io_clusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,6 +4450,14 @@ spec:
44504450
APIPort defines the kubernetes API port. If empty k0smotron
44514451
will pick it automatically.
44524452
type: integer
4453+
externalTrafficPolicy:
4454+
description: ExternalTrafficPolicy defines the external traffic
4455+
policy for the service. Used only when service type is NodePort
4456+
or LoadBalancer.
4457+
enum:
4458+
- Cluster
4459+
- Local
4460+
type: string
44534461
konnectivityPort:
44544462
default: 30132
44554463
description: |-

docs/resource-reference/controlplane.cluster.x-k8s.io-v1beta1.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11020,6 +11020,15 @@ will pick it automatically.<br/>
1102011020
<i>Default</i>: 30443<br/>
1102111021
</td>
1102211022
<td>false</td>
11023+
</tr><tr>
11024+
<td><b>externalTrafficPolicy</b></td>
11025+
<td>enum</td>
11026+
<td>
11027+
ExternalTrafficPolicy defines the external traffic policy for the service. Used only when service type is NodePort or LoadBalancer.<br/>
11028+
<br/>
11029+
<i>Enum</i>: Cluster, Local<br/>
11030+
</td>
11031+
<td>false</td>
1102311032
</tr><tr>
1102411033
<td><b>konnectivityPort</b></td>
1102511034
<td>integer</td>
@@ -20777,6 +20786,15 @@ will pick it automatically.<br/>
2077720786
<i>Default</i>: 30443<br/>
2077820787
</td>
2077920788
<td>false</td>
20789+
</tr><tr>
20790+
<td><b>externalTrafficPolicy</b></td>
20791+
<td>enum</td>
20792+
<td>
20793+
ExternalTrafficPolicy defines the external traffic policy for the service. Used only when service type is NodePort or LoadBalancer.<br/>
20794+
<br/>
20795+
<i>Enum</i>: Cluster, Local<br/>
20796+
</td>
20797+
<td>false</td>
2078020798
</tr><tr>
2078120799
<td><b>konnectivityPort</b></td>
2078220800
<td>integer</td>

docs/resource-reference/k0smotron.io-v1beta1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9177,6 +9177,15 @@ will pick it automatically.<br/>
91779177
<i>Default</i>: 30443<br/>
91789178
</td>
91799179
<td>false</td>
9180+
</tr><tr>
9181+
<td><b>externalTrafficPolicy</b></td>
9182+
<td>enum</td>
9183+
<td>
9184+
ExternalTrafficPolicy defines the external traffic policy for the service. Used only when service type is NodePort or LoadBalancer.<br/>
9185+
<br/>
9186+
<i>Enum</i>: Cluster, Local<br/>
9187+
</td>
9188+
<td>false</td>
91809189
</tr><tr>
91819190
<td><b>konnectivityPort</b></td>
91829191
<td>integer</td>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/coreos/butane v0.24.0
88
github.com/go-logr/logr v1.4.2
99
github.com/gobuffalo/flect v1.0.3
10+
github.com/google/go-cmp v0.7.0
1011
github.com/google/uuid v1.6.0
1112
github.com/imdario/mergo v0.3.16
1213
github.com/k0sproject/k0s v1.27.2-0.20230504131248-94378e521a29
@@ -118,7 +119,6 @@ require (
118119
github.com/google/cel-go v0.22.0 // indirect
119120
github.com/google/certificate-transparency-go v1.1.4 // indirect
120121
github.com/google/gnostic-models v0.6.8 // indirect
121-
github.com/google/go-cmp v0.7.0 // indirect
122122
github.com/google/go-github/v53 v53.2.0 // indirect
123123
github.com/google/go-querystring v1.1.0 // indirect
124124
github.com/google/gofuzz v1.2.0 // indirect

0 commit comments

Comments
 (0)