- a well prepared kubernetes cluster. Follow the [instructions](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/) to create a kubernetes cluster, or create a local kubernetes node referring to [kind](https://kind.sigs.k8s.io/docs/user/quick-start/) or [minikube](https://minikube.sigs.k8s.io/docs/start/)
- a well prepared kubernetes cluster. Follow the[instructions](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/) to create a kubernetes cluster, or create a local kubernetes node referring to[kind](https://kind.sigs.k8s.io/docs/user/quick-start/) or[minikube](https://minikube.sigs.k8s.io/docs/start/)
- cert-manager. Installation on kubernetes referenced to [cert-manager docs](https://cert-manager.io/docs/installation/kubernetes/). Or you can install by the following command.
This project is based on [kubebuilder v3](https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.0.0/kubebuilder_linux_amd64), since CRDs generated by kubebuilder v2 is not compatible in kubernetes v1.20.
kubebuilder create api --group diengine --version v1alpha2 --kind DIJob
## CRD Design
kubebuilder create api --group diengine --version v1alpha2 --kind AggregatorConfig
```
Update codes in [dijob_types.go](./api/v1alpha2/dijob_types.go) with your requirements, and generate deepcopy functions.
## CRD Design
Make codes in [dijob_types.go](./api/v1alpha2/dijob_types.go) and [aggregatorconfig_types.go](./api/v1alpha2/aggregatorconfig.go) with your requirements, and generate deepcopy functions.
```bash
make generate
```
Generate new CRD files with the following command.
```bash
make manifests
```
New CRD files will be generated in [./config/crd/bases](./config/crd/bases)
## Controller Logic
Referenced to [controllers](./controllers)
## DI Server Logic
Referenced to [server](./server)
## Installation
Run the following command in the project root directory.
```bash
# build images.
make docker-build
...
...
@@ -48,26 +45,31 @@ make docker-push
# deploy di-operator and server to cluster
make dev-deploy
```
Since the CustomResourceDefinitions are too long, you will probably find the following error:
```bash
The CustomResourceDefinition "dijobs.diengine.opendilab.org" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
```
Then running the following command will solve the problem:
```bash
kustomize build config/crd | kubectl create -f -
```
`di-operator`, `di-webhook` and `di-server` will be installed in `di-system` namespace.
`di-operator` and `di-server` will be installed in `di-system` namespace.
```bash
$ kubectl get pod -n di-system
NAME READY STATUS RESTARTS AGE
di-operator-57cc65d5c9-5vnvn 1/1 Running 0 59s
di-server-7b86ff8df4-jfgmp 1/1 Running 0 59s
di-webhook-45jgi23fhc-9yght 1/1 Running 0 59s
```
Install global components of DIJob defined in AggregatorConfig:
- Logger: logger should use`github.com/go-logr/logr.Logger`, created from`sigs.k8s.io/controller-runtime/pkg/log.DelegatingLogger`. We have the following specifications
- Logger used in each function should be defined as:`logger := ctx.Log.WithName(function-name).WithValues("job", job-namespace-name))`. It's helpful for debuging since we can easily locate where the log message is from and what the DIJob is. Then, DIJob related information is not needed in log message.
- All the log message should start with lower case letter.