- Notifications
You must be signed in to change notification settings - Fork3
Kubernetes Operator for Unleash feature toggle service
License
nais/unleasherator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Kubernetes operator for managingUnleash - the open-source feature toggle service.
It has support for creating and managing Unleash instances and API tokens across multiple clusters or environments and only depends on Kubernetes native resources.
Used in production at the Norwegian Labour and Welfare Administration (NAV).
graph LR postgres[PostgreSQL] subgraph Kubernetes subgraph unleasherator-system unleasherator[Unleasherator] end subgraph my-namespace unleash[Unleash] apiToken[ApiToken] tokenSecret[Secret] deployment[Deployment] end end unleasherator -- manages --> unleash unleasherator -- manages --> apiToken apiToken -..- unleash apiToken -..-> tokenSecret unleash -- uses --> postgres tokenSecret -..-> deployment
Unleasherator is a Kubernetes operator for managing Unleash instances and API tokens across multiple clusters or environments. It is built using theKubebuilder framework and is cloud and infrastructure agnostic.
You'll find the documentation for various Unleash resources in thedocs directory.
The following example can be used withbitnami/postgresql helm chart to create an Unleash instance with a local postgresql database.
apiVersion:unleash.nais.io/v1kind:Unleashmetadata:name:unleashspec:size:1database:secretName:postgres-postgresqlsecretPassKey:postgres-passwordhost:postgres-postgresqldatabaseName:postgresport:"5432"user:postgresssl:"false"networkPolicy:enabled:trueallowDNS:trueextraEgressRules: -to: -podSelector:matchLabels:app.kubernetes.io/name:postgresqlports: -protocol:TCPport:5432
Sequence of events:
sequenceDiagram participant Unleasherator participant Kubernetes participant Unleash Unleasherator->>Kubernetes: Create Unleash secret Unleasherator->>Kubernetes: Create Unleash deployment Kubernetes->>Unleash: Start Unleash Unleasherator->>Kubernetes: Create Unleash service Unleasherator->>Kubernetes: Create Unleash ingress Unleasherator->>Kubernetes: Create Unleash network policy Unleasherator->>Unleash: Test connection
You can find more examples in theconfig/samples directory.
You’ll need a Kubernetes cluster to run against. You can useKIND to get a local cluster for testing, or run against a remote cluster.
Note: Your controller will automatically use the current context in your kubeconfig file (i.e. whatever clusterkubectl cluster-info
shows).
- Install Instances of Custom Resources:
kubectl apply -f config/samples/
- Build and push your image to the location specified by
IMG
:
make docker-build docker-push IMG=<some-registry>/unleasherator:tag
- Deploy the controller to the cluster with the image specified by
IMG
:
make deploy IMG=<some-registry>/unleasherator:tag
To delete the CRDs from the cluster:
make uninstall
UnDeploy the controller to the cluster:
make undeploy
Contributions are welcome! Please seeCONTRIBUTING.md for more info.
This project aims to follow the KubernetesOperator pattern
It usesControllerswhich provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster
- Install the CRDs into the cluster:
make install
- Run the controller in your cluster:
Since the controller needs to reach the Unleash instance it can not run locally, but must be deployed to the cluster.
make docker-build deploy logs
If you are editing the API definitions, generate the manifests such as CRs or CRDs, and corresponding Helm charts using:
make generate manifests helm
NOTE: Runmake --help
for more information on all potentialmake
targets
More information can be found via theKubebuilder Documentation
There's prometheus metrics coveringhttps://book.kubebuilder.io/reference/metrics-reference.html the default set of kubebuilder provided performance gauges as well as additional metrics for deployment status.
Metric | Type | Description |
---|---|---|
unleasherator_unleash_status | Gauge | Status of Unleash instances |
unleasherator_remoteunleash_status | Gauge | Status of RemoteUnleash instances |
unleasherator_api_token_status | Gauge | Status of ApiToken instances |
unleasherator_api_token_deleted_total | Counter | Number of ApiTokens deleted from Unleash |
unleasherator_api_token_created_total | Counter | Number of ApiTokens created in Unleash |
unleasherator_federation_published_total | Counter | Number of Unleash federation messages published with status |
unleasherator_federation_received_total | Counter | Number of Unleash federation messages received with status |
MIT License
Copyright (c) 2023 NAV
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
About
Kubernetes Operator for Unleash feature toggle service