new-integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/Ingress.java
public static List<String> createIngress(String ingressName,
                                           String domainNamespace,
                                           String domainUid,
                                           Map<String, Integer> clusterNameMsPortMap,
                                           Map<String, String> annotations, boolean setIngressHost) {

    List<String> ingressHostList = new ArrayList<>();
    ArrayList<NetworkingV1beta1IngressRule> ingressRules = new ArrayList<>();
    clusterNameMsPortMap.forEach((clusterName, managedServerPort) -> {
      // set the http ingress paths
      NetworkingV1beta1HTTPIngressPath httpIngressPath = new NetworkingV1beta1HTTPIngressPath()
              .path(null)
              .backend(new NetworkingV1beta1IngressBackend()
                      .serviceName(domainUid + "-cluster-" + clusterName.toLowerCase().replace("_", "-"))
                      .servicePort(new IntOrString(managedServerPort))
              );
      ArrayList<NetworkingV1beta1HTTPIngressPath> httpIngressPaths = new ArrayList<>();
      httpIngressPaths.add(httpIngressPath);

      // set the ingress rule
      String ingressHost = domainUid + "." + domainNamespace + "." + clusterName + ".test";
      if (!setIngressHost) {
        ingressHost = "";
        ingressHostList.add("*");
      }
      NetworkingV1beta1IngressRule ingressRule = new NetworkingV1beta1IngressRule()
              .host(ingressHost)
              .http(new NetworkingV1beta1HTTPIngressRuleValue()
                      .paths(httpIngressPaths));

      ingressRules.add(ingressRule);
      ingressHostList.add(ingressHost);
    });

    // set the ingress
    NetworkingV1beta1Ingress ingress = new NetworkingV1beta1Ingress()
            .apiVersion(INGRESS_API_VERSION)
            .kind(INGRESS_KIND)
            .metadata(new V1ObjectMeta()
                    .name(ingressName)
                    .namespace(domainNamespace)
                    .annotations(annotations))
            .spec(new NetworkingV1beta1IngressSpec()
                    .rules(ingressRules));

    // create the ingress
    try {
      Kubernetes.createIngress(domainNamespace, ingress);
    } catch (ApiException apex) {
      getLogger().severe("got ApiException while calling createIngress: {0}", apex.getResponseBody());
      return null;
    }

    return ingressHostList;
  }
/**
   * Create an ingress for the WebLogic domain with domainUid in the specified domain namespace.
   * The ingress host is set to 'domainUid.domainNamespace.clusterName.test'.
   *
   * @param ingressName name of the ingress to be created
   * @param domainNamespace the WebLogic domain namespace in which the ingress will be created
   * @param domainUid the WebLogic domainUid which is backend to the ingress
   * @param clusterNameMsPortMap the map with key as cluster name and value as managed server port of the cluster
   * @param annotations annotations to create ingress resource
   * @param setIngressHost if false does not set ingress host
   * @return list of ingress hosts or null if got ApiException when calling Kubernetes client API to create ingress
   */
Create an ingress for the WebLogic domain with domainUid in the specified domain namespace.
The ingress host is set to 'domainUid.domainNamespace.clusterName.test'.


Create an ingress for the WebLogic domain with domainUid in the specified domain namespace . The ingress host is set to ' domainUid . domainNamespace . clusterName . test ' .
public static List<String> createIngress(String ingressName,
                                           String domainNamespace,
                                           String domainUid,
                                           Map<String, Integer> clusterNameMsPortMap,
                                           Map<String, String> annotations, boolean setIngressHost) {
    List<String> ingressHostList = new ArrayList<>();
    ArrayList<NetworkingV1beta1IngressRule> ingressRules = new ArrayList<>();
    clusterNameMsPortMap.forEach((clusterName, managedServerPort) -> {
      NetworkingV1beta1HTTPIngressPath httpIngressPath = new NetworkingV1beta1HTTPIngressPath()
              .path(null)
              .backend(new NetworkingV1beta1IngressBackend()
                      .serviceName(domainUid + "-cluster-" + clusterName.toLowerCase().replace("_", "-"))
                      .servicePort(new IntOrString(managedServerPort))
              );
      ArrayList<NetworkingV1beta1HTTPIngressPath> httpIngressPaths = new ArrayList<>();
      httpIngressPaths.add(httpIngressPath);
      String ingressHost = domainUid + "." + domainNamespace + "." + clusterName + ".test";
      if (!setIngressHost) {
        ingressHost = "";
        ingressHostList.add("*");
      }
      NetworkingV1beta1IngressRule ingressRule = new NetworkingV1beta1IngressRule()
              .host(ingressHost)
              .http(new NetworkingV1beta1HTTPIngressRuleValue()
                      .paths(httpIngressPaths));
      ingressRules.add(ingressRule);
      ingressHostList.add(ingressHost);
    });
    NetworkingV1beta1Ingress ingress = new NetworkingV1beta1Ingress()
            .apiVersion(INGRESS_API_VERSION)
            .kind(INGRESS_KIND)
            .metadata(new V1ObjectMeta()
                    .name(ingressName)
                    .namespace(domainNamespace)
                    .annotations(annotations))
            .spec(new NetworkingV1beta1IngressSpec()
                    .rules(ingressRules));
    try {
      Kubernetes.createIngress(domainNamespace, ingress);
    } catch (ApiException apex) {
      getLogger().severe("got ApiException while calling createIngress: {0}", apex.getResponseBody());
      return null;
    }
    return ingressHostList;
  }
public static List < String > createIngress ( String ingressName , String domainNamespace , String domainUid , Map < String , Integer > clusterNameMsPortMap , Map < String , String > annotations , boolean setIngressHost ) { List < String > ingressHostList = new ArrayList < > ( ) ; ArrayList < NetworkingV1beta1IngressRule > ingressRules = new ArrayList < > ( ) ; clusterNameMsPortMap . forEach ( ( clusterName , managedServerPort ) -> { NetworkingV1beta1HTTPIngressPath httpIngressPath = new NetworkingV1beta1HTTPIngressPath ( ) . path ( null ) . backend ( new NetworkingV1beta1IngressBackend ( ) . serviceName ( domainUid + "-cluster-" + clusterName . toLowerCase ( ) . replace ( "_" , "-" ) ) . servicePort ( new IntOrString ( managedServerPort ) ) ) ; ArrayList < NetworkingV1beta1HTTPIngressPath > httpIngressPaths = new ArrayList < > ( ) ; httpIngressPaths . add ( httpIngressPath ) ; String ingressHost = domainUid + "." + domainNamespace + "." + clusterName + ".test" ; if ( ! setIngressHost ) { ingressHost = "" ; ingressHostList . add ( "*" ) ; } NetworkingV1beta1IngressRule ingressRule = new NetworkingV1beta1IngressRule ( ) . host ( ingressHost ) . http ( new NetworkingV1beta1HTTPIngressRuleValue ( ) . paths ( httpIngressPaths ) ) ; ingressRules . add ( ingressRule ) ; ingressHostList . add ( ingressHost ) ; } ) ; NetworkingV1beta1Ingress ingress = new NetworkingV1beta1Ingress ( ) . apiVersion ( INGRESS_API_VERSION ) . kind ( INGRESS_KIND ) . metadata ( new V1ObjectMeta ( ) . name ( ingressName ) . namespace ( domainNamespace ) . annotations ( annotations ) ) . spec ( new NetworkingV1beta1IngressSpec ( ) . rules ( ingressRules ) ) ; try { Kubernetes . createIngress ( domainNamespace , ingress ) ; } catch ( ApiException apex ) { getLogger ( ) . severe ( "got ApiException while calling createIngress: {0}" , apex . getResponseBody ( ) ) ; return null ; } return ingressHostList ; }
Create an ingress for the WebLogic domain with domainUid in the specified domain namespace.
Create an ingress for the WebLogic domain with domainUid in the specified domain namespace .
// set the http ingress paths // set the ingress rule // set the ingress // create the ingress