This folder contains code to generate the KRE Operator that follows the kubernetes operator pattern
The KRE Operator will be deployed within the namespace of each Runtime. This is created by the K8s Manager
service, that is running in the Engine.
-
Runtime: This object generates the needed infrastructure containers used by the RuntimeVersions. example: mongo, nats and minio.
-
RuntimeVersion (TODO): This object generate all the containers needed to perform the inference of an AI/ML model.
This operator is handled by the operator-sdk
and is helm based and the templates are located inside helm-charts
folder.
To start the operator for development you need to create all the necessary permissions and then start the operator with the operator-sdk
.
You need to have operator-sdk
installed on your system to develop this operator. See operator-sdk helm guide
In order to deploy this operator you need to create the following resources in your Kuberentes cluster:
-
CRD (Custom Resource Definition)
To add the features of this operator to your cluster need to extend the Kuberentes API, this can be done with CRD object. Run the following command to create it.
kubectl create -f deploy/crds/kre.konstellation.io_runtimes_crd.yaml
-
RBAC (Role Based Access Control)
We need to define the required permission within the cluster to perform the requied action. There are a definition of the Roles needed that we have to apply to our Namemspace. Following are listed the required commands to create the
Role
,ServiceAccount
andRoleBinding
objects.kubectl create -f deploy/role.yaml kubectl create -f deploy/service_account.yaml kubectl create -f deploy/role_binding.yaml
To start development of the operator follow this steps:
-
Make a symlink to the chart:
sudo ln -s $PWD/helm-charts/kre-chart /opt/helm/helm-charts/kre-chart
-
Start the operator controller locally:
operator-sdk up local --namespace SOME_NAMESPACE
-
Create the CRD on the cluster:
kubectl apply -f deploy/crds/kre.konstellation.io_runtimes_crd.yaml
-
Test the operator by creating a new
Runtime
resource:kubectl -n SOME_NAMESPACE apply -f deploy/crds/kre.konstellation.io_v1alpha1_runtime_cr.yaml
-
Now you can check the resources are created inside that namespace
kubectl -n SOME_NAMESPACE get pods # sample output NAME READY STATUS RESTARTS AGE kre-minio-0 0/1 Running 0 8s kre-mongo-0 1/1 Running 0 8s kre-nats-0 1/1 Running 0 8s kre-nats-1 1/1 Running 0 8s