new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMonitoringExporter.java
private static void createWebHook(String image,
                                    String imagePullPolicy,
                                    String namespace,
                                    String secretName) throws ApiException {
    Map labels = new HashMap<String, String>();
    labels.put("app", "webhook");

    webhookDepl = new V1Deployment()
        .apiVersion("apps/v1")
        .kind("Deployment")
        .metadata(new V1ObjectMeta()
            .name("webhook")
            .namespace(namespace)
            .labels(labels))
        .spec(new V1DeploymentSpec()
            .replicas(1)
            .selector(new V1LabelSelector()
                .matchLabels(labels))
            .template(new V1PodTemplateSpec()
                .metadata(new V1ObjectMeta()
                    .labels(labels))
                .spec(new V1PodSpec()
                    .containers(Arrays.asList(
                        new V1Container()
                            .image(image)
                            .imagePullPolicy(imagePullPolicy)
                            .name("webhook")))
                    .imagePullSecrets(Arrays.asList(
                        new V1LocalObjectReference()
                            .name(secretName))))));

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

    webhookService = new V1Service()
        .metadata(new V1ObjectMeta()
            .name("webhook")
            .namespace(namespace)
            .labels(labels))
        .spec(new V1ServiceSpec()
            .ports(Arrays.asList(
                new V1ServicePort()
                    .port(8080)
                    .protocol("TCP")))
            .selector(labels));

    logger.info("Create service for webhook in namespace {0}",
        namespace);
    boolean serviceCreated = assertDoesNotThrow(() -> Kubernetes.createService(webhookService),
        String.format("Create service failed with ApiException for webhook in namespace %s",
            namespace));
    assertTrue(serviceCreated, String.format(
        "Create service failed with ApiException for webhook in namespace %s ",
        namespace));
    // wait for the webhook pod to be ready
    logger.info("Wait for the webhook pod is ready in namespace {0}", namespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for webhook to be running in namespace {0} "
                    + "(elapsed time {1}ms, remaining time {2}ms)",
                namespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(assertDoesNotThrow(() -> podIsReady(namespace, "app=webhook", "webhook"),
            "webhook podIsReady failed with ApiException"));
  }
/**
   * Create Webhook deployment and service.
   *
   * @param image full image name for deployment
   * @param imagePullPolicy policy for image
   * @param namespace webhook namespace
   * @param secretName webhook image secret name
   */
Create Webhook deployment and service.
@param image full image name for deployment
@param imagePullPolicy policy for image
@param namespace webhook namespace
@param secretName webhook image secret name
Create Webhook deployment and service . @param image full image name for deployment @param imagePullPolicy policy for image @param namespace webhook namespace @param secretName webhook image secret name
private static void createWebHook(String image,
                                    String imagePullPolicy,
                                    String namespace,
                                    String secretName) throws ApiException {
    Map labels = new HashMap<String, String>();
    labels.put("app", "webhook");
    webhookDepl = new V1Deployment()
        .apiVersion("apps/v1")
        .kind("Deployment")
        .metadata(new V1ObjectMeta()
            .name("webhook")
            .namespace(namespace)
            .labels(labels))
        .spec(new V1DeploymentSpec()
            .replicas(1)
            .selector(new V1LabelSelector()
                .matchLabels(labels))
            .template(new V1PodTemplateSpec()
                .metadata(new V1ObjectMeta()
                    .labels(labels))
                .spec(new V1PodSpec()
                    .containers(Arrays.asList(
                        new V1Container()
                            .image(image)
                            .imagePullPolicy(imagePullPolicy)
                            .name("webhook")))
                    .imagePullSecrets(Arrays.asList(
                        new V1LocalObjectReference()
                            .name(secretName))))));
    logger.info("Create deployment for webhook in namespace {0}",
        namespace);
    boolean deploymentCreated = assertDoesNotThrow(() -> Kubernetes.createDeployment(webhookDepl),
        String.format("Create deployment failed with ApiException for webhook in namespace %s",
            namespace));
    assertTrue(deploymentCreated, String.format(
            "Create deployment failed with ApiException for webhook in namespace %s ",
            namespace));
    logger.info("Checking if the deployment is ready {0} completed in namespace {1}",
            "webhook", namespace);
    withStandardRetryPolicy
      .conditionEvaluationListener(
          condition -> logger.info("Waiting for deployment {0} to be completed in namespace {1} "
                          + "(elapsed time {2} ms, remaining time {3} ms)",
                  "webhook",
                  namespace,
                  condition.getElapsedTimeInMS(),
                  condition.getRemainingTimeInMS()))
        .until(Deployment.isReady("webhook", labels, namespace));
    webhookService = new V1Service()
        .metadata(new V1ObjectMeta()
            .name("webhook")
            .namespace(namespace)
            .labels(labels))
        .spec(new V1ServiceSpec()
            .ports(Arrays.asList(
                new V1ServicePort()
                    .port(8080)
                    .protocol("TCP")))
            .selector(labels));
    logger.info("Create service for webhook in namespace {0}",
        namespace);
    boolean serviceCreated = assertDoesNotThrow(() -> Kubernetes.createService(webhookService),
        String.format("Create service failed with ApiException for webhook in namespace %s",
            namespace));
    assertTrue(serviceCreated, String.format(
        "Create service failed with ApiException for webhook in namespace %s ",
        namespace));
    logger.info("Wait for the webhook pod is ready in namespace {0}", namespace);
    withStandardRetryPolicy
        .conditionEvaluationListener(
            condition -> logger.info("Waiting for webhook to be running in namespace {0} "
                    + "(elapsed time {1}ms, remaining time {2}ms)",
                namespace,
                condition.getElapsedTimeInMS(),
                condition.getRemainingTimeInMS()))
        .until(assertDoesNotThrow(() -> podIsReady(namespace, "app=webhook", "webhook"),
            "webhook podIsReady failed with ApiException"));
  }
private static void createWebHook ( String image , String imagePullPolicy , String namespace , String secretName ) throws ApiException { Map labels = new HashMap < String , String > ( ) ; labels . put ( "app" , "webhook" ) ; webhookDepl = new V1Deployment ( ) . apiVersion ( "apps/v1" ) . kind ( "Deployment" ) . metadata ( new V1ObjectMeta ( ) . name ( "webhook" ) . namespace ( namespace ) . labels ( labels ) ) . spec ( new V1DeploymentSpec ( ) . replicas ( 1 ) . selector ( new V1LabelSelector ( ) . matchLabels ( labels ) ) . template ( new V1PodTemplateSpec ( ) . metadata ( new V1ObjectMeta ( ) . labels ( labels ) ) . spec ( new V1PodSpec ( ) . containers ( Arrays . asList ( new V1Container ( ) . image ( image ) . imagePullPolicy ( imagePullPolicy ) . name ( "webhook" ) ) ) . imagePullSecrets ( Arrays . asList ( new V1LocalObjectReference ( ) . name ( secretName ) ) ) ) ) ) ; logger . info ( "Create deployment for webhook in namespace {0}" , namespace ) ; boolean deploymentCreated = assertDoesNotThrow ( ( ) -> Kubernetes . createDeployment ( webhookDepl ) , String . format ( "Create deployment failed with ApiException for webhook in namespace %s" , namespace ) ) ; assertTrue ( deploymentCreated , String . format ( "Create deployment failed with ApiException for webhook in namespace %s " , namespace ) ) ; logger . info ( "Checking if the deployment is ready {0} completed in namespace {1}" , "webhook" , namespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for deployment {0} to be completed in namespace {1} " + "(elapsed time {2} ms, remaining time {3} ms)" , "webhook" , namespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( Deployment . isReady ( "webhook" , labels , namespace ) ) ; webhookService = new V1Service ( ) . metadata ( new V1ObjectMeta ( ) . name ( "webhook" ) . namespace ( namespace ) . labels ( labels ) ) . spec ( new V1ServiceSpec ( ) . ports ( Arrays . asList ( new V1ServicePort ( ) . port ( 8080 ) . protocol ( "TCP" ) ) ) . selector ( labels ) ) ; logger . info ( "Create service for webhook in namespace {0}" , namespace ) ; boolean serviceCreated = assertDoesNotThrow ( ( ) -> Kubernetes . createService ( webhookService ) , String . format ( "Create service failed with ApiException for webhook in namespace %s" , namespace ) ) ; assertTrue ( serviceCreated , String . format ( "Create service failed with ApiException for webhook in namespace %s " , namespace ) ) ; logger . info ( "Wait for the webhook pod is ready in namespace {0}" , namespace ) ; withStandardRetryPolicy . conditionEvaluationListener ( condition -> logger . info ( "Waiting for webhook to be running in namespace {0} " + "(elapsed time {1}ms, remaining time {2}ms)" , namespace , condition . getElapsedTimeInMS ( ) , condition . getRemainingTimeInMS ( ) ) ) . until ( assertDoesNotThrow ( ( ) -> podIsReady ( namespace , "app=webhook" , "webhook" ) , "webhook podIsReady failed with ApiException" ) ) ; }
Create Webhook deployment and service.
Create Webhook deployment and service .
// wait for the webhook pod to be ready