-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps : Update Fabric8 Kubernetes Client to v6.10.0
Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
dff3ac5
commit 52407ff
Showing
6 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/io/fabric8/DeploymentAddEnvironmentVariablePodTemplateDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.fabric8; | ||
|
||
import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientBuilder; | ||
import io.fabric8.kubernetes.client.dsl.base.PatchContext; | ||
import io.fabric8.kubernetes.client.dsl.base.PatchType; | ||
|
||
public class DeploymentAddEnvironmentVariablePodTemplateDemo { | ||
public static void main(String[] args) { | ||
try (KubernetesClient client = new KubernetesClientBuilder().build()) { | ||
client.apps() | ||
.deployments() | ||
.inNamespace("default") | ||
.withName("jkube-spring-boot3-native-image-demo") | ||
.edit(d -> new DeploymentBuilder(d) | ||
.editSpec() | ||
.editTemplate() | ||
.editSpec() | ||
.editContainer(0) | ||
.addNewEnv() | ||
.withName("TEST_ENV_KEY") | ||
.withValue("TEST_ENV_VAL_UPDATED") | ||
.endEnv() | ||
.endContainer() | ||
.endSpec() | ||
.endTemplate() | ||
.endSpec() | ||
.build()); | ||
client.apps() | ||
.deployments() | ||
.inNamespace("default") | ||
.withName("jkube-spring-boot3-native-image-demo") | ||
.patch(PatchContext.of(PatchType.STRATEGIC_MERGE), | ||
"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"spring-boot\",\"env\":[{\"name\":\"PATCHED_ENV\", \"value\":\"PATCH_ENV_VAL_UPDATED\"}]}]}}}}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.fabric8; | ||
|
||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientBuilder; | ||
import io.fabric8.kubernetes.client.dsl.ExecWatch; | ||
import io.fabric8.kubernetes.client.dsl.PodResource; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
public class ExecWithPipesDemo { | ||
public static void main(String[] args) { | ||
try (KubernetesClient client = new KubernetesClientBuilder().build()) { | ||
PodResource podResource = client.pods() | ||
.inNamespace("default") | ||
.withName("exrf9fr"); | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); | ||
try (ExecWatch execWatch = podResource.writingOutput(baos).terminateOnError() | ||
.exec("sh", "-c", "ls -lrt /proc | wc -l")) { | ||
execWatch.exitCode().join(); | ||
} | ||
|
||
System.out.println("Result : " + baos); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.fabric8; | ||
|
||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientBuilder; | ||
|
||
public class RunDemo { | ||
public static void main(String[] args) { | ||
try (KubernetesClient client = new KubernetesClientBuilder().build()) { | ||
String namespace = "default"; | ||
String name = "run-config-example"; | ||
String image = "alpine:3.19.0"; | ||
|
||
client.run().inNamespace(namespace).withNewRunConfig() | ||
.withRestartPolicy("Never") | ||
.withName(name) | ||
.withImage(image) | ||
.withArgs("sh", "-c", "trap : TERM INT; sleep infinity & wait") | ||
.done(); | ||
System.out.println("Done"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters