Skip to content
Snippets Groups Projects

SEE Interface

This AMQP 0-9-1 client provides the interface to the NEMO Secure Execution Environment (SEE).

A pre-built container image is available as nemometaos/see-interface:latest.

Development Quickstart

Requirements

  • Go for compiling the application
  • minikube as test cluster

minikube Setup

  1. Start minikube and enable the metrics server:

    minikube start
    minikube addons enable metrics-server
  2. Create and expose a RabbitMQ deployment:

    kubectl create deployment rabbitmq --image=rabbitmq:4-alpine
    kubectl expose deployment rabbitmq --type=NodePort --port=5672
  3. Optional: Open the Kubernetes dashboard:

    minikube dashboard

Build and Run the SEE Interface

  1. Build the image:

    minikube image build . --tag nemometaos/see-interface:latest
  2. Apply the SEE Interface configuration:

    kubectl apply -f components.yaml

Run see-ctl

To access RabbitMQ, forward the corresponding port:

kubectl port-forward service/rabbitmq 5672

Listen to Metrics

go run cmd/see-ctl/main.go metrics

Modify Kubernetes Objects

First create a YAML object (pod.yaml):

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80

Then, run see-ctl:

go run cmd/see-ctl/main.go do create -f pod.yaml

Metrics

The SEE interface gathers metrics via the Kubernetes Metrics API and publishes them to a topic exchange on the AMQP server.

flowchart RL
    subgraph cluster[SEE Cluster]
    direction RL
    S[ <br><br> ]
    A[Metrics-<br>Server]

    subgraph B[Nodes]
    direction TB
    D[cAdvisor] --> C[kubelet]
    E[Container<br>runtime] --> D
    E1[Container<br>runtime] --> D
    P[pod data] -.- C
    end

    L[API<br>server]
    W[SEE Interface]
    C ---->|node level<br>resource metrics| A -->|metrics<br>API| L --> W
    end

    W ---> K[AMQP Server]

    classDef box fill:#fff,stroke:#000,stroke-width:1px,color:#000;
    class W,B,P,K,cluster,D,E,E1,A,L,C box
    classDef spacewhite fill:#ffffff,stroke:#fff,stroke-width:0px,color:#000
    class S spacewhite
    classDef nemo fill:#326ce5,stroke:#fff,stroke-width:1px,color:#fff;
    class W,K nemo
  • Producer P: SEE
  • Consumers C: Clients

Adapted from Resource metrics pipeline | Kubernetes (Source).

Nodes

flowchart LR
    P((P))
    X{{X}}
    Q1[[Q₁]]
    Q2[[Q₂]]
    C1((C₁))
    C2((C₂))

    P --> X
    X -- minikube --> Q1
    X -- * --> Q2
    Q1 --> C1
    Q2 --> C2

    classDef mermaid-producer fill:#a9def9,stroke:#444950
    classDef mermaid-exchange fill:#fae0e4,stroke:#444950
    classDef mermaid-queue fill:#ede7b1,stroke:#444950
    classDef mermaid-consumer fill:#d3f8e2,stroke:#444950

    class P mermaid-producer
    class X mermaid-exchange
    class Q1 mermaid-queue
    class Q2 mermaid-queue
    class C1 mermaid-consumer
    class C2 mermaid-consumer

Adapted from rabbitmq-website/src/components/Tutorials/T5DiagramTopicX.md.

  • Topic exchange: nemo.see.metrics.nodes
  • Routing key: <node_name>
  • Body: NodeMetrics

Example

  • Routing key: minikube
{
    "Timestamp": "2024-06-21T15:09:27Z",
    "Window": "1m0.195s",
    "Usage": {
        "cpu": "167776094n",
        "memory": "2148948Ki"
    }
}

Pods

flowchart LR
    P((P))
    X{{X}}
    Q1[[Q₁]]
    Q2[[Q₂]]
    C1((C₁))
    C2((C₂))

    P --> X
    X -- default.* --> Q1
    X -- *.rabbitmq --> Q1
    X -- # --> Q2
    Q1 --> C1
    Q2 --> C2

    classDef mermaid-producer fill:#a9def9,stroke:#444950
    classDef mermaid-exchange fill:#fae0e4,stroke:#444950
    classDef mermaid-queue fill:#ede7b1,stroke:#444950
    classDef mermaid-consumer fill:#d3f8e2,stroke:#444950

    class P mermaid-producer
    class X mermaid-exchange
    class Q1 mermaid-queue
    class Q2 mermaid-queue
    class C1 mermaid-consumer
    class C2 mermaid-consumer

Adapted from rabbitmq-website/src/components/Tutorials/T5DiagramTopicX.md.

  • Topic exchange: nemo.see.metrics.pods
  • Routing key: <namespace>.<pod_name>
  • Body: PodMetrics

Example

  • Routing key: default.rabbitmq-6cf5799f4c-5dmxf
{
    "timestamp": "2024-06-21T13:12:33Z",
    "window": "1m0.003s",
    "containers": [
        {
            "name": "rabbitmq",
            "usage": {
                "cpu": "5291035n",
                "memory": "207832Ki"
            }
        }
    ]
}

Resource Configuration

flowchart LR
    C((Client))
    S((Server))
    Q1[[nemo.see.&lt;verb&gt;]]
    Q2[[amq.gen-Xa2…]]
    Request["`Request
    reply_to=amq.gen-Xa2…
    correlation_id=018CC21B…`"]
    Reply["`Reply
    correlation_id=018CC21B…`"]

    C --- Request --> Q1 --> S --> Q2 --- Reply --> C

    
    classDef mermaid-producer fill:#a9def9,stroke:#444950
    classDef mermaid-exchange fill:#fae0e4,stroke:#444950
    classDef mermaid-queue fill:#ede7b1,stroke:#444950
    classDef mermaid-consumer fill:#d3f8e2,stroke:#444950
    classDef mermaid-msg fill:#ced4da,stroke:#444950

    class C mermaid-producer
    class Q1 mermaid-queue
    class Q2 mermaid-queue
    class S mermaid-consumer
    class Request mermaid-msg
    class Reply mermaid-msg

Adapted from rabbitmq-website/src/components/Tutorials/T6DiagramFull.md

  • Verbs: create, delete, apply, migrate
  • Queue: nemo.see.<verb>
  • Body: resource configuration: JSON or YAML
  • Response: error JSON or empty string
  • Corresponding kubectl command: kubectl <verb> -f FILENAME

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.