- a well prepared kubernetes cluster. Follow the instructions to create a kubernetes cluster, or create a local kubernetes node referring to kind or minikube
- kustomize. Installed by the following command
curl -s "https://raw.githubusercontent.com/\
kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bashUpdate codes in dijob_types.go with your requirements, and generate deepcopy functions.
make generateGenerate new CRD files with the following command.
make manifestsNew CRD files will be generated in ./config/crd/bases
Referenced to controllers
Referenced to server
Run the following command in the project root directory.
# build images.
make docker-build
make docker-push
# deploy di-operator and server to cluster
make dev-deploySince the CustomResourceDefinitions are too long, you will probably find the following error:
The CustomResourceDefinition "dijobs.diengine.opendilab.org" is invalid: metadata.annotations: Too long: must have at most 262144 bytesThen running the following command will solve the problem:
kustomize build config/crd | kubectl create -f -di-operator and di-server will be installed in di-system namespace.
$ 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- Logger: logger should use
github.com/go-logr/logr.Logger, created fromsigs.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 debugging 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.
- Logger used in each function should be defined as: