use of org.onosproject.k8snetworking.api.Constants.PRIORITY_NAT_RULE in project onos by opennetworkinglab.
the class K8sServiceHandler method setGroupBuckets.
private void setGroupBuckets(Service service, boolean install) {
Map<ServicePort, Set<String>> spEpasMap = getSportEpAddressMap(service);
Map<ServicePort, List<GroupBucket>> spGrpBkts = Maps.newConcurrentMap();
Map<String, String> nodeIpGatewayIpMap = nodeIpGatewayIpMap(k8sNodeService, k8sNetworkService);
for (K8sNode node : k8sNodeService.completeNodes()) {
spEpasMap.forEach((sp, epas) -> {
List<GroupBucket> bkts = Lists.newArrayList();
for (String ip : epas) {
GroupBucket bkt = buildBuckets(node.intgBridge(), nodeIpGatewayIpMap.getOrDefault(ip, ip), sp);
if (bkt == null) {
continue;
}
if (install) {
bkts.add(bkt);
} else {
bkts.remove(bkt);
}
}
spGrpBkts.put(sp, bkts);
});
String serviceIp = service.getSpec().getClusterIP();
spGrpBkts.forEach((sp, bkts) -> {
String svcStr = servicePortStr(serviceIp, sp.getPort(), sp.getProtocol());
int groupId = svcStr.hashCode();
if (bkts.size() > 0) {
k8sGroupRuleService.setBuckets(appId, node.intgBridge(), groupId, bkts);
}
});
spEpasMap.forEach((sp, epas) -> epas.forEach(epa -> {
String podIp = nodeIpGatewayIpMap.getOrDefault(epa, epa);
int targetPort;
if (sp.getTargetPort().getIntVal() == null) {
Pod pod = podByIp(k8sPodService, podIp);
targetPort = portNumberByName(pod, sp.getTargetPort().getStrVal());
} else {
targetPort = sp.getTargetPort().getIntVal();
}
if (targetPort != 0) {
setUnshiftDomainRules(node.intgBridge(), POD_TABLE, PRIORITY_NAT_RULE, serviceIp, sp.getPort(), sp.getProtocol(), podIp, targetPort, install);
}
}));
}
}
Aggregations