Kubernetes Deployment - WIP
This commit is contained in:
parent
b947d42ac2
commit
61f93f49e5
|
|
@ -2,7 +2,7 @@ FROM golang:1.22@sha256:82e07063a1ac3ee59e6f38b1222e32ce88469e4431ff6496cc40fb9a
|
|||
WORKDIR /app
|
||||
COPY ../ ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o mqtt cmd/mqtt/main.go
|
||||
CMD pwd
|
||||
|
||||
FROM alpine:3.14@sha256:0f2d5c38dd7a4f4f733e688e3a6733cb5ab1ac6e3cb4603a5dd564e5bfb80eed
|
||||
COPY --from=builder /app/mqtt /
|
||||
ENTRYPOINT ["/mqtt"]
|
||||
|
|
|
|||
|
|
@ -2,15 +2,90 @@
|
|||
|
||||
## Requirements
|
||||
|
||||
Kubernetes 1.28+
|
||||
|
||||
### Standalone Installation
|
||||
|
||||
Node:
|
||||
Single Node:
|
||||
* 8 vCPUs
|
||||
* 8 GB RAM
|
||||
|
||||
# Installation
|
||||
|
||||
## Download Files
|
||||
|
||||
```shell
|
||||
git clone https://github.com/OktopUSP/oktopus
|
||||
export DEPLOYMENT_PATH=oktopus/deploy/kubernetes
|
||||
```
|
||||
|
||||
|
||||
## MongoBD
|
||||
|
||||
```shell
|
||||
# Mongo DB Operator at mongodb namespace
|
||||
helm repo add mongodb https://mongodb.github.io/helm-charts
|
||||
|
||||
helm install community-operator mongodb/community-operator --namespace mongodb --create-namespace
|
||||
|
||||
# Mongo DB ReplicaSet
|
||||
export DEPLOYMENT_PATH=oktopus/deploy/kubernetes
|
||||
|
||||
kubectl apply -f $DEPLOYMENT_PATH/mongodb.yaml -n mongodb
|
||||
|
||||
# Check Installation
|
||||
kubectl get pods -n mongodb
|
||||
```
|
||||
|
||||
## NATS Server
|
||||
|
||||
```shell
|
||||
# Download the NATS charts
|
||||
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
|
||||
|
||||
# Install NATS with Jetstream Enabled
|
||||
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
|
||||
kubectl apply -f $DEPLOYMENT_PATH/adapter.yaml
|
||||
kubectl apply -f $DEPLOYMENT_PATH/controller.yaml
|
||||
kubectl apply -f $DEPLOYMENT_PATH/socketio.yaml
|
||||
kubectl apply -f $DEPLOYMENT_PATH/frontend.yaml
|
||||
kubectl apply -f $DEPLOYMENT_PATH/ws.yaml
|
||||
kubectl apply -f $DEPLOYMENT_PATH/ws-adapter.yaml
|
||||
```
|
||||
|
||||
### Checking cluster status:
|
||||
|
||||
```shell
|
||||
|
||||
kubectl get pods
|
||||
kubectl get svc
|
||||
|
||||
```
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: backend
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: backend
|
||||
image: backend:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
|
@ -8,7 +8,7 @@ spec:
|
|||
matchLabels:
|
||||
app: frontend
|
||||
strategy:
|
||||
type: Recreate # Specify the Recreate strategy
|
||||
type: Recreate # Specify the Recreate strategy
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
|
@ -16,16 +16,22 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: frontend
|
||||
image: rogersacchelli/frontend:1.0.3
|
||||
image: oktopusp/frontend:latest
|
||||
resources:
|
||||
requests:
|
||||
memory: 64Mi
|
||||
cpu: 100m
|
||||
limits:
|
||||
memory: 256Mi
|
||||
cpu: 200m
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
imagePullPolicy: Always
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: NEXT_PUBLIC_REST_ENDPOINT
|
||||
value: "192.168.1.130:30003"
|
||||
- name: NEXT_PUBLIC_WS_ENDPOINT
|
||||
value: "192.168.1.130:30002"
|
||||
|
||||
value: "192.168.1.130:30005"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ spec:
|
|||
- protocol: TCP
|
||||
port: 1883
|
||||
targetPort: 1883
|
||||
type: ClusterIP
|
||||
nodePort: 30000
|
||||
type: NodePort
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
|
@ -33,10 +34,10 @@ spec:
|
|||
resources:
|
||||
requests:
|
||||
memory: 64Mi
|
||||
cpu: 0.1
|
||||
cpu: 100m
|
||||
limits:
|
||||
memory: 256Mi
|
||||
cpu: 0.2
|
||||
cpu: 200m
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: MQTT_PORT
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ spec:
|
|||
image: oktopusp/ws:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
#resources:
|
||||
#requests:
|
||||
#memory: 64Mi
|
||||
#cpu: 0.1
|
||||
#limits:
|
||||
#memory: 256Mi
|
||||
#cpu: 0.2
|
||||
resources:
|
||||
requests:
|
||||
memory: 64Mi
|
||||
cpu: 100m
|
||||
limits:
|
||||
memory: 256Mi
|
||||
cpu: 200m
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: SERVER_PORT
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ COPY ./ ./
|
|||
|
||||
RUN npm install
|
||||
|
||||
RUN NEXT_PUBLIC_REST_ENPOINT=REST_API_URL NEXT_PUBLIC_WS_ENPOINT=WS_URL npm run build
|
||||
RUN NEXT_PUBLIC_REST_ENDPOINT=REST_API_URL NEXT_PUBLIC_WS_ENDPOINT=WS_URL npm run build
|
||||
|
||||
RUN ls -la && echo "Listing directory contents done"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user