-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial support for NATS as Datastore (#442)
- Loading branch information
1 parent
a849a84
commit 28a098a
Showing
26 changed files
with
565 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,7 @@ spec: | |
- etcd | ||
- MySQL | ||
- PostgreSQL | ||
- NATS | ||
type: string | ||
endpoints: | ||
description: |- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,7 @@ spec: | |
- etcd | ||
- MySQL | ||
- PostgreSQL | ||
- NATS | ||
type: string | ||
endpoints: | ||
description: |- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,7 @@ spec: | |
- etcd | ||
- MySQL | ||
- PostgreSQL | ||
- NATS | ||
type: string | ||
endpoints: | ||
description: |- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: kamaji.clastix.io/v1alpha1 | ||
kind: DataStore | ||
metadata: | ||
name: nats-bronze | ||
spec: | ||
driver: NATS | ||
endpoints: | ||
- bronze-nats.nats-system.svc:4222 | ||
basicAuth: | ||
username: | ||
content: YWRtaW4= | ||
password: | ||
secretReference: | ||
name: nats-bronze-config | ||
namespace: nats-system | ||
keyPath: password | ||
tlsConfig: | ||
certificateAuthority: | ||
certificate: | ||
secretReference: | ||
name: nats-bronze-config | ||
namespace: nats-system | ||
keyPath: ca.crt | ||
clientCertificate: | ||
certificate: | ||
secretReference: | ||
name: nats-bronze-config | ||
namespace: nats-system | ||
keyPath: server.crt | ||
privateKey: | ||
secretReference: | ||
name: nats-bronze-config | ||
namespace: nats-system | ||
keyPath: server.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: kamaji.clastix.io/v1alpha1 | ||
kind: DataStore | ||
metadata: | ||
name: nats-gold | ||
spec: | ||
driver: NATS | ||
endpoints: | ||
- nats-gold.nats-system.svc:4222 | ||
basicAuth: | ||
username: | ||
content: YWRtaW4= | ||
password: | ||
secretReference: | ||
name: nats-gold-config | ||
namespace: nats-system | ||
keyPath: password | ||
tlsConfig: | ||
certificateAuthority: | ||
certificate: | ||
secretReference: | ||
name: nats-gold-config | ||
namespace: nats-system | ||
keyPath: ca.crt | ||
clientCertificate: | ||
certificate: | ||
secretReference: | ||
name: nats-gold-config | ||
namespace: nats-system | ||
keyPath: server.crt | ||
privateKey: | ||
secretReference: | ||
name: nats-gold-config | ||
namespace: nats-system | ||
keyPath: server.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: kamaji.clastix.io/v1alpha1 | ||
kind: DataStore | ||
metadata: | ||
name: nats-silver | ||
spec: | ||
driver: NATS | ||
endpoints: | ||
- nats-silver.nats-system.svc:4222 | ||
basicAuth: | ||
username: | ||
content: YWRtaW4= | ||
password: | ||
secretReference: | ||
name: nats-silver-config | ||
namespace: nats-system | ||
keyPath: password | ||
tlsConfig: | ||
certificateAuthority: | ||
certificate: | ||
secretReference: | ||
name: nats-silver-config | ||
namespace: nats-system | ||
keyPath: ca.crt | ||
clientCertificate: | ||
certificate: | ||
secretReference: | ||
name: nats-silver-config | ||
namespace: nats-system | ||
keyPath: server.crt | ||
privateKey: | ||
secretReference: | ||
name: nats-silver-config | ||
namespace: nats-system | ||
keyPath: server.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
NAME:=default | ||
NAMESPACE:=nats-system | ||
|
||
.PHONY: helm | ||
HELM = $(shell pwd)/../../../bin/helm | ||
helm: ## Download helm locally if necessary. | ||
$(call go-install-tool,$(HELM),helm.sh/helm/v3/cmd/[email protected]) | ||
|
||
nats: nats-certificates nats-secret nats-deployment | ||
|
||
nats-certificates: | ||
rm -rf $(ROOT_DIR)/certs/$(NAME) && mkdir -p $(ROOT_DIR)/certs/$(NAME) | ||
cfssl gencert -initca $(ROOT_DIR)/ca-csr.json | cfssljson -bare $(ROOT_DIR)/certs/$(NAME)/ca | ||
@mv $(ROOT_DIR)/certs/$(NAME)/ca.pem $(ROOT_DIR)/certs/$(NAME)/ca.crt | ||
@mv $(ROOT_DIR)/certs/$(NAME)/ca-key.pem $(ROOT_DIR)/certs/$(NAME)/ca.key | ||
@NAME=$(NAME) NAMESPACE=$(NAMESPACE) envsubst < server-csr.json > $(ROOT_DIR)/certs/$(NAME)/server-csr.json | ||
cfssl gencert -ca=$(ROOT_DIR)/certs/$(NAME)/ca.crt -ca-key=$(ROOT_DIR)/certs/$(NAME)/ca.key \ | ||
-config=$(ROOT_DIR)/config.json -profile=server \ | ||
$(ROOT_DIR)/certs/$(NAME)/server-csr.json | cfssljson -bare $(ROOT_DIR)/certs/$(NAME)/server | ||
@mv $(ROOT_DIR)/certs/$(NAME)/server.pem $(ROOT_DIR)/certs/$(NAME)/server.crt | ||
@mv $(ROOT_DIR)/certs/$(NAME)/server-key.pem $(ROOT_DIR)/certs/$(NAME)/server.key | ||
chmod 644 $(ROOT_DIR)/certs/$(NAME)/* | ||
|
||
nats-secret: | ||
@kubectl create namespace $(NAMESPACE) || true | ||
@kubectl -n $(NAMESPACE) create secret generic nats-$(NAME)-config \ | ||
--from-file=$(ROOT_DIR)/certs/$(NAME)/ca.crt --from-file=$(ROOT_DIR)/certs/$(NAME)/ca.key \ | ||
--from-file=$(ROOT_DIR)/certs/$(NAME)/server.key --from-file=$(ROOT_DIR)/certs/$(NAME)/server.crt \ | ||
--from-literal=password=password \ | ||
--dry-run=client -o yaml | kubectl apply -f - | ||
|
||
nats-deployment: | ||
@NAME=$(NAME) envsubst < $(ROOT_DIR)/values.yaml | $(HELM) upgrade --install $(NAME) nats/nats --create-namespace -n nats-system -f - | ||
|
||
nats-destroy: | ||
@NAME=$(NAME) envsubst < $(ROOT_DIR)/nats.yaml | kubectl -n $(NAMESPACE) delete --ignore-not-found -f - | ||
@kubectl delete -n $(NAMESPACE) secret mysql-$(NAME)config --ignore-not-found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"CN": "Clastix CA", | ||
"key": { | ||
"algo": "rsa", | ||
"size": 2048 | ||
}, | ||
"names": [ | ||
{ | ||
"C": "IT", | ||
"ST": "Italy", | ||
"L": "Milan" | ||
} | ||
], | ||
"hosts": [ | ||
"127.0.0.1", | ||
"localhost" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"signing": { | ||
"default": { | ||
"expiry": "8760h" | ||
}, | ||
"profiles": { | ||
"server": { | ||
"expiry": "8760h", | ||
"usages": [ | ||
"signing", | ||
"key encipherment", | ||
"server auth", | ||
"client auth" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"CN": "$NAME.$NAMESPACE.svc.cluster.local", | ||
"key": { | ||
"algo": "rsa", | ||
"size": 2048 | ||
}, | ||
"hosts": [ | ||
"127.0.0.1", | ||
"localhost", | ||
"$NAME-nats", | ||
"$NAME-nats.$NAMESPACE.svc", | ||
"$NAME-nats.$NAMESPACE.svc.cluster.local" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
config: | ||
merge: | ||
accounts: | ||
private: | ||
jetstream: enabled | ||
users: | ||
- {user: admin, password: "password", permissions: {subscribe: [">"], publish: [">"]}} | ||
cluster: | ||
enabled: no | ||
nats: | ||
tls: | ||
enabled: true | ||
secretName: nats-$NAME-config | ||
cert: server.crt | ||
key: server.key | ||
jetstream: | ||
enabled: true | ||
fileStore: | ||
pvc: | ||
size: 32Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.