Skip to content

Commit acd2a6b

Browse files
committed
feat: Add Kubernetes deployment manifests, configuration, a helper script, and documentation for Proplet on Confidential Containers.
Signed-off-by: SammyOina <sammyoina@gmail.com>
1 parent 63c90dc commit acd2a6b

4 files changed

Lines changed: 223 additions & 0 deletions

File tree

coco/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Proplet on Confidential Containers (CoCo)
2+
3+
This directory contains resources for deploying Proplet on a Kubernetes cluster enabled with Confidential Containers (Kata Containers).
4+
5+
## Prerequisites
6+
7+
* A Kubernetes cluster with [Confidential Containers](https://confidentialcontainers.org/) (Kata Containers) installed.
8+
* `kubectl` configured to access the cluster.
9+
* `docker` for building images (or another OCI builder).
10+
* A default StorageClass for handling ephemeral storage (optional but recommended).
11+
12+
## Cluster Setup (Quick Start)
13+
14+
To set up a local testing environment with Kind and Confidential Containers:
15+
16+
1. **Create a Kind Cluster**:
17+
```bash
18+
kind create cluster --name coco-test --config - <<EOF
19+
kind: Cluster
20+
apiVersion: kind.x-k8s.io/v1alpha4
21+
nodes:
22+
- role: control-plane
23+
- role: worker
24+
EOF
25+
```
26+
27+
2. **Install the CoCo Operator**:
28+
Deploy the Confidential Containers Operator to install Kata Containers and required components.
29+
30+
```bash
31+
kubectl apply -k github.com/confidential-containers/operator/config/release?ref=v0.8.0
32+
```
33+
34+
*Note: Check the [CoCo Operator releases](https://github.com/confidential-containers/operator/releases) for the latest version.*
35+
36+
3. **Wait for Installation**:
37+
Wait for the `cc-runtime` runtime class to become available:
38+
39+
```bash
40+
kubectl get runtimeclass
41+
# Should show 'kata', 'kata-qemu', or 'kata-fc'
42+
```
43+
44+
Ensure all operator pods are running:
45+
```bash
46+
kubectl get pods -n confidential-containers-system
47+
```
48+
49+
## Deployment
50+
51+
The deployment setup consists of:
52+
* `proplet.yaml`: The main Deployment manifest. Checks for `runtimeClassName: kata` (default).
53+
* `proplet-config.yaml`: Configuration map containing `config.toml` (SuperMQ config) and environment variables.
54+
* `deploy_coco.sh`: A helper script to build and deploy.
55+
56+
### 1. Configuration
57+
58+
1. **Edit `proplet-config.yaml`**:
59+
* Set your `domain_id`, `client_id`, `client_key`, and `channel_id`.
60+
* These values configure Proplet to connect to the SuperMQ message broker.
61+
62+
2. **Edit `proplet.yaml`**:
63+
* Update `PROPLET_MQTT_ADDRESS` if your MQTT broker is not running locally (default `tcp://localhost:1883`).
64+
* Update `PROPLET_INSTANCE_ID` to a unique name for this instance.
65+
* Ensure `runtimeClassName` matches your cluster's CoCo runtime class (e.g., `kata-qemu`, `kata-fc`, or just `kata`).
66+
67+
### 2. Deploy
68+
69+
Use the helper script to build and deploy:
70+
71+
```bash
72+
./deploy_coco.sh
73+
```
74+
75+
Or manually:
76+
77+
```bash
78+
# 1. Build image
79+
docker build -f ../docker/Dockerfile.proplet -t proplet:latest ..
80+
81+
# 2. Apply manifests
82+
kubectl apply -f proplet-config.yaml
83+
kubectl apply -f proplet.yaml
84+
```
85+
86+
## Attestation Agent
87+
88+
In a CoCo environment, the Attestation Agent (AA) typically runs as a guest component inside the VM.
89+
Proplet is configured to communicate with the AA on `localhost:50002` (standard CoCo port).
90+
91+
To attest the environment, ensure:
92+
1. Your Kubernetes cluster is properly configured for remote attestation (KBS/KBC setup).
93+
2. The Attestation Agent is active in the Guest VM.
94+
95+
## Troubleshooting
96+
97+
**Pod stuck in `ContainerCreating`**:
98+
* Check if Kata runtime is available: `kubectl get runtimeclasses`
99+
* Check Kubelet logs for QEMU/Kata startup errors.
100+
101+
**Proplet fails to connect**:
102+
* Check logs: `kubectl logs -l app=proplet`
103+
* Verify network connectivity to the MQTT broker.

coco/deploy_coco.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Helper script to deploy Proplet on Confidential Containers (CoCo)
4+
5+
set -e
6+
7+
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
8+
ROOT_DIR=$(dirname "$SCRIPT_DIR")
9+
K8S_DIR="$SCRIPT_DIR"
10+
11+
# Configuration
12+
IMAGE_NAME="proplet"
13+
IMAGE_TAG="latest"
14+
RUNTIME_CLASS=${RUNTIME_CLASS:-kata}
15+
16+
echo "=== Proplet CoCo Deployment ==="
17+
18+
# 1. Build the Proplet container image
19+
echo "Building Proplet container image..."
20+
cd "$ROOT_DIR"
21+
docker build -f docker/Dockerfile.proplet -t "${IMAGE_NAME}:${IMAGE_TAG}" .
22+
23+
# 2. (Optional) Load into Kind if using Kind
24+
if kind get clusters &> /dev/null; then
25+
echo "Detected Kind cluster, loading image..."
26+
kind load docker-image "${IMAGE_NAME}:${IMAGE_TAG}" || echo "Warning: Failed to load image into Kind, continuing..."
27+
fi
28+
29+
# 3. Apply Kubernetes manifests
30+
echo "Applying Kubernetes manifests..."
31+
# Temporarily update runtimeClassName if overridden
32+
if [ "$RUNTIME_CLASS" != "kata" ]; then
33+
echo "Updating runtimeClassName to $RUNTIME_CLASS..."
34+
sed -i "s/runtimeClassName: kata/runtimeClassName: $RUNTIME_CLASS/g" "$K8S_DIR/proplet.yaml"
35+
fi
36+
37+
kubectl apply -f "$K8S_DIR/proplet-config.yaml"
38+
kubectl apply -f "$K8S_DIR/proplet.yaml"
39+
40+
echo "=== Deployment Submitted ==="
41+
echo "Check status:"
42+
echo " kubectl get pods -l app=proplet"
43+
echo " kubectl logs -l app=proplet"

coco/proplet-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: proplet-config
5+
data:
6+
config.toml: |
7+
# SuperMQ Configuration
8+
9+
[manager]
10+
domain_id = "4bae1a76-afc4-4054-976c-5427c49fbbf3"
11+
client_id = "cdaccb11-7209-4fb9-8df1-3c52e9d64284"
12+
client_key = "507d687d-51f8-4c71-8599-4273a5d75429"
13+
channel_id = "34a616c3-8817-4995-aade-a383e64766a8"
14+
15+
[proplet1]
16+
domain_id = "4bae1a76-afc4-4054-976c-5427c49fbbf3"
17+
client_id = "0deb859f-973d-4e2e-93cf-ec756f4fc3c8"
18+
client_key = "17c03d05-b55d-4a05-88ec-cadecb2130c4"
19+
channel_id = "34a616c3-8817-4995-aade-a383e64766a8"
20+
21+
[proxy]
22+
domain_id = "4bae1a76-afc4-4054-976c-5427c49fbbf3"
23+
client_id = "0deb859f-973d-4e2e-93cf-ec756f4fc3c8"
24+
client_key = "17c03d05-b55d-4a05-88ec-cadecb2130c4"
25+
channel_id = "34a616c3-8817-4995-aade-a383e64766a8"

coco/proplet.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: proplet
5+
labels:
6+
app: proplet
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: proplet
12+
template:
13+
metadata:
14+
labels:
15+
app: proplet
16+
spec:
17+
runtimeClassName: kata
18+
containers:
19+
- name: proplet
20+
image: proplet:latest
21+
imagePullPolicy: IfNotPresent
22+
env:
23+
- name: PROPLET_LOG_LEVEL
24+
value: "info"
25+
- name: PROPLET_INSTANCE_ID
26+
value: "proplet-k8s-001"
27+
- name: PROPLET_CONFIG_FILE
28+
value: "/etc/proplet/config.toml"
29+
- name: PROPLET_CONFIG_SECTION
30+
value: "proplet1"
31+
- name: PROPLET_EXTERNAL_WASM_RUNTIME
32+
value: "/usr/local/bin/wasmtime"
33+
- name: PROPLET_MANAGER_K8S_NAMESPACE
34+
value: "default"
35+
- name: PROPLET_MQTT_ADDRESS
36+
value: "tcp://localhost:1883"
37+
- name: PROPLET_MQTT_TIMEOUT
38+
value: "30"
39+
- name: PROPLET_MQTT_QOS
40+
value: "2"
41+
- name: PROPLET_LIVELINESS_INTERVAL
42+
value: "10"
43+
# Since AA runs in the guest VM in CoCo (not sidecar), we access it via localhost
44+
# if the network namespace is shared or via specific socket.
45+
# Assuming standard loopback availability in the Pod for guest components provided by Kata 3.x+
46+
volumeMounts:
47+
- name: config-volume
48+
mountPath: /etc/proplet
49+
volumes:
50+
- name: config-volume
51+
configMap:
52+
name: proplet-config

0 commit comments

Comments
 (0)