Repository navigation
Releases: sayed-imran/microservice-operator
Release list
v2.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 and all sits behind a proxy. This operator automates the process of deploying as Kubernetes Deployment and exposing the same as a Kubernetes service and also putting the same behind a proxy using Istio's VirtualService and Gateway.
Contents
Prerequisites
As the operator uses Istio's VirtualService and Gateway, the Istio service mesh needs to be installed in the Kubernetes cluster. Refer to the Istio documentation for installation instructions.
Operator Installation
Clone the repository and change directory to the repository:
git clone https://github.com/Sayed-Imran/microservice-operator.git
cd microservice-operatorSingle command to install the operator:
kubectl apply -k manifests/install/Usage
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
path: /api/v1/
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, will create a Kubernetes Service to expose the deployment over port 7000, and will put microservice behind proxy /api/v1/. 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.
Development
To start developing the operator, the following steps can be followed:
- Clone the repository:
git clone https://github.com/Sayed-Imran/microservice-operator.git- Change directory to the repository:
cd microservice-operator- Install the dependencies:
pip install -r requirements.txt- Run the operator:
kopf run main.py --verbosev1.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.