Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rohankanojia/kubernetes-client-demo
A Simple Java project demostrating usage of fabric8 kubernetes Java client
https://github.com/rohankanojia/kubernetes-client-demo
fabric8 fabric8-kubernetes-client java kubernetes
Last synced: about 2 months ago
JSON representation
A Simple Java project demostrating usage of fabric8 kubernetes Java client
- Host: GitHub
- URL: https://github.com/rohankanojia/kubernetes-client-demo
- Owner: rohanKanojia
- License: apache-2.0
- Created: 2018-01-04T07:41:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-13T14:31:52.000Z (4 months ago)
- Last Synced: 2024-10-23T09:58:30.965Z (2 months ago)
- Topics: fabric8, fabric8-kubernetes-client, java, kubernetes
- Language: Java
- Homepage: https://github.com/fabric8io/kubernetes-client
- Size: 330 KB
- Stars: 27
- Watchers: 3
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# Fabric8 Kubernetes Client Demo
![Java CI with Maven](https://github.com/rohanKanojia/kubernetes-client-demo/workflows/Java%20CI%20with%20Maven/badge.svg)
![License](https://img.shields.io/github/license/rohanKanojia/kubernetes-client-demo)
[![Twitter](https://img.shields.io/twitter/follow/fabric8io?style=social)](https://twitter.com/fabric8io)This project contains various samples for different usages of [Fabric8 Kubernetes Client](https://github.com/fabric8io/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
- [CRD YAML -> Java POJO](./fabric8-crd-java-generator-demo/README.md)
- [Java POJO -> CRD YAML](./fabric8-java-crd-yaml-generator-demo/README.md)### [Writing Tests Using Fabric8 Kubernetes Client](./writing-tests-with-fabric8/README.md)
### `kubectl` to Kubernetes Client Mapping:
| kubectl | Fabric8 Kubernetes Client |
| ---------------------------------------------- | ------------------------------------- |
| `kubectl get pods` | [PodListTest.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/PodListTest.java) |
| `kubectl get pods -w` | [PodWatch.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/PodWatch.java) |
| `kubectl create pods` | [PodDemo.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/PodDemo.java) |
| `kubectl create svc -f test-svc.yaml` | [LoadAndCreateService.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/LoadAndCreateService.java) |
| `kubectl exec` | [ExecDemo.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/ExecDemo.java) |
| `kubectl delete pod test-pod1` | [PodDelete.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/PodDelete.java) |
| `kubectl create deploy` | [DeploymentDemo.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/DeploymentDemo.java) |
| `kubectl create -f customresource.yaml` | [CustomResourceCreateDemo.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/CustomResourceCreateDemo.java) |
| `kubectl create -f customresource.yaml` | [CustomResourceCreateDemoTypeless.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/CustomResourceCreateDemoTypeless.java) |
| `kubectl get ns` | [NamespaceListDemo.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/NamespaceListDemo.java) |
| `kubectl create job` | [JobCreate.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/JobCreate.java) |
| `kubectl logs job/pi` | [JobFetchLogs.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/JobFetchLogs.java) |
| `kubectl create -f test-list.yml` | [CreateOrReplaceResourceList.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/CreateOrReplaceResourceList.java) |
| `kubectl create -f test-ing.yml` | [CreateOrReplaceIngress.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/CreateOrReplaceIngress.java) |
| `kubectl create validatingwebhookconfiguration`| [ValidatingWebhookConfigurationTest.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/ValidatingWebhookConfigurationTest.java)
| `kubectl get events` | [EventsExample.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/EventsExample.java) |
| `kubectl top nodes` | [TopExample.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/TopExample.java) |
| `kubectl auth can-i create deployment.apps` | [CanITest.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/CanITest.java) |
| `kubectl cp /foo_dir :/bar_dir` | [UploadDirectoryToPod.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/UploadDirectoryToPod.java) |
| `kubectl cp :/tmp/foo /tmp/bar` | [DownloadFileFromPod.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/DownloadFileFromPod.java) |
| `kubectl cp :/tmp/foo -c c1 /tmp/bar` | [DownloadFileFromMultiContainerPod.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/DownloadFileFromMultiContainerPod.java) |
| `kubectl cp /foo_dir :/tmp/bar_dir` | [UploadFileToPod.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/UploadFileToPod.java) |
| `kubectl patch deployment patch-demo --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo-ctr-2","image": "redis"}]}}}}'` | [PatchExamples.java](https://github.com/rohanKanojia/kubernetes-client-demo/blob/master/src/main/java/io/fabric8/PatchExamples.java) |