Skip to content

Commit

Permalink
Set terminationGracePeriodSeconds to 0 to avoid waiting 30 seconds fo…
Browse files Browse the repository at this point in the history
…r pod termination.
  • Loading branch information
Vlatombe committed Jan 17, 2020
1 parent b9c2774 commit e5faa7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public Pod build() {
builder.withNodeSelector(nodeSelector);
}

builder.withTerminationGracePeriodSeconds(0L);
builder.withContainers(containers.values().toArray(new Container[containers.size()]));

Long runAsUser = template.getRunAsUserAsLong();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void configureCloud() throws Exception {
.withCommand("cat").withTty(true).withWorkingDir("/home/jenkins/agent1").build();
String podName = "test-command-execution-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789");
pod = client.pods().create(new PodBuilder().withNewMetadata().withName(podName)
.withLabels(getLabels(this, name)).endMetadata().withNewSpec().withContainers(c, d).withNodeSelector(Collections.singletonMap("kubernetes.io/os", "linux")).endSpec().build());
.withLabels(getLabels(this, name)).endMetadata().withNewSpec().withContainers(c, d).withNodeSelector(Collections.singletonMap("kubernetes.io/os", "linux")).withTerminationGracePeriodSeconds(0L).endSpec().build());

System.out.println("Created pod: " + pod.getMetadata().getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ spec:
labels:
app: cascading-delete
spec:
terminationGracePeriodSeconds: 0
containers:
- name: ubuntu
image: ubuntu
Expand Down

0 comments on commit e5faa7f

Please sign in to comment.