Manages the lifecycle of a NATS JetStream deployment.
It is a standard Kubernetes operator which observes the state of NATS JetStream deployment and reconciles its state according to desired state.
You’ll need a Kubernetes cluster to run against. You can use k3d 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 cluster kubectl 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>/nats-manager:tag
NOTE: run the following for MacBook M1 devices:
make docker-buildx IMG=<some-registry>/nats-manager:tag
- Deploy the controller to the cluster with the image specified by
IMG
:
make deploy IMG=<some-registry>/nats-manager:tag
To delete the CRDs from the cluster:
make uninstall
UnDeploy the controller from the cluster:
make undeploy
Installing with Kyma Lifecycle Manager
- Deploy the Lifecycle Manager & Module Manager to the Control Plane cluster with:
kyma alpha deploy
NOTE: For single-cluster mode edit the lifecycle manager role to give access to all resources with kubectl edit clusterrole lifecycle-manager-manager-role
and have the following under rules
:
- apiGroups:
- "*"
resources:
- "*"
verbs:
- "*"
- Prepare OCI container registry:
It can be Github, DockerHub, GCP or local registry. The following resources worth having a look to set up a container registry unless you have one:
- Lifecycle manager provision-cluster-and-registry documentation
- Github container registry documentation. Change the visibility of a GH package to public if you don't provide a registry secret.
- Generate module template and push container image by running the following command in the project root director:
kyma alpha create module -n kyma-project.io/module/nats --version 0.0.1 --registry ghcr.io/{GH_USERNAME}/nats-manager -c {REGISTRY_USER_NAME}:{REGISTRY_AUTH_TOKEN} -w
In the command GH container registry sample is used. Replace GH_USERNAME=REGISTRY_USER_NAME and REGISTRY_AUTH_TOKEN with the GH username and token/password respectively.
The command generates a ModuleTemplate template.yaml
file in the project folder.
NOTE: Change template.yaml
content with spec.target=remote
to spec.target=control-plane
for single-cluster mode as it follows:
spec:
target: control-plane
channel: regular
- Apply the module template to the K8s cluster:
kubectl apply -f template.yaml
- Deploy the
nats
module by adding it tokyma
custom resourcespec.modules
:
kubectl edit -n kyma-system kyma default-kyma
The spec part should have the following:
...
spec:
modules:
- name: nats
...
- Check whether your modules is deployed properly:
Check nats resource if it has ready state:
kubectl get -n kyma-system nats
Check Kyma resource if it has ready state:
kubectl get -n kyma-system kyma
If they don't have ready state, one can troubleshoot it by checking the pods under nats-manager-system
namespace where the module is installed:
kubectl get pods -n nats-manager-system
Uninstalling controller with Kyma Lifecycle Manager
-
Delete nats from
kyma
resourcespec.modules
kubectl edit -n kyma-system kyma default-kyma
: -
Check
nats
resource and module namespace whether they are deleted
kubectl get -n kyma-system nats
This project aims to follow the Kubernetes Operator pattern.
It uses Controllers, which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster.
- Install the CRDs into the cluster:
make install
- Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):
make run
NOTE: You can also run this in one step by running: make install run
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
make manifests
NOTE: Run make --help
for more information on all potential make
targets
More information can be found via the Kubebuilder Documentation
Copyright 2023.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.