mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 12:47:28 +08:00
feat: custom listening port for gateway pod in helm (#829)
This commit is contained in:
@@ -195,6 +195,8 @@ spec:
|
|||||||
- "serve"
|
- "serve"
|
||||||
- --gatewaySelectorKey=higress
|
- --gatewaySelectorKey=higress
|
||||||
- --gatewaySelectorValue={{ .Release.Namespace }}-{{ include "gateway.name" . }}
|
- --gatewaySelectorValue={{ .Release.Namespace }}-{{ include "gateway.name" . }}
|
||||||
|
- --gatewayHttpPort={{ .Values.gateway.httpPort }}
|
||||||
|
- --gatewayHttpsPort={{ .Values.gateway.httpsPort }}
|
||||||
{{- if not .Values.global.enableStatus }}
|
{{- if not .Values.global.enableStatus }}
|
||||||
- --enableStatus={{ .Values.global.enableStatus }}
|
- --enableStatus={{ .Values.global.enableStatus }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ spec:
|
|||||||
protocol: TCP
|
protocol: TCP
|
||||||
name: http-envoy-prom
|
name: http-envoy-prom
|
||||||
{{- if or .Values.global.local .Values.global.kind }}
|
{{- if or .Values.global.local .Values.global.kind }}
|
||||||
- containerPort: 80
|
- containerPort: {{ .Values.gateway.httpPort }}
|
||||||
hostPort: 80
|
hostPort: {{ .Values.gateway.httpPort }}
|
||||||
name: http
|
name: http
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
- containerPort: 443
|
- containerPort: {{ .Values.gateway.httpsPort }}
|
||||||
hostPort: 443
|
hostPort: {{ .Values.gateway.httpsPort }}
|
||||||
name: https
|
name: https
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -417,7 +417,8 @@ gateway:
|
|||||||
|
|
||||||
# Pod environment variables
|
# Pod environment variables
|
||||||
env: {}
|
env: {}
|
||||||
|
httpPort: 80
|
||||||
|
httpsPort: 443
|
||||||
hostNetwork: false
|
hostNetwork: false
|
||||||
|
|
||||||
# Labels to apply to all resources
|
# Labels to apply to all resources
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ type ServerArgs struct {
|
|||||||
KeepStaleWhenEmpty bool
|
KeepStaleWhenEmpty bool
|
||||||
GatewaySelectorKey string
|
GatewaySelectorKey string
|
||||||
GatewaySelectorValue string
|
GatewaySelectorValue string
|
||||||
|
GatewayHttpPort uint32
|
||||||
|
GatewayHttpsPort uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type readinessProbe func() (bool, error)
|
type readinessProbe func() (bool, error)
|
||||||
@@ -220,6 +222,8 @@ func (s *Server) initConfigController() error {
|
|||||||
SystemNamespace: ns,
|
SystemNamespace: ns,
|
||||||
GatewaySelectorKey: s.GatewaySelectorKey,
|
GatewaySelectorKey: s.GatewaySelectorKey,
|
||||||
GatewaySelectorValue: s.GatewaySelectorValue,
|
GatewaySelectorValue: s.GatewaySelectorValue,
|
||||||
|
GatewayHttpPort: s.GatewayHttpPort,
|
||||||
|
GatewayHttpsPort: s.GatewayHttpsPort,
|
||||||
}
|
}
|
||||||
if options.ClusterId == "Kubernetes" {
|
if options.ClusterId == "Kubernetes" {
|
||||||
options.ClusterId = ""
|
options.ClusterId = ""
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ func getServerCommand() *cobra.Command {
|
|||||||
|
|
||||||
serveCmd.PersistentFlags().IntVar(&serverArgs.RegistryOptions.KubeOptions.KubernetesAPIBurst, "kubernetesApiBurst", 160,
|
serveCmd.PersistentFlags().IntVar(&serverArgs.RegistryOptions.KubeOptions.KubernetesAPIBurst, "kubernetesApiBurst", 160,
|
||||||
"Maximum burst for throttle when communicating with the kubernetes API")
|
"Maximum burst for throttle when communicating with the kubernetes API")
|
||||||
|
serveCmd.PersistentFlags().Uint32Var(&serverArgs.GatewayHttpPort, "gatewayHttpPort", 80,
|
||||||
|
"Http listening port of gateway pod")
|
||||||
|
serveCmd.PersistentFlags().Uint32Var(&serverArgs.GatewayHttpsPort, "gatewayHttpsPort", 443,
|
||||||
|
"Https listening port of gateway pod")
|
||||||
|
|
||||||
loggingOptions.AttachCobraFlags(serveCmd)
|
loggingOptions.AttachCobraFlags(serveCmd)
|
||||||
serverArgs.GrpcKeepAliveOptions.AttachCobraFlags(serveCmd)
|
serverArgs.GrpcKeepAliveOptions.AttachCobraFlags(serveCmd)
|
||||||
|
|||||||
@@ -114,11 +114,15 @@ func TestConvertGatewaysForIngress(t *testing.T) {
|
|||||||
Enable: true,
|
Enable: true,
|
||||||
ClusterId: "ingress-v1beta1",
|
ClusterId: "ingress-v1beta1",
|
||||||
RawClusterId: "ingress-v1beta1__",
|
RawClusterId: "ingress-v1beta1__",
|
||||||
|
GatewayHttpPort: 80,
|
||||||
|
GatewayHttpsPort: 443,
|
||||||
}
|
}
|
||||||
v1Options := common.Options{
|
v1Options := common.Options{
|
||||||
Enable: true,
|
Enable: true,
|
||||||
ClusterId: "ingress-v1",
|
ClusterId: "ingress-v1",
|
||||||
RawClusterId: "ingress-v1__",
|
RawClusterId: "ingress-v1__",
|
||||||
|
GatewayHttpPort: 80,
|
||||||
|
GatewayHttpsPort: 443,
|
||||||
}
|
}
|
||||||
ingressV1Beta1Controller := controllerv1beta1.NewController(fake, fake, v1Beta1Options, nil)
|
ingressV1Beta1Controller := controllerv1beta1.NewController(fake, fake, v1Beta1Options, nil)
|
||||||
ingressV1Controller := controllerv1.NewController(fake, fake, v1Options, nil)
|
ingressV1Controller := controllerv1.NewController(fake, fake, v1Options, nil)
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ type Options struct {
|
|||||||
SystemNamespace string
|
SystemNamespace string
|
||||||
GatewaySelectorKey string
|
GatewaySelectorKey string
|
||||||
GatewaySelectorValue string
|
GatewaySelectorValue string
|
||||||
|
GatewayHttpPort uint32
|
||||||
|
GatewayHttpsPort uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type BasicAuthRules struct {
|
type BasicAuthRules struct {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -357,6 +358,7 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp
|
|||||||
return fmt.Errorf("invalid ingress rule %s:%s in cluster %s, either `defaultBackend` or `rules` must be specified", cfg.Namespace, cfg.Name, c.options.ClusterId)
|
return fmt.Errorf("invalid ingress rule %s:%s in cluster %s, either `defaultBackend` or `rules` must be specified", cfg.Namespace, cfg.Name, c.options.ClusterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for _, rule := range ingressV1.Rules {
|
for _, rule := range ingressV1.Rules {
|
||||||
// Need create builder for every rule.
|
// Need create builder for every rule.
|
||||||
domainBuilder := &common.IngressDomainBuilder{
|
domainBuilder := &common.IngressDomainBuilder{
|
||||||
@@ -383,9 +385,9 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp
|
|||||||
}
|
}
|
||||||
wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{
|
wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{
|
||||||
Port: &networking.Port{
|
Port: &networking.Port{
|
||||||
Number: 80,
|
Number: c.options.GatewayHttpPort,
|
||||||
Protocol: string(protocol.HTTP),
|
Protocol: string(protocol.HTTP),
|
||||||
Name: common.CreateConvertedName("http-80-ingress", c.options.ClusterId),
|
Name: common.CreateConvertedName("http-"+strconv.FormatUint(uint64(c.options.GatewayHttpPort), 10)+"-ingress", c.options.ClusterId),
|
||||||
},
|
},
|
||||||
Hosts: []string{rule.Host},
|
Hosts: []string{rule.Host},
|
||||||
})
|
})
|
||||||
@@ -428,9 +430,9 @@ func (c *controller) ConvertGateway(convertOptions *common.ConvertOptions, wrapp
|
|||||||
// Append https server
|
// Append https server
|
||||||
wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{
|
wrapperGateway.Gateway.Servers = append(wrapperGateway.Gateway.Servers, &networking.Server{
|
||||||
Port: &networking.Port{
|
Port: &networking.Port{
|
||||||
Number: 443,
|
Number: uint32(c.options.GatewayHttpsPort),
|
||||||
Protocol: string(protocol.HTTPS),
|
Protocol: string(protocol.HTTPS),
|
||||||
Name: common.CreateConvertedName("https-443-ingress", c.options.ClusterId),
|
Name: common.CreateConvertedName("https-"+strconv.FormatUint(uint64(c.options.GatewayHttpsPort), 10)+"-ingress", c.options.ClusterId),
|
||||||
},
|
},
|
||||||
Hosts: []string{rule.Host},
|
Hosts: []string{rule.Host},
|
||||||
Tls: &networking.ServerTLSSettings{
|
Tls: &networking.ServerTLSSettings{
|
||||||
|
|||||||
Reference in New Issue
Block a user