Allow Multicluster Service to be non LoadBalancer ServiceType (#5307)

Signed-off-by: Björn Wenzel <bjoern.wenzel@dbschenker.com>
This commit is contained in:
Björn Wenzel 2020-12-03 19:03:49 +01:00 committed by GitHub
parent 86d6b46e04
commit 0ee18eb168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 17 deletions

View File

@ -17,20 +17,21 @@ Kubernetes: `>=1.13.0-0`
|-----|------|---------|-------------| |-----|------|---------|-------------|
| controllerComponentLabel | string | `"linkerd.io/control-plane-component"` | Control plane label. Do not edit | | controllerComponentLabel | string | `"linkerd.io/control-plane-component"` | Control plane label. Do not edit |
| createdByAnnotation | string | `"linkerd.io/created-by"` | Annotation label for the proxy create. Do not edit. | | createdByAnnotation | string | `"linkerd.io/created-by"` | Annotation label for the proxy create. Do not edit. |
| gateway | bool | `true` | If the gateway component should be installed | | gateway | bool | `true` | If the gateway component should be installed |
| gatewayLocalProbePath | string | `"/health-local"` | The path that will be used by the local liveness checks to ensure the gateway is alive | | gatewayLocalProbePath | string | `"/health-local"` | The path that will be used by the local liveness checks to ensure the gateway is alive |
| gatewayLocalProbePort | int | `8888` | The port that will be used by the local liveness checks to ensure the gateway is alive | | gatewayLocalProbePort | int | `8888` | The port that will be used by the local liveness checks to ensure the gateway is alive |
| gatewayName | string | `"linkerd-gateway"` | The name of the gateway that will be installed | | gatewayName | string | `"linkerd-gateway"` | The name of the gateway that will be installed |
| gatewayNginxImage | string | `"nginx"` | The Nginx image | | gatewayNginxImage | string | `"nginx"` | The Nginx image |
| gatewayNginxImageVersion | float | `1.17` | The version of the Nginx image | | gatewayNginxImageVersion | float | `1.17` | The version of the Nginx image |
| gatewayPort | int | `4143` | The port on which all the gateway will accept incoming traffic | | gatewayPort | int | `4143` | The port on which all the gateway will accept incoming traffic |
| gatewayProbePath | string | `"/health"` | The path that will be used by remote clusters for determining whether the gateway is alive | | gatewayProbePath | string | `"/health"` | The path that will be used by remote clusters for determining whether the gateway is alive |
| gatewayProbePort | int | `4181` | The port used for liveliness probing | | gatewayProbePort | int | `4181` | The port used for liveliness probing |
| gatewayProbeSeconds | int | `3` | The interval (in seconds) between liveness probes | | gatewayProbeSeconds | int | `3` | The interval (in seconds) between liveness probes |
| gatewayServiceType | string | `"LoadBalancer"` | Service Type of gateway Service |
| installNamespace | bool | `true` | If the namespace should be installed | | installNamespace | bool | `true` | If the namespace should be installed |
| linkerdVersion | string | `"linkerdVersionValue"` | Control plane version | | linkerdVersion | string | `"linkerdVersionValue"` | Control plane version |
| namespace | string | `"linkerd-multicluster"` | Service Mirror component namespace | | namespace | string | `"linkerd-multicluster"` | Service Mirror component namespace |
| proxyOutboundPort | int | `4140` | The port on which the proxy accepts outbound traffic | | proxyOutboundPort | int | `4140` | The port on which the proxy accepts outbound traffic |
| remoteMirrorServiceAccount | bool | `true` | If the remote mirror service account should be installed | | remoteMirrorServiceAccount | bool | `true` | If the remote mirror service account should be installed |
| remoteMirrorServiceAccountName | string | `"linkerd-service-mirror-remote-access-default"` | The name of the service account used to allow remote clusters to mirror local services | | remoteMirrorServiceAccountName | string | `"linkerd-service-mirror-remote-access-default"` | The name of the service account used to allow remote clusters to mirror local services |

View File

@ -133,7 +133,7 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: {{.Values.gatewayName}} app: {{.Values.gatewayName}}
type: LoadBalancer type: {{ .Values.gatewayServiceType }}
{{- if .Values.loadBalancerIP }} {{- if .Values.loadBalancerIP }}
loadBalancerIP: {{ .Values.loadBalancerIP }} loadBalancerIP: {{ .Values.loadBalancerIP }}
{{- end }} {{- end }}

View File

@ -2,7 +2,7 @@
controllerComponentLabel: linkerd.io/control-plane-component controllerComponentLabel: linkerd.io/control-plane-component
# -- Annotation label for the proxy create. Do not edit. # -- Annotation label for the proxy create. Do not edit.
createdByAnnotation: linkerd.io/created-by createdByAnnotation: linkerd.io/created-by
# -- If the gateway component should be installed # -- If the gateway component should be installed
gateway: true gateway: true
# -- The path that will be used by the local liveness checks to ensure the # -- The path that will be used by the local liveness checks to ensure the
# gateway is alive # gateway is alive
@ -10,11 +10,11 @@ gatewayLocalProbePath: /health-local
# -- The port that will be used by the local liveness checks to ensure the # -- The port that will be used by the local liveness checks to ensure the
# gateway is alive # gateway is alive
gatewayLocalProbePort: 8888 gatewayLocalProbePort: 8888
# -- The name of the gateway that will be installed # -- The name of the gateway that will be installed
gatewayName: linkerd-gateway gatewayName: linkerd-gateway
# -- The Nginx image # -- The Nginx image
gatewayNginxImage: nginx gatewayNginxImage: nginx
# -- The version of the Nginx image # -- The version of the Nginx image
gatewayNginxImageVersion: 1.17 gatewayNginxImageVersion: 1.17
# -- The port on which all the gateway will accept incoming traffic # -- The port on which all the gateway will accept incoming traffic
gatewayPort: 4143 gatewayPort: 4143
@ -23,18 +23,20 @@ gatewayPort: 4143
gatewayProbePath: /health gatewayProbePath: /health
# -- The port used for liveliness probing # -- The port used for liveliness probing
gatewayProbePort: 4181 gatewayProbePort: 4181
# -- The interval (in seconds) between liveness probes # -- The interval (in seconds) between liveness probes
gatewayProbeSeconds: 3 gatewayProbeSeconds: 3
# -- If the namespace should be installed # -- If the namespace should be installed
installNamespace: true installNamespace: true
# -- Control plane version # -- Control plane version
linkerdVersion: linkerdVersionValue linkerdVersion: linkerdVersionValue
# -- Service Mirror component namespace # -- Service Mirror component namespace
namespace: linkerd-multicluster namespace: linkerd-multicluster
# -- The port on which the proxy accepts outbound traffic # -- The port on which the proxy accepts outbound traffic
proxyOutboundPort: 4140 proxyOutboundPort: 4140
# -- If the remote mirror service account should be installed # -- If the remote mirror service account should be installed
remoteMirrorServiceAccount: true remoteMirrorServiceAccount: true
# -- The name of the service account used to allow remote clusters to mirror # -- The name of the service account used to allow remote clusters to mirror
# local services # local services
remoteMirrorServiceAccountName: linkerd-service-mirror-remote-access-default remoteMirrorServiceAccountName: linkerd-service-mirror-remote-access-default
# -- Service Type of gateway Service
gatewayServiceType: LoadBalancer

View File

@ -59,6 +59,7 @@ type (
gatewayNginxImage string gatewayNginxImage string
gatewayNginxVersion string gatewayNginxVersion string
remoteMirrorCredentials bool remoteMirrorCredentials bool
gatewayServiceType string
} }
linkOptions struct { linkOptions struct {
@ -73,6 +74,7 @@ type (
controlPlaneVersion string controlPlaneVersion string
dockerRegistry string dockerRegistry string
selector string selector string
gatewayAddresses string
} }
gatewaysOptions struct { gatewaysOptions struct {
@ -97,6 +99,7 @@ func newMulticlusterInstallOptionsWithDefault() (*multiclusterInstallOptions, er
gatewayNginxImage: defaults.GatewayNginxImage, gatewayNginxImage: defaults.GatewayNginxImage,
gatewayNginxVersion: defaults.GatewayNginxImageVersion, gatewayNginxVersion: defaults.GatewayNginxImageVersion,
remoteMirrorCredentials: true, remoteMirrorCredentials: true,
gatewayServiceType: defaults.GatewayServiceType,
}, nil }, nil
} }
@ -113,6 +116,7 @@ func newLinkOptionsWithDefault() (*linkOptions, error) {
serviceMirrorRetryLimit: defaults.ServiceMirrorRetryLimit, serviceMirrorRetryLimit: defaults.ServiceMirrorRetryLimit,
logLevel: defaults.LogLevel, logLevel: defaults.LogLevel,
selector: k8s.DefaultExportedServiceSelector, selector: k8s.DefaultExportedServiceSelector,
gatewayAddresses: "",
}, nil }, nil
} }
@ -198,6 +202,7 @@ func buildMulticlusterInstallValues(ctx context.Context, opts *multiclusterInsta
defaults.ProxyOutboundPort = uint32(values.GetGlobal().Proxy.Ports.Outbound) defaults.ProxyOutboundPort = uint32(values.GetGlobal().Proxy.Ports.Outbound)
defaults.LinkerdVersion = version.Version defaults.LinkerdVersion = version.Version
defaults.RemoteMirrorServiceAccount = opts.remoteMirrorCredentials defaults.RemoteMirrorServiceAccount = opts.remoteMirrorCredentials
defaults.GatewayServiceType = opts.gatewayServiceType
return defaults, nil return defaults, nil
} }
@ -395,6 +400,7 @@ func newMulticlusterInstallCommand() *cobra.Command {
cmd.Flags().StringVar(&options.gatewayNginxImage, "gateway-nginx-image", options.gatewayNginxImage, "The nginx image to be used") cmd.Flags().StringVar(&options.gatewayNginxImage, "gateway-nginx-image", options.gatewayNginxImage, "The nginx image to be used")
cmd.Flags().StringVar(&options.gatewayNginxVersion, "gateway-nginx-image-version", options.gatewayNginxVersion, "The version of nginx to be used") cmd.Flags().StringVar(&options.gatewayNginxVersion, "gateway-nginx-image-version", options.gatewayNginxVersion, "The version of nginx to be used")
cmd.Flags().BoolVar(&options.remoteMirrorCredentials, "service-mirror-credentials", options.remoteMirrorCredentials, "Whether to install the service account which can be used by service mirror components in source clusters to discover exported services") cmd.Flags().BoolVar(&options.remoteMirrorCredentials, "service-mirror-credentials", options.remoteMirrorCredentials, "Whether to install the service account which can be used by service mirror components in source clusters to discover exported services")
cmd.Flags().StringVar(&options.gatewayServiceType, "gateway-service-type", options.gatewayServiceType, "Overwrite Service type for gateway service")
// Hide developer focused flags in release builds. // Hide developer focused flags in release builds.
release, err := version.IsReleaseChannel(version.Version) release, err := version.IsReleaseChannel(version.Version)
@ -617,7 +623,8 @@ func newLinkCommand() *cobra.Command {
return err return err
} }
gatewayAddresses := []string{} gatewayAddresses := ""
gwAddresses := []string{}
for _, ingress := range gateway.Status.LoadBalancer.Ingress { for _, ingress := range gateway.Status.LoadBalancer.Ingress {
addr := ingress.IP addr := ingress.IP
if addr == "" { if addr == "" {
@ -626,10 +633,14 @@ func newLinkCommand() *cobra.Command {
if addr == "" { if addr == "" {
continue continue
} }
gatewayAddresses = append(gatewayAddresses, addr) gwAddresses = append(gwAddresses, addr)
} }
if len(gatewayAddresses) == 0 { if len(gwAddresses) == 0 && opts.gatewayAddresses == "" {
return fmt.Errorf("Gateway %s.%s has no ingress addresses", gateway.Name, gateway.Namespace) return fmt.Errorf("Gateway %s.%s has no ingress addresses", gateway.Name, gateway.Namespace)
} else if len(gwAddresses) > 0 {
gatewayAddresses = strings.Join(gwAddresses, ",")
} else {
gatewayAddresses = opts.gatewayAddresses
} }
gatewayIdentity, ok := gateway.Annotations[k8s.GatewayIdentity] gatewayIdentity, ok := gateway.Annotations[k8s.GatewayIdentity]
@ -659,7 +670,7 @@ func newLinkCommand() *cobra.Command {
TargetClusterDomain: configMap.GetGlobal().ClusterDomain, TargetClusterDomain: configMap.GetGlobal().ClusterDomain,
TargetClusterLinkerdNamespace: controlPlaneNamespace, TargetClusterLinkerdNamespace: controlPlaneNamespace,
ClusterCredentialsSecret: fmt.Sprintf("cluster-credentials-%s", opts.clusterName), ClusterCredentialsSecret: fmt.Sprintf("cluster-credentials-%s", opts.clusterName),
GatewayAddress: strings.Join(gatewayAddresses, ","), GatewayAddress: gatewayAddresses,
GatewayPort: gatewayPort, GatewayPort: gatewayPort,
GatewayIdentity: gatewayIdentity, GatewayIdentity: gatewayIdentity,
ProbeSpec: probeSpec, ProbeSpec: probeSpec,
@ -728,6 +739,7 @@ func newLinkCommand() *cobra.Command {
cmd.Flags().StringVar(&opts.logLevel, "log-level", opts.logLevel, "Log level for the Multicluster components") cmd.Flags().StringVar(&opts.logLevel, "log-level", opts.logLevel, "Log level for the Multicluster components")
cmd.Flags().StringVar(&opts.dockerRegistry, "registry", opts.dockerRegistry, "Docker registry to pull service mirror controller image from") cmd.Flags().StringVar(&opts.dockerRegistry, "registry", opts.dockerRegistry, "Docker registry to pull service mirror controller image from")
cmd.Flags().StringVarP(&opts.selector, "selector", "l", opts.selector, "Selector (label query) to filter which services in the target cluster to mirror") cmd.Flags().StringVarP(&opts.selector, "selector", "l", opts.selector, "Selector (label query) to filter which services in the target cluster to mirror")
cmd.Flags().StringVar(&opts.gatewayAddresses, "gateway-addresses", opts.gatewayAddresses, "If specified overwrites gateway addresses when gateway service is not type LoadBalancer (comma separated list)")
return cmd return cmd
} }

View File

@ -46,6 +46,7 @@ type Values struct {
RemoteMirrorServiceAccount bool `json:"remoteMirrorServiceAccount"` RemoteMirrorServiceAccount bool `json:"remoteMirrorServiceAccount"`
RemoteMirrorServiceAccountName string `json:"remoteMirrorServiceAccountName"` RemoteMirrorServiceAccountName string `json:"remoteMirrorServiceAccountName"`
TargetClusterName string `json:"targetClusterName"` TargetClusterName string `json:"targetClusterName"`
GatewayServiceType string `json:"gatewayServiceType"`
} }
// NewInstallValues returns a new instance of the Values type. // NewInstallValues returns a new instance of the Values type.