k8s: pods resolve the swarm names of host-run services to the hive bridge
This commit is contained in:
parent
242df5faba
commit
cb54519be8
1 changed files with 168 additions and 11 deletions
|
|
@ -55,6 +55,9 @@ let
|
|||
deploy.k8s.podCidr = "10.42.0.0/16";
|
||||
deploy.k8s.serviceCidr = "10.42.128.0/17";
|
||||
};
|
||||
# The node on a host with no hive bridge, so no address to resolve names to.
|
||||
nodeNoBridge = hive { deploy.k8s.enable = true; };
|
||||
coreDnsKey = "hyperhive-host-services.override";
|
||||
refusals = lib.filter (a: !a.assertion) nodeRefused.assertions;
|
||||
refuses = needle: lib.any (a: lib.hasInfix needle a.message) refusals;
|
||||
|
||||
|
|
@ -262,6 +265,46 @@ let
|
|||
&& refuses "overlap the hive bridge"
|
||||
&& refuses "overlap each other";
|
||||
}
|
||||
{
|
||||
# The names are the control that the search finds something: the swarm's
|
||||
# own bao name and the hive domain are among them, and every one is in the
|
||||
# A and AAAA templates.
|
||||
name = "the node's CoreDNS answers every swarm name this host serves with the hive bridge's address";
|
||||
ok =
|
||||
let
|
||||
h = withNode.services.hyperhive;
|
||||
cm = withNode.services.k3s.manifests.coredns-custom.content;
|
||||
text = cm.data.${coreDnsKey};
|
||||
names = lib.unique ([ h.domain ] ++ h.gateway.localNames);
|
||||
in
|
||||
cm.kind == "ConfigMap"
|
||||
&& cm.metadata.name == "coredns-custom"
|
||||
&& cm.metadata.namespace == "kube-system"
|
||||
&& lib.length names >= 6
|
||||
&& lib.elem h.swarm.bao.domain names
|
||||
&& lib.all (n: lib.hasInfix (builtins.replaceStrings [ "." ] [ "[.]" ] n) text) names
|
||||
&& lib.hasInfix "template IN A {" text
|
||||
&& lib.hasInfix "template IN AAAA {" text
|
||||
&& lib.hasInfix "answer \"{{ .Name }} 60 IN A ${h.network.bridgeIp}\"" text
|
||||
&& lib.hasInfix " fallthrough\n}\n" text
|
||||
&& !(lib.hasInfix "127.0.0.1" text)
|
||||
&& !(lib.hasInfix "hosts" text)
|
||||
&& lib.attrNames h.deploy.k8s.hostServices == lib.sort lib.lessThan names
|
||||
&& lib.all (s: s.address == h.network.bridgeIp) (lib.attrValues h.deploy.k8s.hostServices);
|
||||
}
|
||||
{
|
||||
# The host with the node on and a bridge is the control that the manifest
|
||||
# is there to be absent.
|
||||
name = "the node applies the CoreDNS override only on a host with the hive bridge";
|
||||
ok =
|
||||
withNode.services.hyperhive.network.enable
|
||||
&& withNode.services.k3s.manifests ? coredns-custom
|
||||
&& allLocal.services.k3s.manifests == { }
|
||||
&& !nodeNoBridge.services.hyperhive.network.enable
|
||||
&& nodeNoBridge.services.hyperhive.domain == "h1.t.local"
|
||||
&& nodeNoBridge.services.hyperhive.deploy.k8s.hostServices == { }
|
||||
&& !(nodeNoBridge.services.k3s.manifests ? coredns-custom);
|
||||
}
|
||||
];
|
||||
in
|
||||
runGroup "k8s" cases
|
||||
|
|
|
|||
Loading…
Reference in a new issue