Repository navigation
v1.0.0
Microservice Operator
This operator is a Kubernetes operator that manages microservices. It is built using the kopf framework, which is a Python framework for Kubernetes operators.
Any microservice API which is developed, needs to be deployed and exposed as a Kubernetes service. This operator automates the process of deploying as Kubernetes Deployment and exposing the same as a Kubernetes service.
Contents
Installation
For the operator to be installed, the crd needs to be installed first. The crd can be installed using the following command:
kubectl apply -f https://raw.githubusercontent.com/Sayed-Imran/microservice-operator/main/crd.ymlTo install the operator, the following command can be used:
kubectl apply -f https://raw.githubusercontent.com/Sayed-Imran/microservice-operator/main/deploy.ymlUsage
The operator can be used by creating a custom resource of kind Microservice. The following is an example of a custom resource:
apiVersion: imran.dev.io/v1alpha1
kind: Microservice
metadata:
name: micron
spec:
labels:
app: microservice-sample
env: dev
replicas: 3
image: sayedimran/fastapi-sample-app:v4
port: 7000
env:
- name: ENV
value: dev
- name: LOG_LEVEL
value: debug
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128MiThe above custom resource will create a deployment with 3 replicas and expose the same as a service. The deployment will use the image sayedimran/fastapi-sample-app:v4 and will expose the service on port 7000. The environment variables ENV and LOG_LEVEL will be set to dev and debug respectively. The resources for the deployment will be limited to 100m CPU and 128Mi memory and the requests will be the same.