io.fabric8.kubernetes.api.model.apps.DoneableDeployment Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.apps.DoneableDeployment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 6 votes |
public static DoneableDeployment deployKafkaClients(boolean tlsListener, String kafkaClientsName, boolean hostnameVerification, KafkaUser... kafkaUsers) { Map<String, String> label = Collections.singletonMap(Constants.KAFKA_CLIENTS_LABEL_KEY, Constants.KAFKA_CLIENTS_LABEL_VALUE); Deployment kafkaClient = new DeploymentBuilder() .withNewMetadata() .withName(kafkaClientsName) .withLabels(label) .endMetadata() .withNewSpec() .withNewSelector() .addToMatchLabels("app", kafkaClientsName) .addToMatchLabels(label) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata() .addToLabels("app", kafkaClientsName) .addToLabels(label) .endMetadata() .withSpec(createClientSpec(tlsListener, kafkaClientsName, hostnameVerification, kafkaUsers)) .endTemplate() .endSpec() .build(); return KubernetesResource.deployNewDeployment(kafkaClient); }
Example #2
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 6 votes |
public static DoneableDeployment deployNewDeployment(Deployment deployment) { return new DoneableDeployment(deployment, co -> { TestUtils.waitFor("Deployment creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION, () -> { try { ResourceManager.kubeClient().createOrReplaceDeployment(co); return true; } catch (KubernetesClientException e) { if (e.getMessage().contains("object is being deleted")) { return false; } else { throw e; } } } ); return waitFor(deleteLater(co)); }); }
Example #3
Source File: DeploymentMockBuilder.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
@Override protected void mockCreate(String resourceName, RollableScalableResource<Deployment, DoneableDeployment> resource) { when(resource.create(any())).thenAnswer(invocation -> { checkNotExists(resourceName); Deployment deployment = invocation.getArgument(0); LOGGER.debug("create {} {} -> {}", resourceType, resourceName, deployment); deployment.getMetadata().setGeneration(Long.valueOf(0)); deployment.setStatus(new DeploymentStatusBuilder().withObservedGeneration(Long.valueOf(0)).build()); db.put(resourceName, copyResource(deployment)); for (int i = 0; i < deployment.getSpec().getReplicas(); i++) { String uuid = UUID.randomUUID().toString(); String podName = deployment.getMetadata().getName() + "-" + uuid; LOGGER.debug("create Pod {} because it's in Deployment {}", podName, resourceName); Pod pod = new PodBuilder() .withNewMetadataLike(deployment.getSpec().getTemplate().getMetadata()) .withUid(uuid) .withNamespace(deployment.getMetadata().getNamespace()) .withName(podName) .endMetadata() .withNewSpecLike(deployment.getSpec().getTemplate().getSpec()).endSpec() .build(); mockPods.inNamespace(deployment.getMetadata().getNamespace()).withName(podName).create(pod); podsForDeployments.compute(deployment.getMetadata().getName(), (deploymentName, podsInDeployment) -> { if (podsInDeployment == null) { podsInDeployment = new ArrayList<>(2); } podsInDeployment.add(podName); return podsInDeployment; }); } return deployment; }); }
Example #4
Source File: DeploymentRollingUpdater.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override protected void removeDeploymentKey(DoneableDeployment obj) { obj.editSpec() .editSelector().removeFromMatchLabels(DEPLOYMENT_KEY).endSelector() .editTemplate().editMetadata().removeFromLabels(DEPLOYMENT_KEY).endMetadata().endTemplate() .endSpec(); }
Example #5
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
@Override public DoneableDeployment edit() { if (isCascading()) { return cascading(false).edit(); } return super.edit(); }
Example #6
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 5 votes |
public DeploymentOperationsImpl(RollingOperationContext context) { super(context.withApiGroupName("apps") .withApiGroupVersion("v1") .withPlural("deployments")); this.type = Deployment .class; this.listType = DeploymentList.class; this.doneableType = DoneableDeployment.class; }
Example #7
Source File: WebServerController.java From java-operator-sdk with Apache License 2.0 | 5 votes |
@Override public boolean deleteResource(WebServer nginx) { log.info("Execution deleteResource for: {}", nginx.getMetadata().getName()); log.info("Deleting ConfigMap {}", configMapName(nginx)); Resource<ConfigMap, DoneableConfigMap> configMap = kubernetesClient.configMaps() .inNamespace(nginx.getMetadata().getNamespace()) .withName(configMapName(nginx)); if (configMap.get() != null) { configMap.delete(); } log.info("Deleting Deployment {}", deploymentName(nginx)); RollableScalableResource<Deployment, DoneableDeployment> deployment = kubernetesClient.apps().deployments() .inNamespace(nginx.getMetadata().getNamespace()) .withName(deploymentName(nginx)); if (deployment.get() != null) { deployment.cascading(true).delete(); } log.info("Deleting Service {}", serviceName(nginx)); ServiceResource<Service, DoneableService> service = kubernetesClient.services() .inNamespace(nginx.getMetadata().getNamespace()) .withName(serviceName(nginx)); if (service.get() != null) { service.delete(); } return true; }
Example #8
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment clusterOperator(String namespace) { return deployNewDeployment(defaultCLusterOperator(namespace, Constants.CO_OPERATION_TIMEOUT_DEFAULT, Constants.RECONCILIATION_INTERVAL).build()); }
Example #9
Source File: AppsAPIGroupClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public MixedOperation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> deployments() { return new DeploymentOperationsImpl(httpClient, getConfiguration()); }
Example #10
Source File: ExtensionsAPIGroupClient.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override @Deprecated public MixedOperation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> deployments() { return new DeploymentOperationsImpl(httpClient, getConfiguration()); }
Example #11
Source File: DeploymentRollingUpdater.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override protected Operation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> resources() { return new DeploymentOperationsImpl(client, config); }
Example #12
Source File: DeploymentRollingUpdater.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override protected void updateDeploymentKey(DoneableDeployment obj, String hash) { obj.editSpec() .editTemplate().editMetadata().addToAnnotations(DEPLOYMENT_KEY, hash).endMetadata().endTemplate() .endSpec(); }
Example #13
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public ImageEditReplacePatchable<Deployment, Deployment, DoneableDeployment> withTimeout(long timeout, TimeUnit unit) { return new DeploymentOperationsImpl(((RollingOperationContext)context).withRollingTimeUnit(unit)); }
Example #14
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public ImageEditReplacePatchable<Deployment, Deployment, DoneableDeployment> withTimeoutInMillis(long timeoutInMillis) { return new DeploymentOperationsImpl(((RollingOperationContext)context).withRollingTimeout(timeoutInMillis)); }
Example #15
Source File: DeploymentOperationsImpl.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public RollingUpdater<Deployment, DeploymentList, DoneableDeployment> getRollingUpdater(long rollingTimeout, TimeUnit rollingTimeUnit) { return new DeploymentRollingUpdater(client, config, getNamespace(), rollingTimeUnit.toMillis(rollingTimeout), config.getLoggingInterval()); }
Example #16
Source File: ExtensionsAPIGroupDSL.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Deprecated MixedOperation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> deployments();
Example #17
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment clusterOperator(String namespace, long operationTimeout, long reconciliationInterval) { return deployNewDeployment(defaultCLusterOperator(namespace, operationTimeout, reconciliationInterval).build()); }
Example #18
Source File: KubernetesResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment clusterOperator(String namespace, long operationTimeout) { return deployNewDeployment(defaultCLusterOperator(namespace, operationTimeout, Constants.RECONCILIATION_INTERVAL).build()); }
Example #19
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment deployKeycloak() { String keycloakName = "keycloak"; Map<String, String> keycloakLabels = new HashMap<>(); keycloakLabels.put("app", keycloakName); return KubernetesResource.deployNewDeployment(new DeploymentBuilder() .withNewMetadata() .withNamespace(ResourceManager.kubeClient().getNamespace()) .withLabels(keycloakLabels) .withName(keycloakName) .endMetadata() .withNewSpec() .withNewSelector() .withMatchLabels(keycloakLabels) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata() .withLabels(keycloakLabels) .endMetadata() .withNewSpec() .withContainers() .addNewContainer() .withName(keycloakName + "pod") .withImage("jboss/keycloak:8.0.1") .withPorts( new ContainerPortBuilder() .withName("http") .withContainerPort(8080) .build(), new ContainerPortBuilder() .withName("https") .withContainerPort(8443) .build() ) .addNewEnv() .withName("KEYCLOAK_USER") .withValue("admin") .endEnv() .addNewEnv() .withName("KEYCLOAK_PASSWORD") .withValue("admin") .endEnv() // for enabling importing authorization script .withArgs("-Dkeycloak.profile.feature.upload_scripts=enabled") .endContainer() .endSpec() .endTemplate() .endSpec() .build()); }
Example #20
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment kafkaStreamsWithTracing(String bootstrapServer) { String kafkaStreamsName = "hello-world-streams"; Map<String, String> kafkaStreamLabels = new HashMap<>(); kafkaStreamLabels.put("app", kafkaStreamsName); return KubernetesResource.deployNewDeployment(new DeploymentBuilder() .withNewMetadata() .withNamespace(ResourceManager.kubeClient().getNamespace()) .withLabels(kafkaStreamLabels) .withName(kafkaStreamsName) .endMetadata() .withNewSpec() .withNewSelector() .withMatchLabels(kafkaStreamLabels) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata() .withLabels(kafkaStreamLabels) .endMetadata() .withNewSpec() .withContainers() .addNewContainer() .withName(kafkaStreamsName) .withImage("strimzi/" + kafkaStreamsName + ":latest") .addNewEnv() .withName("BOOTSTRAP_SERVERS") .withValue(bootstrapServer) .endEnv() .addNewEnv() .withName("APPLICATION_ID") .withValue(kafkaStreamsName) .endEnv() .addNewEnv() .withName("SOURCE_TOPIC") .withValue("my-topic") .endEnv() .addNewEnv() .withName("TARGET_TOPIC") .withValue("cipot-ym") .endEnv() .addNewEnv() .withName("LOG_LEVEL") .withValue("INFO") .endEnv() .addNewEnv() .withName("JAEGER_SERVICE_NAME") .withValue(kafkaStreamsName) .endEnv() .addNewEnv() .withName("JAEGER_AGENT_HOST") .withValue("my-jaeger-agent") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_TYPE") .withValue("const") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_PARAM") .withValue("1") .endEnv() .endContainer() .endSpec() .endTemplate() .endSpec() .build()); }
Example #21
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment producerWithTracing(String bootstrapServer) { String producerName = "hello-world-producer"; Map<String, String> producerLabels = new HashMap<>(); producerLabels.put("app", producerName); return KubernetesResource.deployNewDeployment(new DeploymentBuilder() .withNewMetadata() .withNamespace(ResourceManager.kubeClient().getNamespace()) .withLabels(producerLabels) .withName(producerName) .endMetadata() .withNewSpec() .withNewSelector() .withMatchLabels(producerLabels) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata() .withLabels(producerLabels) .endMetadata() .withNewSpec() .withContainers() .addNewContainer() .withName(producerName) .withImage("strimzi/" + producerName + ":latest") .addNewEnv() .withName("BOOTSTRAP_SERVERS") .withValue(bootstrapServer) .endEnv() .addNewEnv() .withName("TOPIC") .withValue("my-topic") .endEnv() .addNewEnv() .withName("DELAY_MS") .withValue("1000") .endEnv() .addNewEnv() .withName("LOG_LEVEL") .withValue("INFO") .endEnv() .addNewEnv() .withName("MESSAGE_COUNT") .withValue("1000000") .endEnv() .addNewEnv() .withName("JAEGER_SERVICE_NAME") .withValue(producerName) .endEnv() .addNewEnv() .withName("JAEGER_AGENT_HOST") .withValue("my-jaeger-agent") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_TYPE") .withValue("const") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_PARAM") .withValue("1") .endEnv() .endContainer() .endSpec() .endTemplate() .endSpec() .build()); }
Example #22
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment consumerWithTracing(String bootstrapServer) { String consumerName = "hello-world-consumer"; Map<String, String> consumerLabels = new HashMap<>(); consumerLabels.put("app", consumerName); return KubernetesResource.deployNewDeployment(new DeploymentBuilder() .withNewMetadata() .withNamespace(ResourceManager.kubeClient().getNamespace()) .withLabels(consumerLabels) .withName(consumerName) .endMetadata() .withNewSpec() .withNewSelector() .withMatchLabels(consumerLabels) .endSelector() .withReplicas(1) .withNewTemplate() .withNewMetadata() .withLabels(consumerLabels) .endMetadata() .withNewSpec() .withContainers() .addNewContainer() .withName(consumerName) .withImage("strimzi/" + consumerName + ":latest") .addNewEnv() .withName("BOOTSTRAP_SERVERS") .withValue(bootstrapServer) .endEnv() .addNewEnv() .withName("TOPIC") .withValue("my-topic") .endEnv() .addNewEnv() .withName("GROUP_ID") .withValue("my-" + consumerName) .endEnv() .addNewEnv() .withName("DELAY_MS") .withValue("1000") .endEnv() .addNewEnv() .withName("LOG_LEVEL") .withValue("INFO") .endEnv() .addNewEnv() .withName("MESSAGE_COUNT") .withValue("1000000") .endEnv() .addNewEnv() .withName("JAEGER_SERVICE_NAME") .withValue(consumerName) .endEnv() .addNewEnv() .withName("JAEGER_AGENT_HOST") .withValue("my-jaeger-agent") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_TYPE") .withValue("const") .endEnv() .addNewEnv() .withName("JAEGER_SAMPLER_PARAM") .withValue("1") .endEnv() .endContainer() .endSpec() .endTemplate() .endSpec() .build()); }
Example #23
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment deployKafkaClients(boolean tlsListener, String kafkaClientsName, KafkaUser... kafkaUsers) { return deployKafkaClients(tlsListener, kafkaClientsName, true, kafkaUsers); }
Example #24
Source File: KafkaClientsResource.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public static DoneableDeployment deployKafkaClients(String kafkaClusterName) { return deployKafkaClients(false, kafkaClusterName, null); }
Example #25
Source File: DeploymentMockBuilder.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
public DeploymentMockBuilder(Map<String, Deployment> depDb, MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> mockPods) { super(Deployment.class, DeploymentList.class, DoneableDeployment.class, castClass(RollableScalableResource.class), depDb); this.mockPods = mockPods; }
Example #26
Source File: DeploymentOperator.java From strimzi-kafka-operator with Apache License 2.0 | 4 votes |
@Override protected MixedOperation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> operation() { return client.apps().deployments(); }
Example #27
Source File: AppsAPIGroupDSL.java From kubernetes-client with Apache License 2.0 | votes |
MixedOperation<Deployment, DeploymentList, DoneableDeployment, RollableScalableResource<Deployment, DoneableDeployment>> deployments();