Naiserator
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:
Deployment
that runs a specified number of application instancesService
which points to the application endpointHorizontal pod autoscaler
for automatic application scalingService account
for granting correct permissions to managed resources
Optionally, if enabled in the application manifest, the following resources:
Ingress
adding TLS termination and virtualhost support- Leader election sidecar which decides a cluster leader from available pods. This feature also creates a
Role
andRole binding
.
If Istio support is enabled with --features.access-policy
:
NetworkPolicy
- A set of
VirtualService
ServiceRole
andServiceRoleBinding
resourcesServiceEntry
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.
Documentation
The entire specification for the manifest is documented in our doc.nais.io.
Deployment
- Kubernetes v1.11.0 or later
Installation
You can deploy the most recent release of Naiserator by applying to your cluster:
kubectl apply -f hack/resources/
Development
- 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
Kafka & Protobuf
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.
Update and compile Protobuf definition
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.
Code generation
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"
controller-gen
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.1
. Download with
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.1