Search in sources :

Example 6 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class DomainPresenceInfo method getAdmin.

/**
 * Server objects (Pods and Services) for admin server
 * @return Server objects for admin server
 */
public ServerKubernetesObjects getAdmin() {
    Domain dom = domain.get();
    DomainSpec spec = dom.getSpec();
    return servers.get(spec.getAsName());
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 7 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class PodHelperConfigTest method getDomainCustomResourceForDefaults.

private Domain getDomainCustomResourceForDefaults(String image, String imagePullPolicy) {
    DomainSpec spec = newDomainSpec();
    spec.setDomainUID(DOMAIN_UID);
    spec.setDomainName(DOMAIN_NAME);
    spec.setAsName(ADMIN_SERVER_NAME);
    spec.setAdminSecret(newSecretReference().name(WEBLOGIC_CREDENTIALS_SECRET_NAME));
    spec.setAsPort(ADMIN_SERVER_PORT);
    if (image != null) {
        spec.setImage(image);
    }
    if (imagePullPolicy != null) {
        spec.setImagePullPolicy(imagePullPolicy);
    }
    Domain domain = new Domain();
    domain.setMetadata(newObjectMeta().namespace(NAMESPACE));
    domain.setSpec(spec);
    return domain;
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 8 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class Main method deleteDomainPresence.

private static void deleteDomainPresence(Domain dom) {
    V1ObjectMeta meta = dom.getMetadata();
    DomainSpec spec = dom.getSpec();
    String namespace = meta.getNamespace();
    String domainUID = spec.getDomainUID();
    deleteDomainPresence(namespace, domainUID);
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta)

Example 9 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class Main method scaleDownIfNecessary.

private static Step scaleDownIfNecessary(DomainPresenceInfo info, Collection<String> servers, Step next) {
    Domain dom = info.getDomain();
    DomainSpec spec = dom.getSpec();
    boolean shouldStopAdmin = false;
    String sc = spec.getStartupControl();
    if (sc != null && StartupControlConstants.NONE_STARTUPCONTROL.equals(sc.toUpperCase())) {
        shouldStopAdmin = true;
        next = DomainStatusUpdater.createAvailableStep(DomainStatusUpdater.ALL_STOPPED_AVAILABLE_REASON, next);
    }
    String adminName = spec.getAsName();
    Map<String, ServerKubernetesObjects> currentServers = info.getServers();
    Collection<Map.Entry<String, ServerKubernetesObjects>> serversToStop = new ArrayList<>();
    for (Map.Entry<String, ServerKubernetesObjects> entry : currentServers.entrySet()) {
        if ((shouldStopAdmin || !entry.getKey().equals(adminName)) && !servers.contains(entry.getKey())) {
            serversToStop.add(entry);
        }
    }
    if (!serversToStop.isEmpty()) {
        return new ServerDownIteratorStep(serversToStop, next);
    }
    return next;
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ServerKubernetesObjects(oracle.kubernetes.operator.helpers.ServerKubernetesObjects) ArrayList(java.util.ArrayList) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) V1ConfigMap(io.kubernetes.client.models.V1ConfigMap)

Example 10 with DomainSpec

use of oracle.kubernetes.weblogic.domain.v1.DomainSpec in project weblogic-kubernetes-operator by oracle.

the class Main method normalizeDomainSpec.

// -----------------------------------------------------------------------------
// 
// Below this point are methods that are called primarily from watch handlers,
// after watch events are received.
// 
// -----------------------------------------------------------------------------
private static void normalizeDomainSpec(DomainSpec spec) {
    // Normalize DomainSpec so that equals() will work correctly
    String imageName = spec.getImage();
    if (imageName == null || imageName.length() == 0) {
        spec.setImage(imageName = KubernetesConstants.DEFAULT_IMAGE);
    }
    String imagePullPolicy = spec.getImagePullPolicy();
    if (imagePullPolicy == null || imagePullPolicy.length() == 0) {
        spec.setImagePullPolicy(imagePullPolicy = (imageName.endsWith(KubernetesConstants.LATEST_IMAGE_SUFFIX)) ? KubernetesConstants.ALWAYS_IMAGEPULLPOLICY : KubernetesConstants.IFNOTPRESENT_IMAGEPULLPOLICY);
    }
    if (spec.getExportT3Channels() == null) {
        spec.setExportT3Channels(new ArrayList<String>());
    }
    String startupControl = spec.getStartupControl();
    if (startupControl == null || startupControl.length() == 0) {
        spec.setStartupControl(startupControl = StartupControlConstants.AUTO_STARTUPCONTROL);
    }
    if (spec.getServerStartup() == null) {
        spec.setServerStartup(new ArrayList<ServerStartup>());
    } else {
        for (ServerStartup ss : spec.getServerStartup()) {
            if (ss.getDesiredState() == null) {
                ss.setDesiredState(RUNNING_STATE);
            }
            if (ss.getEnv() == null) {
                ss.setEnv(new ArrayList<V1EnvVar>());
            }
        }
    }
    if (spec.getClusterStartup() == null) {
        spec.setClusterStartup(new ArrayList<ClusterStartup>());
    } else {
        for (ClusterStartup cs : spec.getClusterStartup()) {
            if (cs.getDesiredState() == null) {
                cs.setDesiredState(RUNNING_STATE);
            }
            if (cs.getEnv() == null) {
                cs.setEnv(new ArrayList<V1EnvVar>());
            }
            if (cs.getReplicas() == null) {
                cs.setReplicas(1);
            }
        }
    }
    if (spec.getReplicas() == null) {
        spec.setReplicas(1);
    }
}
Also used : ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) ServerStartup(oracle.kubernetes.weblogic.domain.v1.ServerStartup) V1EnvVar(io.kubernetes.client.models.V1EnvVar)

Aggregations

DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)17 ClusterStartup (oracle.kubernetes.weblogic.domain.v1.ClusterStartup)11 Test (org.junit.Test)10 Domain (oracle.kubernetes.weblogic.domain.v1.Domain)6 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)3 V1Service (io.kubernetes.client.models.V1Service)2 ArrayList (java.util.ArrayList)2 DomainPresenceInfo (oracle.kubernetes.operator.helpers.DomainPresenceInfo)2 WlsServerConfig (oracle.kubernetes.operator.wlsconfig.WlsServerConfig)2 Engine (oracle.kubernetes.operator.work.Engine)2 Packet (oracle.kubernetes.operator.work.Packet)2 Step (oracle.kubernetes.operator.work.Step)2 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)1 V1EnvVar (io.kubernetes.client.models.V1EnvVar)1 V1ServiceList (io.kubernetes.client.models.V1ServiceList)1 V1ServicePort (io.kubernetes.client.models.V1ServicePort)1 V1ServiceSpec (io.kubernetes.client.models.V1ServiceSpec)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1