diff --git a/pkg/ingress/config/ingress_config.go b/pkg/ingress/config/ingress_config.go index ad55182ca..0a749f074 100644 --- a/pkg/ingress/config/ingress_config.go +++ b/pkg/ingress/config/ingress_config.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" "fmt" + "sort" "strings" "sync" @@ -673,6 +674,18 @@ func (m *IngressConfig) convertDestinationRule(configs []common.WrapperConfig) [ out := make([]config.Config, 0, len(destinationRules)) for _, dr := range destinationRules { + sort.SliceStable(dr.DestinationRule.TrafficPolicy.PortLevelSettings, func(i, j int) bool { + portI := dr.DestinationRule.TrafficPolicy.PortLevelSettings[i].Port + portJ := dr.DestinationRule.TrafficPolicy.PortLevelSettings[j].Port + if portI == nil && portJ == nil { + return true + } else if portI == nil { + return true + } else if portJ == nil { + return false + } + return portI.Number < portJ.Number + }) drName := util.CreateDestinationRuleName(m.clusterId, dr.ServiceKey.Namespace, dr.ServiceKey.Name) out = append(out, config.Config{ Meta: config.Meta{ diff --git a/pkg/ingress/kube/annotations/upstreamtls.go b/pkg/ingress/kube/annotations/upstreamtls.go index d9d2e4300..d645d6abc 100644 --- a/pkg/ingress/kube/annotations/upstreamtls.go +++ b/pkg/ingress/kube/annotations/upstreamtls.go @@ -65,7 +65,12 @@ func (u upstreamTLS) Parse(annotations Annotations, config *Ingress, _ *GlobalCo } defer func() { - config.UpstreamTLS = upstreamTLSConfig + if upstreamTLSConfig.BackendProtocol == defaultBackendProtocol { + // no need destination rule when use HTTP protocol + config.UpstreamTLS = nil + } else { + config.UpstreamTLS = upstreamTLSConfig + } }() if proto, err := annotations.ParseStringASAP(backendProtocol); err == nil { diff --git a/pkg/ingress/kube/annotations/upstreamtls_test.go b/pkg/ingress/kube/annotations/upstreamtls_test.go index c48247952..02e69ca22 100644 --- a/pkg/ingress/kube/annotations/upstreamtls_test.go +++ b/pkg/ingress/kube/annotations/upstreamtls_test.go @@ -33,6 +33,12 @@ func TestUpstreamTLSParse(t *testing.T) { input: Annotations{}, expect: nil, }, + { + input: Annotations{ + buildNginxAnnotationKey(backendProtocol): "HTTP", + }, + expect: nil, + }, { input: Annotations{ buildNginxAnnotationKey(proxySSLSecret): "",