Merge pull request #247 from rogersacchelli/dev

Kubernetes Deploy With Ingress Controller
This commit is contained in:
Leandro Antônio Farias Machado 2024-04-24 15:22:43 -03:00 committed by GitHub
commit 35d539d61c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 58 additions and 59 deletions

View File

@ -19,6 +19,15 @@ git clone https://github.com/OktopUSP/oktopus
export DEPLOYMENT_PATH=oktopus/deploy/kubernetes
```
## HAProxy Ingress Controller
```shell
helm install haproxy-kubernetes-ingress haproxytech/kubernetes-ingress \
--create-namespace \
--namespace haproxy-controller \
--set controller.kind=DaemonSet \
--set controller.daemonset.useHostPort=true
```
## MongoBD
@ -49,27 +58,6 @@ helm install nats nats/nats --set config.jetstream.enabled=true
## Oktopus
<b>Node Ports</b>
For this deployment, we are not using a load balancer and kubernetes is deployed on-premises so we are using Nodeports to insource the client traffic into cluster. below the ports set on deployment files:
1. MQTT broker service (mqtt-svc): 30000
2. Frontend (frontend-svc): 30001
3. SocketIO: (socketio-svc): 30002
4. Controller (controller-svc): 30003
5. WebSocket (ws-svc): 30005
Before deploying the files, edit the frontend.yaml file to set the correct enviroment variables:
```yaml
env:
- name: NEXT_PUBLIC_REST_ENDPOINT
value: "<FRONTEND_IP>:30003"
- name: NEXT_PUBLIC_WS_ENDPOINT
value: "<FRONTEND_IP>:30005"
```
```shell
kubectl apply -f $DEPLOYMENT_PATH/mqtt.yaml
kubectl apply -f $DEPLOYMENT_PATH/mqtt-adapter.yaml
@ -88,4 +76,4 @@ kubectl apply -f $DEPLOYMENT_PATH/ws-adapter.yaml
kubectl get pods
kubectl get svc
```
```

View File

@ -33,7 +33,7 @@ spec:
- name: NATS_VERIFY_CERTIFICATES
value: "false"
- name: MONGO_URI
value: "mongodb://oktopusp:oktopusp@mongodb-0.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-1.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-2.mongodb-svc.mongodb.svc.cluster.local:27017/adapter?replicaSet=mongodb&ssl=false"
value: "mongodb://oktopusp:oktopusp@mongodb-0.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-1.mongodb-svc.mongodb.svc.cluster.local:27017,mongodb-2.mongodb-svc.mongodb.svc.cluster.local:27017/?replicaSet=mongodb&ssl=false"
- name: CONTROLLER_ID
value: "oktopusController"

View File

@ -48,6 +48,5 @@ spec:
- protocol: TCP
port: 8000
targetPort: 8000
nodePort: 30003
type: NodePort
type: ClusterIP

View File

@ -28,10 +28,8 @@ spec:
- containerPort: 3000
imagePullPolicy: IfNotPresent
env:
- name: NEXT_PUBLIC_REST_ENDPOINT
value: "192.168.1.130:30003"
- name: NEXT_PUBLIC_WS_ENDPOINT
value: "192.168.1.130:30005"
- name: NEXT_PUBLIC_REST_ENDPOINT
value: "/api"
---
apiVersion: v1
kind: Service
@ -44,5 +42,5 @@ spec:
- protocol: TCP
port: 3000
targetPort: 3000
nodePort: 30001
type: NodePort
#externalTrafficPolicy: Local
type: ClusterIP

View File

@ -1,7 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: haproxy-kubernetes-ingress
namespace: haproxy-controller
data:
syslog-server: "address:stdout, format: raw, facility:daemon"

View File

@ -1,8 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: haproxy-tcp
namespace: default
data:
1883: # Port where the frontend is going to listen to.
default/mqtt-svc:1883 # Kubernetes service in the format NS/ServiceName:ServicePort

View File

@ -1,8 +0,0 @@
controller:
service:
tcpPorts:
- name: mqtt
port: 1883
targetPort: 1883
extraArgs:
- --configmap-tcp-services=default/haproxy-tcp

View File

@ -0,0 +1,34 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-ingress
namespace: default
annotations:
spec:
ingressClassName: "haproxy"
rules:
- host: oktopus.rdss.cloud
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend-svc
port:
number: 3000
- path: /api
pathType: Prefix
backend:
service:
name: controller-svc
port:
number: 8000
- path: /socket.io
pathType: Prefix
backend:
service:
name: socketio-svc
port:
number: 5000

View File

@ -31,7 +31,7 @@ spec:
- name: NATS_VERIFY_CERTIFICATES
value: "false"
- name: MQTT_URL
value: "tcp://mqtt:1883"
value: "tcp://mqtt-svc:1883"
- name: MQTT_CLIENT_ID
value: "mqtt-adapter"
- name: MQTT_USERNAME

View File

@ -9,8 +9,8 @@ spec:
- protocol: TCP
port: 1883
targetPort: 1883
nodePort: 30000
type: NodePort
externalTrafficPolicy: Local
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
@ -46,3 +46,6 @@ spec:
value: "false"
- name: LOG_LEVEL
value: "0" # 0 - DEBUG
- name: REDIS_ENABLE
value: "false"

View File

@ -19,6 +19,8 @@ spec:
env:
- name: NATS_URL
value: "nats:4222"
- name: CORS_ALLOWED_ORIGINS
value: ""
---
apiVersion: v1
kind: Service
@ -31,5 +33,3 @@ spec:
- protocol: TCP
port: 5000
targetPort: 5000
nodePort: 30002
type: NodePort