Search in sources :

Example 6 with DomainPresenceInfo

use of oracle.kubernetes.operator.helpers.DomainPresenceInfo in project weblogic-kubernetes-operator by oracle.

the class Main method dispatchIngressWatch.

private static void dispatchIngressWatch(Watch.Response<V1beta1Ingress> item) {
    V1beta1Ingress i = item.object;
    if (i != null) {
        V1ObjectMeta metadata = i.getMetadata();
        String domainUID = metadata.getLabels().get(LabelConstants.DOMAINUID_LABEL);
        String clusterName = metadata.getLabels().get(LabelConstants.CLUSTERNAME_LABEL);
        if (domainUID != null) {
            DomainPresenceInfo info = domains.get(domainUID);
            if (info != null && clusterName != null) {
                switch(item.type) {
                    case "ADDED":
                        info.getIngresses().put(clusterName, i);
                        break;
                    case "MODIFIED":
                        V1beta1Ingress skoIngress = info.getIngresses().get(clusterName);
                        if (skoIngress != null) {
                            info.getIngresses().replace(clusterName, skoIngress, i);
                        }
                        break;
                    case "DELETED":
                        V1beta1Ingress oldIngress = info.getIngresses().remove(clusterName);
                        if (oldIngress != null) {
                            // Ingress was deleted, but sko still contained a non-null entry
                            LOGGER.info(MessageKeys.INGRESS_DELETED, domainUID, metadata.getNamespace(), clusterName);
                            doCheckAndCreateDomainPresence(info.getDomain(), true);
                        }
                        break;
                    case "ERROR":
                    default:
                }
            }
        }
    }
}
Also used : V1beta1Ingress(io.kubernetes.client.models.V1beta1Ingress) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo)

Example 7 with DomainPresenceInfo

use of oracle.kubernetes.operator.helpers.DomainPresenceInfo in project weblogic-kubernetes-operator by oracle.

the class PodHelperConfigTest method newPacket.

private static Packet newPacket(Domain domain, V1PersistentVolumeClaimList claims) {
    DomainPresenceInfo info = new DomainPresenceInfo(domain);
    info.setClaims(claims);
    Packet packet = new Packet();
    packet.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info));
    return packet;
}
Also used : Packet(oracle.kubernetes.operator.work.Packet) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo)

Example 8 with DomainPresenceInfo

use of oracle.kubernetes.operator.helpers.DomainPresenceInfo in project weblogic-kubernetes-operator by oracle.

the class ServiceHelperTest method createReadListUpdate.

@Test
public void createReadListUpdate() throws Exception {
    CallBuilderFactory factory = new CallBuilderFactory(null);
    // Domain
    Domain dom = new Domain();
    V1ObjectMeta metadata = new V1ObjectMeta();
    metadata.setResourceVersion("12345");
    metadata.setNamespace("tests");
    dom.setMetadata(metadata);
    DomainSpec spec = new DomainSpec();
    spec.setDomainUID("domain-uid");
    spec.setDomainName("base_domain");
    dom.setSpec(spec);
    // Create a new service.
    System.out.println("Creating service");
    Step s = ServiceHelper.createForServerStep(null);
    Engine e = new Engine("ServiceHelperTest");
    Packet p = new Packet();
    DomainPresenceInfo info = new DomainPresenceInfo(dom);
    p.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info));
    p.put(ProcessingConstants.SERVER_NAME, "admin");
    p.put(ProcessingConstants.PORT, Integer.valueOf(7001));
    Fiber f = e.createFiber();
    f.start(s, p, null);
    f.get();
    // Read the service we just created.
    System.out.println("Reading service");
    V1Service service = factory.create().readService("domain-uid-admin", "tests");
    checkService(service, false);
    // Get a list of services.
    System.out.println("Listing services");
    V1ServiceList serviceList = factory.create().listService("tests");
    boolean serviceFound = false;
    for (V1Service item : serviceList.getItems()) {
        if (item.getMetadata().getName().equals("domain-uid-admin")) {
            serviceFound = true;
            break;
        }
    }
    Assert.assertTrue("Expected service domain-uid-admin not found in list", serviceFound);
    // Add a second selector to this service.
    Map<String, String> selector = service.getSpec().getSelector();
    selector.put("domain", "domain-uid");
    service.getSpec().setSelector(selector);
// TODO: uncomment out when bug calling replace service is fixed.
// System.out.println("Replacing service");
// service = serviceHelper.replace("domain-uid-admin", service);
// checkService(service, true);
}
Also used : Packet(oracle.kubernetes.operator.work.Packet) V1ServiceList(io.kubernetes.client.models.V1ServiceList) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) Fiber(oracle.kubernetes.operator.work.Fiber) V1Service(io.kubernetes.client.models.V1Service) CallBuilderFactory(oracle.kubernetes.operator.helpers.CallBuilderFactory) Step(oracle.kubernetes.operator.work.Step) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) Engine(oracle.kubernetes.operator.work.Engine) Test(org.junit.Test)

Aggregations

DomainPresenceInfo (oracle.kubernetes.operator.helpers.DomainPresenceInfo)8 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)5 Packet (oracle.kubernetes.operator.work.Packet)4 V1Service (io.kubernetes.client.models.V1Service)3 ServerKubernetesObjects (oracle.kubernetes.operator.helpers.ServerKubernetesObjects)3 V1Pod (io.kubernetes.client.models.V1Pod)2 V1ServiceList (io.kubernetes.client.models.V1ServiceList)2 V1beta1Ingress (io.kubernetes.client.models.V1beta1Ingress)2 CallBuilderFactory (oracle.kubernetes.operator.helpers.CallBuilderFactory)2 CompletionCallback (oracle.kubernetes.operator.work.Fiber.CompletionCallback)2 Step (oracle.kubernetes.operator.work.Step)2 Domain (oracle.kubernetes.weblogic.domain.v1.Domain)2 DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)2 ApiException (io.kubernetes.client.ApiException)1 JSON (io.kubernetes.client.JSON)1 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)1 V1DeleteOptions (io.kubernetes.client.models.V1DeleteOptions)1 V1EnvVar (io.kubernetes.client.models.V1EnvVar)1 V1PersistentVolumeClaimList (io.kubernetes.client.models.V1PersistentVolumeClaimList)1 V1PodList (io.kubernetes.client.models.V1PodList)1