Commit 31a63869 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Improve egress selector handling on agentless servers

Don't set up the agent tunnel authorizer on agentless servers, and warn when agentless servers won't have a way to reach in-cluster endpoints. Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 5348b5e6
...@@ -101,16 +101,20 @@ func Setup(ctx context.Context, config *daemonconfig.Node, proxy proxy.Proxy) er ...@@ -101,16 +101,20 @@ func Setup(ctx context.Context, config *daemonconfig.Node, proxy proxy.Proxy) er
close(apiServerReady) close(apiServerReady)
}() }()
// Allow the kubelet port, as published via our node object // We don't need to run the tunnel authorizer if the container runtime endpoint is /dev/null,
go tunnel.setKubeletPort(ctx, apiServerReady) // signifying that this is an agentless server that will not register a node.
if config.ContainerRuntimeEndpoint != "/dev/null" {
switch tunnel.mode { // Allow the kubelet port, as published via our node object.
case daemonconfig.EgressSelectorModeCluster: go tunnel.setKubeletPort(ctx, apiServerReady)
// In Cluster mode, we allow the cluster CIDRs, and any connections to the node's IPs for pods using host network.
tunnel.clusterAuth(config) switch tunnel.mode {
case daemonconfig.EgressSelectorModePod: case daemonconfig.EgressSelectorModeCluster:
// In Pod mode, we watch pods assigned to this node, and allow their addresses, as well as ports used by containers with host network. // In Cluster mode, we allow the cluster CIDRs, and any connections to the node's IPs for pods using host network.
go tunnel.watchPods(ctx, apiServerReady, config) tunnel.clusterAuth(config)
case daemonconfig.EgressSelectorModePod:
// In Pod mode, we watch pods assigned to this node, and allow their addresses, as well as ports used by containers with host network.
go tunnel.watchPods(ctx, apiServerReady, config)
}
} }
// The loadbalancer is only disabled when there is a local apiserver. Servers without a local // The loadbalancer is only disabled when there is a local apiserver. Servers without a local
......
...@@ -530,8 +530,11 @@ func validateNetworkConfiguration(serverConfig server.Config) error { ...@@ -530,8 +530,11 @@ func validateNetworkConfiguration(serverConfig server.Config) error {
} }
switch serverConfig.ControlConfig.EgressSelectorMode { switch serverConfig.ControlConfig.EgressSelectorMode {
case config.EgressSelectorModeAgent, config.EgressSelectorModeCluster, case config.EgressSelectorModeCluster, config.EgressSelectorModePod:
config.EgressSelectorModeDisabled, config.EgressSelectorModePod: case config.EgressSelectorModeAgent, config.EgressSelectorModeDisabled:
if serverConfig.DisableAgent {
logrus.Warn("Webhooks and apiserver aggregation may not function properly without an agent; please set egress-selector-mode to 'cluster' or 'pod'")
}
default: default:
return fmt.Errorf("invalid egress-selector-mode %s", serverConfig.ControlConfig.EgressSelectorMode) return fmt.Errorf("invalid egress-selector-mode %s", serverConfig.ControlConfig.EgressSelectorMode)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment