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 (see
example application),
Naiserator will generate several resources that work together to form a complete deployment:
Deployment
that runs a specified number of application instances,Service
which points to the application endpoint,Ingress
adding TLS termination and virtualhost support,Horizontal pod autoscaler
for automatic application scaling,Service account
for granting correct permissions to managed resources.
These resources will remain in Kubernetes until the Application
resource is deleted.
The entire specification for the manifest is documented in our nais.io/doc.
- 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 config
kubectl apply -f examples/nais.yaml
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 up
to bring up a local instance. - Enable this feature by passing
-kafka-enabled=true
when 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.
Check out the controller-gen documentation if unsure.
A known working version of controller-gen is v0.2.0-beta.3
.