Refine search
@Override public Deployment transform(Deployment deployment, io.logz.apollo.models.Deployment apolloDeployment, Service apolloService, Environment apolloEnvironment, DeployableVersion apolloDeployableVersion, Group group) { // TODO: This should probably be an externally configured map of key names and desired dynamic values // TODO: Keeping this logz.io specific at the moment Map<String, String> desiredEnvironmentVariables = ImmutableMap.<String, String> builder() .put("ENV", apolloEnvironment.getAvailability()) .put("REGION", apolloEnvironment.getGeoRegion()) .build(); deployment.getSpec().getTemplate().getSpec().getContainers().forEach(container -> { List<EnvVar> envVarList = container.getEnv(); desiredEnvironmentVariables.forEach((key, value) -> { // Do not override values supplied externally if (envVarList.stream().noneMatch(envVar -> envVar.getName().equals(key))) { envVarList.add(new EnvVar(key, value, null)); } }); container.setEnv(envVarList); }); return deployment; } }
public DeploymentSpecBuilder(DeploymentSpecFluent<?> fluent,Boolean validationEnabled){ this(fluent, new DeploymentSpec(), validationEnabled); } public DeploymentSpecBuilder(DeploymentSpecFluent<?> fluent,DeploymentSpec instance){
public void run() { try { Deployment deployment = get(); //If the deployment is gone, we shouldn't wait. if (deployment == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for Deployment: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deployment.getStatus().getReplicas()); int currentReplicas = deployment.getStatus().getReplicas() != null ? deployment.getStatus().getReplicas() : 0; long generation = deployment.getMetadata().getGeneration() != null ? deployment.getMetadata().getGeneration() : 0; long observedGeneration = deployment.getStatus() != null && deployment.getStatus().getObservedGeneration() != null ? deployment.getStatus().getObservedGeneration() : -1; if (observedGeneration >= generation && Objects.equals(deployment.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for Deployment: {} in namespace: {} seconds so waiting...", deployment.getStatus().getReplicas(), deployment.getSpec().getReplicas(), deployment.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } } };
public DeploymentSpecBuilder(DeploymentSpec instance,Boolean validationEnabled){ this.fluent = this; this.withMinReadySeconds(instance.getMinReadySeconds()); this.withPaused(instance.getPaused()); this.withReplicas(instance.getReplicas()); this.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); this.withRollbackTo(instance.getRollbackTo()); this.withSelector(instance.getSelector()); this.withStrategy(instance.getStrategy()); this.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; }
Map<String, String> labelsFromDeployment = deployment.getMetadata().getLabels(); deployment.getMetadata().setLabels(labelsFromDeployment); Map<String, String> labelsFromDeploymentPod = deployment.getSpec().getTemplate().getMetadata().getLabels(); labelsFromDeploymentPod.put(ApolloToKubernetes.getApolloDeploymentUniqueIdentifierKey(), ApolloToKubernetes.getApolloPodUniqueIdentifier(apolloEnvironment, apolloService, Optional.ofNullable(apolloDeployment.getGroupName()))); deployment.getSpec().getTemplate().getMetadata().setLabels(labelsFromDeploymentPod);
public static boolean isDeploymentReady(Deployment d) { Utils.checkNotNull(d, "Deployment can't be null."); DeploymentSpec spec = d.getSpec(); DeploymentStatus status = d.getStatus(); if (status == null || status.getReplicas() == null || status.getAvailableReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReplicas() && spec.getReplicas().intValue() <= status.getAvailableReplicas(); }
@Override public boolean reap() { Deployment deployment = oper.cascading(false).edit().editSpec().withReplicas(0).endSpec().done(); waitForObservedGeneration(deployment.getStatus().getObservedGeneration()); reapMatchingReplicaSets(deployment.getSpec().getSelector()); return false; }
labels = normalizeLabels(labels); final Deployment deployment = new Deployment(); metadata.setName(normalizeDeploymentName(deploymentName)); metadata.setLabels(labels); deployment.setMetadata(metadata); deployment.setSpec(this.createDeploymentSpec(labels, final boolean verifyTls) { final DeploymentSpec deploymentSpec = new DeploymentSpec(); final PodTemplateSpec podTemplateSpec = new PodTemplateSpec(); final ObjectMeta metadata = new ObjectMeta(); deploymentSpec.setTemplate(podTemplateSpec); return deploymentSpec;
@Override public void adapt(KubernetesListBuilder builder) { super.adapt(builder); List<HasMetadata> items = builder.getItems(); for (HasMetadata item : items) { if (item instanceof Deployment) { Deployment deployment = (Deployment) item; ObjectMeta metadata = deployment.getMetadata(); DeploymentSpec spec = deployment.getSpec(); if (metadata != null && spec != null) { PodTemplateSpec template = spec.getTemplate(); if (template != null) { ObjectMeta templateMetadata = template.getMetadata(); if (templateMetadata == null) { templateMetadata = new ObjectMeta(); template.setMetadata(templateMetadata); } templateMetadata.setAnnotations(MapUtil.mergeMaps(templateMetadata.getAnnotations(), metadata.getAnnotations())); } } } } builder.withItems(items); } }
public DeploymentSpecBuilder(DeploymentSpecFluent<?> fluent,DeploymentSpec instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withMinReadySeconds(instance.getMinReadySeconds()); fluent.withPaused(instance.getPaused()); fluent.withReplicas(instance.getReplicas()); fluent.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); fluent.withRollbackTo(instance.getRollbackTo()); fluent.withSelector(instance.getSelector()); fluent.withStrategy(instance.getStrategy()); fluent.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; } public DeploymentSpecBuilder(DeploymentSpec instance){
labels = normalizeLabels(labels); final Deployment deployment = new Deployment(); metadata.setName(normalizeDeploymentName(deploymentName)); metadata.setLabels(labels); deployment.setMetadata(metadata); deployment.setSpec(this.createDeploymentSpec(labels, final boolean verifyTls) { final DeploymentSpec deploymentSpec = new DeploymentSpec(); final PodTemplateSpec podTemplateSpec = new PodTemplateSpec(); final ObjectMeta metadata = new ObjectMeta(); deploymentSpec.setTemplate(podTemplateSpec); return deploymentSpec;
deployment.getSpec().getTemplate().getSpec().getContainers().forEach(container -> {
public DeploymentSpecFluentImpl(DeploymentSpec instance){ this.withMinReadySeconds(instance.getMinReadySeconds()); this.withPaused(instance.getPaused()); this.withReplicas(instance.getReplicas()); this.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); this.withRollbackTo(instance.getRollbackTo()); this.withSelector(instance.getSelector()); this.withStrategy(instance.getStrategy()); this.withTemplate(instance.getTemplate()); }
public DeploymentSpecBuilder(Boolean validationEnabled){ this(new DeploymentSpec(), validationEnabled); } public DeploymentSpecBuilder(DeploymentSpecFluent<?> fluent){
if (resourceType.equals(KubernetesResource.DEPLOYMENT)) { Deployment deployment = (Deployment) metadata; labels = deployment.getSpec().getTemplate().getMetadata().getLabels(); } else if (resourceType.equals(KubernetesResource.REPLICATION_CONTROLLER)) { ReplicationController replicationController = (ReplicationController) metadata;
public DeploymentSpec build(){ DeploymentSpec buildable = new DeploymentSpec(fluent.getMinReadySeconds(),fluent.isPaused(),fluent.getReplicas(),fluent.getRevisionHistoryLimit(),fluent.getRollbackTo(),fluent.getSelector(),fluent.getStrategy(),fluent.getTemplate()); validate(buildable); return buildable; }
private boolean enableDebug(HasMetadata entity) { if (entity instanceof Deployment) { Deployment resource = (Deployment) entity; DeploymentSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicaSet) { ReplicaSet resource = (ReplicaSet) entity; ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicationController) { ReplicationController resource = (ReplicationController) entity; ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) entity; DeploymentConfigSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } return false; }
private boolean enableDebug(HasMetadata entity) { if (entity instanceof Deployment) { Deployment resource = (Deployment) entity; DeploymentSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicaSet) { ReplicaSet resource = (ReplicaSet) entity; ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicationController) { ReplicationController resource = (ReplicationController) entity; ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) entity; DeploymentConfigSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } return false; }
final DeploymentSpec spec = deployHandler.getDeployment(config, images).getSpec(); if (spec != null) { builder.accept(new TypedVisitor<DeploymentBuilder>() { if (spec.getTemplate() != null && spec.getTemplate().getSpec() != null) { final PodSpec podSpec = spec.getTemplate().getSpec(); builder.accept(new TypedVisitor<PodSpecBuilder>() { @Override
final String serverTillerImage = resource.get().getSpec().getTemplate().getSpec().getContainers().get(0).getImage(); assert serverTillerImage != null;