Naiserator is a Kubernetes operator that handles the lifecycle of the custom resource nais.io/Application.
The main goal of Naiserator is to simplify application deployment by providing a high-level abstraction tailored for the NAIS platform.
Naiserator supersedes naisd.
When an Application resource is created in Kubernetes,
Naiserator will generate several resources that work together to form a complete deployment:
Deploymentthat runs a specified number of application instancesServicewhich points to the application endpointHorizontal pod autoscalerfor automatic application scalingService accountfor granting correct permissions to managed resources
Optionally, if enabled in the application manifest, the following resources:
Ingressadding TLS termination and virtualhost support- Leader election sidecar which decides a cluster leader from available pods. This feature also creates a
RoleandRole binding.
These resources will remain in Kubernetes until the Application resource is deleted.
Any unneeded resources will be automatically deleted if disabled by feature flags or is lacking in a application manifest.
The entire specification for the manifest is documented in our doc.nais.io.
- Kubernetes v1.11.0 or later
You can deploy the most recent release of Naiserator by applying to your cluster:
kubectl apply -f hack/resources/
- The Go programming language, version 1.11 or later
- goimports
- Docker Desktop or other Docker release compatible with Kubernetes
- Kubernetes, either through minikube or a local cluster
Go modules
are used for dependency tracking. Make sure you do export GO111MODULE=on before running any Go commands.
It is no longer needed to have the project checked out in your $GOPATH.
kubectl apply -f ../liberator/config/crd
kubectl apply -f ./hack/resources
make local
Whenever an Application is synchronized, a deployment event message can be sent to a Kafka topic. There's a few prerequisites to develop with this enabled locally:
- Protobuf installed
- An instance of kafka to test against. Use
docker-compose upto bring up a local instance. - Enable this feature by passing
-kafka-enabled=truewhen starting Naiserator.
Whenever the Protobuf definition is updated you can update using make proto. It will download the definitions, compile
and place them in the correct packages.
In order to use the Kubernetes Go library, we need to use classes that work together with the interfaces in that library. Those classes are mostly boilerplate code, and to ensure healthy and happy developers, we use code generators for that.
When the CRD changes, or additional Kubernetes resources need to be generated, you have to run code generation:
make crd
make codegen-crd
make codegen-updater
git add -A
git commit -a -m "Update boilerplate k8s API code"
The tool controller-gen is used by make crd to generate a CRD YAML file using the Go type specifications in
pkg/apis/nais.io/v1alpha1/*_types.go. This YAML file should not be edited by hand. Any changes needed should
go directly into the Go file as magic annotations.
The CRD spec will be generated in config/crd/nais.io_applications.yaml.
Check out the controller-gen documentation if unsure.
A known working version of controller-gen is v0.2.5. Download with
GO111MODULE=off go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5