Skip to content

Commit

Permalink
Merge pull request #70 from st-tech/feature/update-k8s-client-5-12-1
Browse files Browse the repository at this point in the history
update k8s client version in v0.10.4_pathced branch to 5.12.1
  • Loading branch information
kyoppii13 authored Mar 10, 2022
2 parents 46809cf + c758d2f commit 691d5ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion digdag-standards/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
}

// kubernetes
compile ('io.fabric8:kubernetes-client:4.6.2') {
compile ('io.fabric8:kubernetes-client:5.12.1') {
// Avoid compilation failures due to dependencies
exclude group: 'org.slf4j', module: 'slf4j-api'
// TODO: digdag use version 3.12.0, upgrade to version 3.12.6.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
import io.digdag.spi.CommandRequest;
import io.digdag.spi.TaskRequest;
import io.fabric8.kubernetes.api.model.Affinity;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.ContainerBuilder;
import io.fabric8.kubernetes.api.model.ContainerStatus;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
import io.fabric8.kubernetes.api.model.PodBuilder;
import io.fabric8.kubernetes.api.model.PodSpec;
import io.fabric8.kubernetes.api.model.PodSpecBuilder;
import io.fabric8.kubernetes.api.model.ResourceRequirements;
import io.fabric8.kubernetes.api.model.Toleration;
import io.fabric8.kubernetes.api.model.Volume;
import io.fabric8.kubernetes.api.model.VolumeMount;
import io.fabric8.kubernetes.api.model.PersistentVolume;
import io.fabric8.kubernetes.api.model.PersistentVolumeBuilder;
import io.fabric8.kubernetes.api.model.PersistentVolumeSpec;
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim;
import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder;
import io.fabric8.kubernetes.api.model.PersistentVolumeClaimSpec;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.utils.Serialization;
Expand Down Expand Up @@ -68,15 +72,16 @@ public Pod runPod(final CommandContext context, final CommandRequest request,
final Config kubernetesPodConfig = extractTargetKindConfig(context, "Pod");
final Container container = createContainer(context, request, kubernetesPodConfig, name, commands, arguments);
final PodSpec podSpec = createPodSpec(context, request, kubernetesPodConfig, container);
io.fabric8.kubernetes.api.model.Pod pod = client.pods()
.createNew()
.withNewMetadata()
.withName(name)
.withNamespace(client.getNamespace())
.withLabels(getPodLabels())
.endMetadata()
.withSpec(podSpec)
.done();
final io.fabric8.kubernetes.api.model.Pod pod = client.pods().inNamespace(client.getNamespace()).create(
new PodBuilder()
.withNewMetadata()
.withName(name)
.withLabels(getPodLabels())
.withNamespace(client.getNamespace())
.endMetadata()
.withSpec(podSpec)
.build()
);
return Pod.of(pod);
}

Expand Down Expand Up @@ -180,13 +185,15 @@ protected PersistentVolume createPersistentVolume(final CommandContext context)
final Config kubernetesPvConfig = extractTargetKindConfig(context, "PersistentVolume");
if (kubernetesPvConfig != null && kubernetesPvConfig.has("spec"))
return client.persistentVolumes()
.createOrReplaceWithNew()
.withNewMetadata()
.withName(kubernetesPvConfig.get("name", String.class))
.withNamespace(client.getNamespace())
.endMetadata()
.withSpec(getPersistentVolume(kubernetesPvConfig.get("spec", Config.class)))
.done();
.createOrReplace(
new PersistentVolumeBuilder()
.withNewMetadata()
.withName(kubernetesPvConfig.get("name", String.class))
.withNamespace(client.getNamespace())
.endMetadata()
.withSpec(getPersistentVolume(kubernetesPvConfig.get("spec", Config.class)))
.build()
);
else
return null;
}
Expand All @@ -196,13 +203,16 @@ protected PersistentVolumeClaim createPersistentVolumeClaim(final CommandContext
final Config kubernetesPvcConfig = extractTargetKindConfig(context, "PersistentVolumeClaim");
if (kubernetesPvcConfig != null && kubernetesPvcConfig.has("spec"))
return client.persistentVolumeClaims()
.createOrReplaceWithNew()
.withNewMetadata()
.withName(kubernetesPvcConfig.get("name", String.class))
.withNamespace(client.getNamespace())
.endMetadata()
.withSpec(getPersistentVolumeClaim(kubernetesPvcConfig.get("spec", Config.class)))
.done();
.createOrReplace(
new PersistentVolumeClaimBuilder()
.withNewMetadata()
.withName(kubernetesPvcConfig.get("name", String.class))
.withNamespace(client.getNamespace())
.endMetadata()
.withSpec(getPersistentVolumeClaim(kubernetesPvcConfig.get("spec", Config.class)))
.build()

);
else
return null;
}
Expand Down

0 comments on commit 691d5ee

Please sign in to comment.