blob: 5dc099460a4e1c84438c8ee316d7d04fb7c0d38c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.lb;
import ai.vespa.http.DomainName;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.ZoneEndpoint;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/**
* This implementation of {@link LoadBalancerService} returns the load balancer(s) that exist by default in the shared
* routing layer.
* <p>
* Since such load balancers always exist, we can return the hostname of the routing layer VIP directly. Nothing has to
* be provisioned.
*
* @author ogronnesby
*/
public class SharedLoadBalancerService implements LoadBalancerService {
private final String vipHostname;
public SharedLoadBalancerService(String vipHostname) {
this.vipHostname = Objects.requireNonNull(vipHostname);
}
@Override
public LoadBalancerInstance create(LoadBalancerSpec spec, boolean force) {
if (spec.settings().isPresent() && ! spec.settings().get().isDefault())
throw new IllegalArgumentException("custom zone endpoint settings are not supported with " + getClass());
return new LoadBalancerInstance(Optional.of(DomainName.of(vipHostname)),
Optional.empty(),
Optional.empty(),
Set.of(4443),
Set.of(),
spec.reals(),
spec.settings().orElse(ZoneEndpoint.defaultEndpoint),
Optional.empty(),
spec.cloudAccount());
}
@Override
public void remove(LoadBalancer loadBalancer) {
// Do nothing, we have no external state to modify
}
@Override
public Protocol protocol() {
return Protocol.dualstack;
}
@Override
public boolean supports(NodeType nodeType, ClusterSpec.Type clusterType) {
// Shared routing layer only supports routing to tenant nodes
return nodeType == NodeType.tenant && clusterType.isContainer();
}
}
|