use of oracle.kubernetes.operator.wlsconfig.WlsServerConfig in project weblogic-kubernetes-operator by oracle.
the class Main method adminChannelsToCreate.
/**
* This method checks the domain spec against any configured network
* access points defined for the domain. This implementation only handles T3
* protocol for externalization.
*
* @param scan WlsDomainConfig from discovery containing configuration
* @param dom Domain containing Domain resource information
* @return Validated collection of network access points
*/
public static Collection<NetworkAccessPoint> adminChannelsToCreate(WlsDomainConfig scan, Domain dom) {
LOGGER.entering();
// The following hard-coded values for the nodePort min/max ranges are
// provided here until the appropriate API is discovered to obtain
// this information from Kubernetes.
Integer nodePortMin = 30000;
Integer nodePortMax = 32767;
DomainSpec spec = dom.getSpec();
if (spec.getExportT3Channels() == null) {
return null;
}
WlsServerConfig adminServerConfig = scan.getServerConfig(spec.getAsName());
List<NetworkAccessPoint> naps = adminServerConfig.getNetworkAccessPoints();
// This will become a list of valid channels to create services for.
Collection<NetworkAccessPoint> channels = new ArrayList<>();
// Pick out externalized channels from the server channels list
for (String incomingChannel : spec.getExportT3Channels()) {
boolean missingChannel = true;
for (NetworkAccessPoint nap : naps) {
if (nap.getName().equalsIgnoreCase(incomingChannel)) {
missingChannel = false;
channels.add(nap);
break;
}
}
if (missingChannel) {
LOGGER.warning(MessageKeys.EXCH_CHANNEL_NOT_DEFINED, incomingChannel, spec.getAsName());
}
}
// Iterate through the selected channels and validate
Collection<NetworkAccessPoint> validatedChannels = new ArrayList<>();
for (NetworkAccessPoint nap : channels) {
// Only supporting T3 for now.
if (!nap.getProtocol().equalsIgnoreCase("t3")) {
LOGGER.severe(MessageKeys.EXCH_WRONG_PROTOCOL, nap.getName(), nap.getProtocol());
continue;
}
// Until otherwise determined, ports must be the same.
if (!nap.getListenPort().equals(nap.getPublicPort())) {
// log a warning and ignore this item.
LOGGER.warning(MessageKeys.EXCH_UNEQUAL_LISTEN_PORTS, nap.getName());
continue;
}
// Make sure configured port is within NodePort range.
if (nap.getListenPort().compareTo(nodePortMin) < 0 || nap.getListenPort().compareTo(nodePortMax) > 0) {
// port setting is outside the NodePort range limits
LOGGER.warning(MessageKeys.EXCH_OUTSIDE_RANGE, nap.getName(), nap.getPublicPort(), nodePortMin, nodePortMax);
continue;
}
validatedChannels.add(nap);
}
LOGGER.exiting();
return validatedChannels;
}
use of oracle.kubernetes.operator.wlsconfig.WlsServerConfig in project weblogic-kubernetes-operator by oracle.
the class ExternalChannelTest method setupConstants.
@Before
public void setupConstants() throws NoSuchFieldException {
domain.setMetadata(meta);
domain.setSpec(spec);
meta.setNamespace("default");
spec.setAsName("admin-server");
spec.setExportT3Channels(chlist);
wlsDomainConfig = wlsDomainConfig.load(jsonString);
WlsServerConfig adminServerConfig = wlsDomainConfig.getServerConfig(spec.getAsName());
List<NetworkAccessPoint> naps = adminServerConfig.getNetworkAccessPoints();
nap = naps.get(0);
Class<?> cls = nap.getClass();
protocol = cls.getDeclaredField("protocol");
listenPort = cls.getDeclaredField("listenPort");
publicPort = cls.getDeclaredField("publicPort");
protocol.setAccessible(true);
listenPort.setAccessible(true);
publicPort.setAccessible(true);
}
use of oracle.kubernetes.operator.wlsconfig.WlsServerConfig in project weblogic-kubernetes-operator by oracle.
the class IngressHelperTest method setUp.
@Before
public void setUp() throws ApiException {
// make sure test bed is clean
tearDown();
// Create domain
Domain domain = new Domain();
V1ObjectMeta metadata = new V1ObjectMeta();
metadata.setName("domianIngressHelperTest");
metadata.setNamespace(namespace);
domain.setMetadata(metadata);
DomainSpec spec = new DomainSpec();
spec.setDomainName("base_domain");
spec.setDomainUID(domainUID);
domain.setSpec(spec);
info = new DomainPresenceInfo(domain);
// Create scan
WlsDomainConfig scan = new WlsDomainConfig();
WlsServerConfig server1Scan = new WlsServerConfig(server1Name, server1Port, server1Name, null);
WlsServerConfig server2Scan = new WlsServerConfig(server2Name, server2Port, server2Name, null);
scan.getServerConfigs().put(server1Name, server1Scan);
scan.getServerConfigs().put(server2Name, server2Scan);
WlsClusterConfig cluster1Scan = new WlsClusterConfig(clusterName);
cluster1Scan.getServerConfigs().add(server1Scan);
cluster1Scan.getServerConfigs().add(server2Scan);
scan.getClusterConfigs().put(clusterName, cluster1Scan);
info.setScan(scan);
ServerKubernetesObjects sko = new ServerKubernetesObjects();
V1Service service = new V1Service();
V1ObjectMeta sm = new V1ObjectMeta();
sm.setName(service1Name);
sm.setNamespace(namespace);
service.setMetadata(sm);
V1ServiceSpec ss = new V1ServiceSpec();
V1ServicePort port = new V1ServicePort();
port.setPort(server1Port);
ss.addPortsItem(port);
service.setSpec(ss);
sko.getService().set(service);
info.getServers().put(server1Name, sko);
sko = new ServerKubernetesObjects();
service = new V1Service();
sm = new V1ObjectMeta();
sm.setName(service2Name);
sm.setNamespace(namespace);
service.setMetadata(sm);
ss = new V1ServiceSpec();
port = new V1ServicePort();
port.setPort(server2Port);
ss.addPortsItem(port);
service.setSpec(ss);
sko.getService().set(service);
info.getServers().put(server2Name, sko);
engine = new Engine("IngressHelperTest");
}
Aggregations