Skip to content

Commit

Permalink
Merge pull request #407 from Lyt99/bugfix/backend-ip-version
Browse files Browse the repository at this point in the history
fix backend ip version check for clb
  • Loading branch information
k8s-ci-robot authored Apr 25, 2024
2 parents 5b8e9e1 + ddfd17a commit 894910e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pkg/controller/service/reconcile/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,26 @@ func (e *EndpointWithENI) setTrafficPolicy(reqCtx *svcCtx.RequestContext) {
}

func (e *EndpointWithENI) setAddressIpVersion(reqCtx *svcCtx.RequestContext) {
e.AddressIPVersion = model.IPv4
if reqCtx.Anno.Get(annotation.BackendIPVersion) != string(model.IPv6) {
return
}
// Only EndpointSlice support dual stack.
// Enable IPv6DualStack and EndpointSlice feature gates if you want to use ipv6 backends
if utilfeature.DefaultMutableFeatureGate.Enabled(ctrlCfg.IPv6DualStack) &&
utilfeature.DefaultMutableFeatureGate.Enabled(ctrlCfg.EndpointSlice) &&
strings.EqualFold(reqCtx.Anno.Get(annotation.IPVersion), string(model.DualStack)) &&
reqCtx.Anno.Get(annotation.BackendIPVersion) == string(model.IPv6) {
e.AddressIPVersion = model.IPv6
reqCtx.Log.Info("backend address ip version is ipv6")
if !utilfeature.DefaultMutableFeatureGate.Enabled(ctrlCfg.IPv6DualStack) ||
!utilfeature.DefaultMutableFeatureGate.Enabled(ctrlCfg.EndpointSlice) {
return
}
e.AddressIPVersion = model.IPv4

c := model.IPv6
if helper.NeedNLB(reqCtx.Service) {
c = model.DualStack
}
if strings.EqualFold(reqCtx.Anno.Get(annotation.IPVersion), string(c)) {
reqCtx.Log.Info("backend address ip version is ipv6")
e.AddressIPVersion = model.IPv6
}
return
}

func GetNodes(reqCtx *svcCtx.RequestContext, kubeClient client.Client) ([]v1.Node, error) {
Expand Down

0 comments on commit 894910e

Please sign in to comment.