Commit c13ada52 authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat: add deploy on kind scripts and oop helm chart

parents
Loading
Loading
Loading
Loading

README.md

0 → 100644
+117 −0
Original line number Diff line number Diff line
# Open Operator Platform (OOP) — Helm Deployment

Reference deployment of OOP on a local [kind](https://kind.sigs.k8s.io/) cluster using Helm.
Intended for local development, integration testing, and demos. **Not for production.**

---

## Components

| Component | Namespace | Description |
|---|---|---|
| SRM (Service Resource Manager) | `oop` | Manages application artefacts and lifecycle |
| Artifact Manager | `oop` | Stores and serves artefacts |
| OEG (Open Exposure Gateway) | `oop` | Northbound API entry point for tenants |
| Federation Manager | `federation-manager` | Inter-operator federation workflows |
| Keycloak | `federation-manager` | OAuth2/OIDC authentication for FM |

---

## Prerequisites

| Tool | Minimum version |
|---|---|
| Docker | 20.x |
| kind | 0.20 |
| kubectl | 1.25 |
| Helm | v3 |

---

## Deploy on kind (one command)

```bash
cd helm
chmod +x deploy-on-kind.sh
./deploy-on-kind.sh
```

This runs `kind-bootstrap.sh` then `helm-deploy.sh` in sequence.

**`kind-bootstrap.sh`** (run once per cluster):
1. Checks prerequisites
2. Creates host storage directories at `/tmp/kind-oop/`
3. Creates the `oop-cluster` kind cluster from `kind-oop-config.yaml`
4. Creates namespaces (`oop`, `federation-manager`), a `oop-user` service account, and a `cluster-admin` binding

**`helm-deploy.sh`** (re-runnable):
1. Generates a short-lived token for `oop-user`
2. `helm install oop-platform ./oop-platform-chart -n oop -f values.kind.yaml`
3. `helm install federation-manager ./oop-platform-chart/charts/federation-manager -n federation-manager -f values.fm.kind.yaml`

---

## Access URLs (after deployment)

| Service | URL |
|---|---|
| SRM Dashboard | http://localhost:32415 |
| Artifact Manager | http://localhost:30080 |
| OEG API (Swagger) | http://localhost:32263/oeg/1.0.0/docs/ |
| Keycloak | http://localhost:30081 |
| Keycloak Admin | http://localhost:30081/admin — `admin / admin` |
| Federation Manager | http://localhost:30989 |

---

## Upgrade

```bash
# Upgrade core platform (SRM + OEG)
helm upgrade oop-platform ./oop-platform-chart \
  -n oop \
  -f values.kind.yaml \
  --set srm.srmcontroller.env.kubernetesMasterToken="$(kubectl -n oop create token oop-user)"

# Upgrade Federation Manager
helm upgrade federation-manager ./oop-platform-chart/charts/federation-manager \
  -n federation-manager \
  -f values.fm.kind.yaml
```

---

## Cleanup

```bash
helm uninstall oop-platform -n oop
helm uninstall federation-manager -n federation-manager
kind delete cluster --name oop-cluster
```

---

## Configuration files

| File | Purpose |
|---|---|
| `oop-platform-chart/values.yaml` | Base defaults for all components |
| `values.kind.yaml` | kind overrides for `oop-platform` (NodePorts, hostPath, storageClass) |
| `values.fm.kind.yaml` | kind overrides for `federation-manager` subchart |
| `kind-oop-config.yaml` | kind cluster definition (port mappings, host mounts) |

---

## Troubleshooting

```bash
kubectl get pods -n oop
kubectl get pods -n federation-manager

# Inspect a failing pod
kubectl describe pod <pod-name> -n oop
kubectl logs <pod-name> -n oop

# Check Helm release status
helm status oop-platform -n oop
```

deploy-on-kind.sh

0 → 100755
+16 −0
Original line number Diff line number Diff line
#!/bin/bash

# ====================================================================
# Deploy Open Operator Platform (OOP) on kind
# Convenience wrapper — runs kind-bootstrap.sh then helm-deploy.sh.
# You can also run each script individually.
# ====================================================================

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

chmod +x "$SCRIPT_DIR/kind-bootstrap.sh" "$SCRIPT_DIR/helm-deploy.sh"

"$SCRIPT_DIR/kind-bootstrap.sh"
"$SCRIPT_DIR/helm-deploy.sh"

helm-deploy.sh

0 → 100755
+73 −0
Original line number Diff line number Diff line
#!/bin/bash

# ====================================================================
# Deploy OOP Platform via Helm
# Requires the cluster to be bootstrapped first (kind-bootstrap.sh).
# ====================================================================

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CHART_DIR="$SCRIPT_DIR/oop-platform-chart"

OOP_NS="oop"
FM_NS="federation-manager"
OOP_RELEASE="oop-platform"

echo "OOP Platform — Helm Deploy"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# ── Check prerequisites ───────────────────────────────────────────────
if ! command -v kubectl &> /dev/null; then
    echo " kubectl is not installed"
    exit 1
fi

if ! command -v helm &> /dev/null; then
    echo " helm is not installed"
    exit 1
fi

# ── Generate token from existing service account ─────────────────────
echo "Generating token..."
TOKEN=$(kubectl -n $OOP_NS create token oop-user)
echo "  Token generated"
echo ""

# ── Deploy with Helm ──────────────────────────────────────────────────
echo "Deploying OOP Platform via Helm..."

helm upgrade --install $OOP_RELEASE "$CHART_DIR" \
    -n $OOP_NS \
    --create-namespace \
    -f "$SCRIPT_DIR/values.kind.yaml" \
    --set srm.srmcontroller.env.kubernetesMasterToken="$TOKEN" \
    --set federationManager.enabled=false

helm upgrade --install federation-manager "$CHART_DIR/charts/federation-manager" \
    -n $FM_NS \
    --create-namespace \
    -f "$SCRIPT_DIR/values.fm.kind.yaml"

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Deployment complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Access URLs (via localhost):"
echo "   SRM Dashboard:       http://localhost:32415"
echo "   Artifact Manager:    http://localhost:30080"
echo "   OEG API:             http://localhost:32263/oeg/1.0.0/docs/"
echo "   Keycloak:            http://localhost:30081"
echo "   Keycloak Admin:      http://localhost:30081/admin  (Username: admin / Password: admin)"
echo "   Federation Manager:  http://localhost:30989"
echo ""
echo "Useful commands:"
echo "   kubectl get pods -n $OOP_NS"
echo "   kubectl get pods -n $FM_NS"
echo "   kubectl logs -f deployment/srmcontroller -n $OOP_NS"
echo "   helm uninstall $OOP_RELEASE -n $OOP_NS          # Remove SRM + OEG"
echo "   helm uninstall federation-manager -n $FM_NS    # Remove Federation Manager"
echo "   kind delete cluster --name oop-cluster          # Tear down cluster"
echo ""

kind-bootstrap.sh

0 → 100755
+84 −0
Original line number Diff line number Diff line
#!/bin/bash

# ====================================================================
# Bootstrap kind cluster for OOP (infra only — no Helm)
# Run this once. After this, run helm-deploy.sh to install charts.
# ====================================================================

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
KIND_CONFIG="$SCRIPT_DIR/kind-oop-config.yaml"

OOP_NS="oop"
FM_NS="federation-manager"

echo "OOP Platform — kind Bootstrap"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# ── Step 1: Check prerequisites ──────────────────────────────────────
echo "Step 1/4: Checking prerequisites..."

if ! command -v kind &> /dev/null; then
    echo " kind is not installed"
    echo "   Install: https://kind.sigs.k8s.io/"
    exit 1
fi

if ! command -v kubectl &> /dev/null; then
    echo " kubectl is not installed"
    exit 1
fi

echo " Prerequisites met (kind, kubectl)"
echo ""

# ── Step 2: Create storage directories ───────────────────────────────
echo "Step 2/4: Creating storage directories..."
sudo mkdir -p /tmp/kind-oop/mongodb_srm /tmp/kind-oop/mongodb_oeg /tmp/kind-oop/mongodb_fm 2>/dev/null || true
sudo chmod -R 777 /tmp/kind-oop/ 2>/dev/null || true
echo "  Storage directories ready at /tmp/kind-oop/"
echo ""

# ── Step 3: Create kind cluster ───────────────────────────────────────
echo "Step 3/4: Creating kind cluster..."

if kind get clusters 2>/dev/null | grep -q "oop-cluster"; then
    echo "  Cluster 'oop-cluster' already exists"
    read -p "  Delete and recreate? (y/N) " -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        kind delete cluster --name oop-cluster
    else
        echo "  Using existing cluster"
    fi
fi

if ! kind get clusters 2>/dev/null | grep -q "oop-cluster"; then
    kind create cluster --config "$KIND_CONFIG"
    echo "  Cluster created"
fi

kubectl config use-context kind-oop-cluster
echo ""

# ── Step 4: Wait for cluster, create namespaces and service account ───
echo "Step 4/4: Waiting for cluster and setting up namespaces + RBAC..."
kubectl wait --for=condition=Ready nodes --all --timeout=120s

kubectl create namespace $OOP_NS 2>/dev/null || echo "  Namespace $OOP_NS already exists"
kubectl create namespace $FM_NS  2>/dev/null || echo "  Namespace $FM_NS already exists"

kubectl create serviceaccount oop-user -n $OOP_NS 2>/dev/null || echo "  Service account already exists"
kubectl create clusterrolebinding oop-user-binding \
    --clusterrole=cluster-admin \
    --serviceaccount=$OOP_NS:oop-user \
    2>/dev/null || echo "  ClusterRoleBinding already exists"

echo "  Cluster ready"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Bootstrap complete. Run ./helm-deploy.sh to install the platform."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

kind-oop-config.yaml

0 → 100644
+36 −0
Original line number Diff line number Diff line
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: oop-cluster
nodes:
- role: control-plane
  
  # Port mappings for accessing services from host via localhost
  extraPortMappings:
  
  # Core Platform Services (oop namespace)
  - containerPort: 32415    # SRM Dashboard
    hostPort: 32415
    protocol: TCP
  - containerPort: 30080    # Artifact Manager
    hostPort: 30080
    protocol: TCP
  - containerPort: 32263    # OEG API
    hostPort: 32263
    protocol: TCP
  
  # Federation Services (federation-manager namespace)
  - containerPort: 30081    # Keycloak
    hostPort: 30081
    protocol: TCP
  - containerPort: 30989    # Federation Manager
    hostPort: 30989
    protocol: TCP
  
  # Storage volumes for MongoDB persistence
  extraMounts:
  - hostPath: /tmp/kind-oop/mongodb_srm
    containerPath: /mnt/data/mongodb_srm
  - hostPath: /tmp/kind-oop/mongodb_oeg
    containerPath: /mnt/data/mongodb_oeg
  - hostPath: /tmp/kind-oop/mongodb_fm
    containerPath: /mnt/data/mongodb_fm