Search in sources :

Example 1 with V1ServicePort

use of io.kubernetes.client.models.V1ServicePort 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");
}
Also used : V1ServicePort(io.kubernetes.client.models.V1ServicePort) WlsServerConfig(oracle.kubernetes.operator.wlsconfig.WlsServerConfig) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) WlsClusterConfig(oracle.kubernetes.operator.wlsconfig.WlsClusterConfig) V1ServiceSpec(io.kubernetes.client.models.V1ServiceSpec) V1Service(io.kubernetes.client.models.V1Service) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) WlsDomainConfig(oracle.kubernetes.operator.wlsconfig.WlsDomainConfig) Engine(oracle.kubernetes.operator.work.Engine) Before(org.junit.Before)

Example 2 with V1ServicePort

use of io.kubernetes.client.models.V1ServicePort in project twister2 by DSC-SPIDAL.

the class KubernetesUtils method createServiceObject.

public static V1Service createServiceObject(String serviceName, String serviceLabel, int port, int targetPort) {
    V1Service service = new V1Service();
    service.setKind("Service");
    service.setApiVersion("v1");
    // construct and set metadata
    V1ObjectMeta meta = new V1ObjectMeta();
    meta.setName(serviceName);
    service.setMetadata(meta);
    // construct and set service spec
    V1ServiceSpec serviceSpec = new V1ServiceSpec();
    // ClusterIP needs to be None for headless service
    serviceSpec.setClusterIP("None");
    // set selector
    HashMap<String, String> selectors = new HashMap<String, String>();
    selectors.put("app", serviceLabel);
    serviceSpec.setSelector(selectors);
    ArrayList<V1ServicePort> ports = new ArrayList<V1ServicePort>();
    V1ServicePort servicePort = new V1ServicePort();
    servicePort.setPort(port);
    servicePort.setTargetPort(new IntOrString(targetPort));
    servicePort.setProtocol("TCP");
    ports.add(servicePort);
    serviceSpec.setPorts(ports);
    service.setSpec(serviceSpec);
    return service;
}
Also used : V1ServicePort(io.kubernetes.client.models.V1ServicePort) HashMap(java.util.HashMap) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) IntOrString(io.kubernetes.client.custom.IntOrString) V1ServiceSpec(io.kubernetes.client.models.V1ServiceSpec) ArrayList(java.util.ArrayList) V1Service(io.kubernetes.client.models.V1Service) IntOrString(io.kubernetes.client.custom.IntOrString)

Aggregations

V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)2 V1Service (io.kubernetes.client.models.V1Service)2 V1ServicePort (io.kubernetes.client.models.V1ServicePort)2 V1ServiceSpec (io.kubernetes.client.models.V1ServiceSpec)2 IntOrString (io.kubernetes.client.custom.IntOrString)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 WlsClusterConfig (oracle.kubernetes.operator.wlsconfig.WlsClusterConfig)1 WlsDomainConfig (oracle.kubernetes.operator.wlsconfig.WlsDomainConfig)1 WlsServerConfig (oracle.kubernetes.operator.wlsconfig.WlsServerConfig)1 Engine (oracle.kubernetes.operator.work.Engine)1 Domain (oracle.kubernetes.weblogic.domain.v1.Domain)1 DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)1 Before (org.junit.Before)1