Commit 7b758bef authored by Kostas Chartsias's avatar Kostas Chartsias
Browse files

OpenOP OEG integrations for QoD

parent 25af8831
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
This deployment relies on a `.env` file that is loaded at runtime by Docker Compose.
```
GROQ_API_KEY=your-secret-key
OpenOP_ISI_BACKEND=http://example-backend
OpenOP_BACKEND_OAI=http://example-backend
```

## Run
+1 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@ services:
    environment:
      MCP_HOST: 0.0.0.0
      MCP_PORT: 8004
      OpenOP_Backend: http://api:8081
      OpenOP_ISI_BACKEND: ${OpenOP_ISI_BACKEND}
      OpenOP_BACKEND_OAI: ${OpenOP_BACKEND_OAI}
    ports:
      - "8004:8004"
    networks:
+129 −0
Original line number Diff line number Diff line
# Kubernetes Deployment (ai2)

This directory contains Kubernetes manifests and a deployment script for running:
- `mcp_module` (service: `mcp-service`, port `8004`)
- `ai_agent` (service: `ai-agent-service`, port `9013`)

The default namespace is `ai2`.

## Files

- `namespace.yaml`: Creates namespace `ai2`.
- `configmap.yaml`: Non-sensitive runtime configuration.
- `secret.yaml`: Sensitive runtime configuration (`GROQ_API_KEY`).
- `mcp-deployment.yaml` / `mcp-service.yaml`: MCP Deployment and NodePort Service (`32004`).
- `ai-agent-deployment.yaml` / `ai-agent-service.yaml`: AI Agent Deployment and NodePort Service (`32013`).
- `deploy.sh`: Applies resources in order and waits for deployments to become available.

## Prerequisites

- Kubernetes cluster with `kubectl` configured.
- Access to pull container images from:
  - `labs.etsi.org:5050/oop/code/ai2/mcp_module:latest`
  - `labs.etsi.org:5050/oop/code/ai2/ai_agent:latest`
- A valid `GROQ_API_KEY`.

## Configure Secrets

Set the API key in `secret.yaml`:

```yaml
stringData:
  GROQ_API_KEY: "<your-key>"
```

Alternative (CLI):

```bash
kubectl create secret generic ai2-secrets \
  --from-literal=GROQ_API_KEY=<your-key> \
  -n ai2 \
  --dry-run=client -o yaml | kubectl apply -f -
```

## Deploy

From this directory:

```bash
chmod +x deploy.sh
./deploy.sh
```

Optional namespace override:

```bash
NAMESPACE=ai2 ./deploy.sh
```

## Verify

```bash
kubectl get ns ai2
kubectl get all -n ai2
kubectl get configmap ai2-config -n ai2
kubectl get secret ai2-secrets -n ai2
```

Check readiness and logs:

```bash
kubectl rollout status deployment/mcp-deployment -n ai2
kubectl rollout status deployment/ai-agent-deployment -n ai2
kubectl logs deployment/mcp-deployment -n ai2
kubectl logs deployment/ai-agent-deployment -n ai2
```

Health endpoints:

- MCP: `http://<node-ip>:32004/health`

## Test API Locally

Forward the AI Agent service to localhost:

```bash
kubectl port-forward svc/ai-agent-service 9013:9013 -n ai2
```

In a separate terminal, test endpoint `http://127.0.0.1:9013/groq-mcp` with `Content-Type: application/json`.

Create QoD session:

```bash
curl -X POST "http://127.0.0.1:9013/groq-mcp" \
  -H "Content-Type: application/json" \
  -d '{"query":"Create QoD session for device IP 12.1.0.20 application server IP 198.51.100.10 with QoS qos-e and duration 60 seconds"}'
```

Get QoD session:

```bash
curl -X POST "http://127.0.0.1:9013/groq-mcp" \
  -H "Content-Type: application/json" \
  -d '{"query":"Get  QoD session information for 33f6392b-57d0-42a3-a9fd-b4dcce617fce"}'
```

Delete QoD session:

```bash
curl -X POST "http://127.0.0.1:9013/groq-mcp" \
  -H "Content-Type: application/json" \
  -d '{"query":"Delete QoD session 33f6392b-57d0-42a3-a9fd-b4dcce617fce"}'
```

## Deployment Order

`deploy.sh` enforces this sequence:
1. Namespace
2. ConfigMap + Secret
3. MCP Deployment + Service
4. AI Agent Deployment + Service

The AI Agent Pod also includes an init container that waits for `http://mcp-service:8004/health` before starting.

## Cleanup

```bash
kubectl delete namespace ai2
```
+84 −0
Original line number Diff line number Diff line
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ai-agent-deployment
  namespace: ai2
  labels:
    app: ai-agent
    component: ai-agent
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ai-agent
  template:
    metadata:
      labels:
        app: ai-agent
        component: ai-agent
    spec:
      initContainers:
        - name: wait-for-mcp
          image: curlimages/curl:latest
          command: ["sh", "-c"]
          args:
            - |
              until curl -f http://mcp-service:8004/health; do
                echo "Waiting for MCP service to be ready..."
                sleep 2
              done
              echo "MCP service is ready!"

      containers:
        - name: ai-agent
          image: labs.etsi.org:5050/oop/code/ai2/ai_agent:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9013
              name: http
              protocol: TCP

          env:
            - name: APP_HOST
              valueFrom:
                configMapKeyRef:
                  name: ai2-config
                  key: APP_HOST
            - name: APP_PORT
              valueFrom:
                configMapKeyRef:
                  name: ai2-config
                  key: APP_PORT
            - name: MCP_SERVER_URL
              valueFrom:
                configMapKeyRef:
                  name: ai2-config
                  key: MCP_SERVER_URL
            - name: GROQ_API_KEY
              valueFrom:
                secretKeyRef:
                  name: ai2-secrets
                  key: GROQ_API_KEY
            - name: GROQ_MODEL_NAME
              valueFrom:
                configMapKeyRef:
                  name: ai2-config
                  key: GROQ_MODEL_NAME

          livenessProbe:
            httpGet:
              path: /health
              port: 9013
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3

          readinessProbe:
            httpGet:
              path: /health
              port: 9013
            initialDelaySeconds: 5
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 3
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
apiVersion: v1
kind: Service
metadata:
  name: ai-agent-service
  namespace: ai2
  labels:
    app: ai-agent
    component: ai-agent
spec:
  type: NodePort
  ports:
    - port: 9013
      targetPort: 9013
      nodePort: 32013
      protocol: TCP
      name: http
  selector:
    app: ai-agent
Loading