Skip to content

rohanKanojia/kubernetes-client-demo

Repository files navigation

Fabric8 Kubernetes Client Demo

Java CI with Maven License Twitter

This project contains various samples for different usages of Fabric8 Kubernetes Client. I generally use them in my blogs or for testing.

How to Build?

Just need to run mvn clean install to compile project

How to run a specific sample?

In order to run a sample, you need to be logged into a Kubernetes/OpenShift cluster. You can either use minikube or minishift if you don't have access to a remote cluster.

You can load project as maven project in your IDE and can run sample from IDE. You can also run it from maven using exec-maven-plugin. For example, here is how you would run DeploymentDemo:

mvn exec:java -Dexec.mainClass="io.fabric8.DeploymentDemo"

Fabric8 Code Generation samples

kubectl to Kubernetes Client Mapping:

kubectl Fabric8 Kubernetes Client
kubectl get pods PodListTest.java
kubectl get pods -w PodWatch.java
kubectl create pods PodDemo.java
kubectl create svc -f test-svc.yaml LoadAndCreateService.java
kubectl exec ExecDemo.java
kubectl delete pod test-pod1 PodDelete.java
kubectl create deploy DeploymentDemo.java
kubectl create -f customresource.yaml CustomResourceCreateDemo.java
kubectl create -f customresource.yaml CustomResourceCreateDemoTypeless.java
kubectl get ns NamespaceListDemo.java
kubectl create job JobCreate.java
kubectl logs job/pi JobFetchLogs.java
kubectl create -f test-list.yml CreateOrReplaceResourceList.java
kubectl create -f test-ing.yml CreateOrReplaceIngress.java
kubectl create validatingwebhookconfiguration ValidatingWebhookConfigurationTest.java
kubectl get events EventsExample.java
kubectl top nodes TopExample.java
kubectl auth can-i create deployment.apps CanITest.java
kubectl cp /foo_dir <some-pod>:/bar_dir UploadDirectoryToPod.java
kubectl cp <pod>:/tmp/foo /tmp/bar DownloadFileFromPod.java
kubectl cp <pod>:/tmp/foo -c c1 /tmp/bar DownloadFileFromMultiContainerPod.java
kubectl cp /foo_dir <pod>:/tmp/bar_dir UploadFileToPod.java
kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo-ctr-2","image": "redis"}]}}}}' PatchExamples.java

About

A Simple Java project demostrating usage of fabric8 kubernetes Java client

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published