GithubHelp home page GithubHelp logo

shailendra14k / podsetoperatorinjava Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rohankanojia/podsetoperatorinjava

0.0 1.0 0.0 26 KB

Java Implementation of https://github.com/hrishin/podset-operator using Fabric8 Kubernetes Client

License: Apache License 2.0

Java 100.00%

podsetoperatorinjava's Introduction

PodSet Operator in Java Using Fabric8 Kubernetes Client

This is a demo operator which implements a simple operator for a custom resource called PodSet which is somewhat equal to ReplicaSet. Here is what this resource looks like:

apiVersion: demo.k8s.io/v1alpha1
kind: PodSet
metadata:
  name: example-podset
  spec:
    replicas: 5

Each PodSet object would have 'x' number of replicas, so this operator just tries to maintain x number of replicas checking whether that number of pods are running in cluster or not.

How to Build

   mvn clean install

How to Run

   mvn exec:java -Dexec.mainClass=io.fabric8.podset.operator.PodSetOperatorMain

Make Sure that PodSet Custom Resource Definition is already applied onto the cluster. If not, just apply it using this command:

kubectl apply -f src/main/resources/crd.yaml

Once everything is set, you can see that operator creating pods in your cluster for PodSet resource: Demo Screenshot

Deploying onto Kubernetes(minikube) using Eclipse JKube

  • Make Sure that PodSet Custom Resource Definition is already applied onto the cluster. If not, just apply it using this command:
kubectl apply -f src/main/resources/crd.yaml
  • Make sure that you have given correct privileges to ServiceAccount that would be used by the Pod, it's default in our case. Otherwise you might get 403 from Kubernetes API server.
kubectl create clusterrolebinding default-pod --clusterrole cluster-admin --serviceaccount=default:default

# In case of some other namespace:
kubectl create clusterrolebinding default-pod --clusterrole cluster-admin --serviceaccount=<namespace>:default
  • Build Docker Image
mvn k8s:build

JKube Build Docker Image

  • Generate Kubernetes Manifests
mvn k8s:resource

JKube Generate Kubernetes Manifests

  • Apply generated Kubernetes Manifests onto Kubernetes
mvn k8s:apply

Once generated resources are applied, try creating one of PodSet objects in src/main/resources

kubectl apply -f src/main/resources/cr.yaml

JKube Apply Generated Kubernetes Manifests

podsetoperatorinjava's People

Contributors

rohankanojia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.