diff --git a/.gitignore b/.gitignore index ca65cda..e0c3ef3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ target/ .idea/ server/*.iml +k8s.secret.yml +/consumer.properties diff --git a/Jenkinsfile b/Jenkinsfile index 107cad0..bd809b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,3 @@ library('jenkins-pipeline') -demoServerUiPipeline("sim-stocks", "maven") \ No newline at end of file +demoServerUiPipeline("stocks-simulated", "maven") \ No newline at end of file diff --git a/README.md b/README.md index c5cda90..d80432c 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,13 @@ npm run dev ``` Then head to `localhost:5173` to see it in action. + +# Deploying to kubernetes + +Edit the consumer.properties file to match the settings needed to connect to confluent cloud. + +```bash +# If the secret already exists +kubectl delete secret -n demo-stocks-simulated consumer-properties +kubectl update secret generic -n demo-stocks-simulated consumer-properties --from-file=consumer.properties +``` diff --git a/k8s.yml b/k8s.yml index 56a91ba..a2ea092 100644 --- a/k8s.yml +++ b/k8s.yml @@ -2,32 +2,39 @@ apiVersion: apps/v1 kind: StatefulSet metadata: - name: demo-sim-stocks - namespace: demo-sim-stocks + name: demo-stocks-simulated + namespace: demo-stocks-simulated spec: replicas: 1 selector: matchLabels: - demo: sim-stocks + demo: stocks-simulated serviceName: demo template: metadata: labels: - demo: sim-stocks + demo: stocks-simulated spec: + volumes: + - name: consumer-properties + secret: + secretName: consumer-properties containers: - image: DOCKER_IMAGE imagePullPolicy: Always name: demo + args: + - "-Dswim.config=/config/server.k8s.recon" + volumeMounts: + - mountPath: /secret/confluent + name: consumer-properties ports: - containerPort: 9001 protocol: TCP resources: limits: cpu: 500m - memory: 1Gi + memory: 512Mi requests: cpu: 250m - memory: 512Mi - - + memory: 256Mi diff --git a/server/src/main/resources/server.k8s.recon b/server/src/main/resources/server.k8s.recon new file mode 100644 index 0000000..389277d --- /dev/null +++ b/server/src/main/resources/server.k8s.recon @@ -0,0 +1,40 @@ +@kernel(class: "swim.meta.MetaKernel") +@kernel(class: "swim.service.web.UiRouter") + +provisions: { + @provision("consumer") { + class: "nstream.adapter.common.provision.PropertiesProvision", + config: "/secret/confluent/consumer.properties" + } +} + +stock: @fabric { + @plane(class: "io.nstream.demos.stocks.StockPlane") + + uri: "/consumer" + @agent(class: "nstream.adapter.confluent.ConfluentIngestingPatch") { + confluentIngressConf: @kafkaIngressSettings { + consumerPropertiesProvisionName: "consumer" + laneUri: "status" + } + } + + @node { + pattern: "/stock/:symbol" + @agent(class: "io.nstream.demos.stocks.agents.StockAgent") + } + + @node { + pattern: "/symbols" + @agent(class: "io.nstream.demos.stocks.agents.SymbolsAgent") + } + +} + +@web(port: 9001) { + space: "stock" + @websocket { + serverCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level + clientCompressionLevel: 0# -1 = default; 0 = off; 1-9 = deflate level + } +} \ No newline at end of file