new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java
private static void createCoordinator(String image,
                                        String imagePullPolicy,
                                        String namespace,
                                        String secretName) throws ApiException {
    if (coordinatorDepl == null) {
      Map labels = new HashMap<String, String>();
      labels.put("app", "coordinator");
      coordinatorDepl = new V1Deployment()
              .apiVersion("apps/v1")
              .kind("Deployment")
              .metadata(new V1ObjectMeta()
                      .name("coordinator")
                      .namespace(namespace)
                      .labels(labels))
              .spec(new V1DeploymentSpec()
                      .replicas(1)
                      .selector(new V1LabelSelector()
                              .matchLabels(labels))
                      .strategy(new V1DeploymentStrategy()
                              .type("Recreate"))
                      .template(new V1PodTemplateSpec()
                              .metadata(new V1ObjectMeta()
                                      .labels(labels))
                              .spec(new V1PodSpec()
                                      .containers(Arrays.asList(
                                              new V1Container()
                                                      .image(image)
                                                      .imagePullPolicy(imagePullPolicy)
                                                      .name("coordinator")
                                                      .ports(Arrays.asList(
                                                              new V1ContainerPort()
                                                                      .containerPort(8999)))))
                                      .imagePullSecrets(Arrays.asList(
                                              new V1LocalObjectReference()
                                                      .name(secretName))))));

      logger.info("Create deployment for coordinator in namespace {0}",
              namespace);
      boolean deploymentCreated = assertDoesNotThrow(() -> Kubernetes.createDeployment(coordinatorDepl),
              String.format("Create deployment failed with ApiException for coordinator in namespace %s",
                      namespace));
      assertTrue(deploymentCreated, String.format(
              "Create deployment failed with ApiException for coordinator in namespace %s ",
              namespace));
      withStandardRetryPolicy
              .conditionEvaluationListener(
                condition -> logger.info("Waiting for deployment {0} to be completed in namespace {1} "
                                      + "(elapsed time {2} ms, remaining time {3} ms)",
                              "coordinator",
                              namespace,
                              condition.getElapsedTimeInMS(),
                              condition.getRemainingTimeInMS()))
              .until(Deployment.isReady("coordinator", labels, namespace));

      HashMap<String,String> annotations = new HashMap<>();
      annotations.put("kubectl.kubernetes.io/last-applied-configuration","");
      coordinatorService = new V1Service()
              .metadata(new V1ObjectMeta()
                      .name("coordinator")
                      .annotations(annotations)
                      .namespace(namespace)
                      .labels(labels))
              .spec(new V1ServiceSpec()
                      .ports(Arrays.asList(
                              new V1ServicePort()
                                      .port(8999)
                                      .targetPort(new IntOrString(8999))))
                      .type("NodePort")
                      .selector(labels));

      logger.info("Create service for coordinator in namespace {0}",
              namespace);
      boolean success = assertDoesNotThrow(() -> Kubernetes.createService(coordinatorService),
              String.format("Create service failed with ApiException for coordinator in namespace %s",
                      namespace));
      assertTrue(success, "Coordinator service creation failed");
    }
  }
/**
   * Create Coordinator deployment and service.
   *
   * @param image full image name for deployment
   * @param imagePullPolicy policy for image
   * @param namespace coordinator namespace
   * @param secretName coordinator secret name
   */
Create Coordinator deployment and service.
@param image full image name for deployment
@param imagePullPolicy policy for image
@param namespace coordinator namespace
@param secretName coordinator secret name
Create Coordinator deployment and service . @param image full image name for deployment @param imagePullPolicy policy for image @param namespace coordinator namespace @param secretName coordinator secret name
private static void createCoordinator(String image,
                                        String imagePullPolicy,
                                        String namespace,
                                        String secretName) throws ApiException {
    if (coordinatorDepl == null) {
      Map labels = new HashMap<String, String>();
      labels.put("app", "coordinator");
      coordinatorDepl = new V1Deployment()
              .apiVersion("apps/v1")
              .kind("Deployment")
              .metadata(new V1ObjectMeta()
                      .name("coordinator")
                      .namespace(namespace)
                      .labels(labels))
              .spec(new V1DeploymentSpec()
                      .replicas(1)
                      .selector(new V1LabelSelector()
                              .matchLabels(labels))
                      .strategy(new V1DeploymentStrategy()
                              .type("Recreate"))
                      .template(new V1PodTemplateSpec()
                              .metadata(new V1ObjectMeta()
                                      .labels(labels))
                              .spec(new V1PodSpec()
                                      .containers(Arrays.asList(
                                              new V1Container()
                                                      .image(image)
                                                      .imagePullPolicy(imagePullPolicy)
                                                      .name("coordinator")
                                                      .ports(Arrays.asList(
                                                              new V1ContainerPort()
                                                                      .containerPort(8999)))))
                                      .imagePullSecrets(Arrays.asList(
                                              new V1LocalObjectReference()
                                                      .name(secretName))))));
      logger.info("Create deployment for coordinator in namespace {0}",
              namespace);
      boolean deploymentCreated = assertDoesNotThrow(() -> Kubernetes.createDeployment(coordinatorDepl),
              String.format("Create deployment failed with ApiException for coordinator in namespace %s",
                      namespace));
      assertTrue(deploymentCreated, String.format(
              "Create deployment failed with ApiException for coordinator in namespace %s ",
              namespace));
      withStandardRetryPolicy
              .conditionEvaluationListener(
                condition -> logger.info("Waiting for deployment {0} to be completed in namespace {1} "
                                      + "(elapsed time {2} ms, remaining time {3} ms)",
                              "coordinator",
                              namespace,
                              condition.getElapsedTimeInMS(),
                              condition.getRemainingTimeInMS()))
              .until(Deployment.isReady("coordinator", labels, namespace));
      HashMap<String,String> annotations = new HashMap<>();
      annotations.put("kubectl.kubernetes.io/last-applied-configuration","");
      coordinatorService = new V1Service()
              .metadata(new V1ObjectMeta()
                      .name("coordinator")
                      .annotations(annotations)
                      .namespace(namespace)
                      .labels(labels))
              .spec(new V1ServiceSpec()
                      .ports(Arrays.asList(
                              new V1ServicePort()
                                      .port(8999)
                                      .targetPort(new IntOrString(8999))))
                      .type("NodePort")
                      .selector(labels));
      logger.info("Create service for coordinator in namespace {0}",
              namespace);
      boolean success = assertDoesNotThrow(() -> Kubernetes.createService(coordinatorService),
              String.format("Create service failed with ApiException for coordinator in namespace %s",
                      namespace));
      assertTrue(success, "Coordinator service creation failed");
    }
  }
private static void createCoordinator ( String image , String imagePullPolicy , String namespace , String secretName ) throws ApiException { if ( coordinatorDepl == null ) { Map labels = new HashMap < String , String > ( ) ; labels . put ( "app" , "coordinator" ) ; coordinatorDepl = new V1Deployment ( ) . apiVersion ( "apps/v1" ) . kind ( "Deployment" ) . metadata ( new V1ObjectMeta ( ) . name ( "coordinator" ) . namespace ( namespace ) . labels ( labels ) ) . spec ( new V1DeploymentSpec ( ) . replicas ( 1 ) . selector ( new V1LabelSelector ( ) . matchLabels ( labels ) ) . strategy ( new V1DeploymentStrategy ( ) . type ( "Recreate" ) ) . template ( new V1PodTemplateSpec ( ) . metadata ( new V1ObjectMeta ( ) . labels ( labels ) ) . spec ( new V1PodSpec ( ) . containers ( Arrays . asList ( new V1Container ( ) . image ( image ) . imagePullPolicy ( imagePullPolicy ) . name ( "coordinator" ) . ports ( Arrays . asList ( new V1ContainerPort ( ) . containerPort ( 8999 ) ) ) ) ) . imagePullSecrets ( Arrays . asList ( new V1LocalObjectReference ( ) . name ( secretName ) ) ) ) ) ) ; logger . info ( "Create deployment for coordinator in namespace {0}" , namespace ) ; boolean deploymentCreated = assertDoesNotThrow ( ( ) -> Kubernetes . createDeployment ( coordinatorDepl ) , String . format ( "Create deployment failed with ApiException for coordinator in namespace %s" , namespace ) ) ; assertTrue ( deploymentCreated , String . format ( "Create deployment failed with ApiException for coordinator in namespace %s " , namespace ) ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for deployment {0} to be completed in namespace {1} " + "(elapsed time {2} ms, remaining time {3} ms)" , "coordinator" , namespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( Deployment . isReady ( "coordinator" , labels , namespace ) ) ; HashMap < String , String > annotations = new HashMap < > ( ) ; annotations . put ( "kubectl.kubernetes.io/last-applied-configuration" , "" ) ; coordinatorService = new V1Service ( ) . metadata ( new V1ObjectMeta ( ) . name ( "coordinator" ) . annotations ( annotations ) . namespace ( namespace ) . labels ( labels ) ) . spec ( new V1ServiceSpec ( ) . ports ( Arrays . asList ( new V1ServicePort ( ) . port ( 8999 ) . targetPort ( new IntOrString ( 8999 ) ) ) ) . type ( "NodePort" ) . selector ( labels ) ) ; logger . info ( "Create service for coordinator in namespace {0}" , namespace ) ; boolean success = assertDoesNotThrow ( ( ) -> Kubernetes . createService ( coordinatorService ) , String . format ( "Create service failed with ApiException for coordinator in namespace %s" , namespace ) ) ; assertTrue ( success , "Coordinator service creation failed" ) ; } }
Create Coordinator deployment and service.
Create Coordinator deployment and service .