Skip to content

Commit

Permalink
keep sdk in repo for now
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Ciangottini <[email protected]>
  • Loading branch information
dciangot committed Sep 19, 2024
1 parent b9526ab commit 2e0bea3
Show file tree
Hide file tree
Showing 26 changed files with 996 additions and 0 deletions.
Binary file added example/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
Empty file added example/Dockerfile.mock
Empty file.
Empty file added example/README.md
Empty file.
48 changes: 48 additions & 0 deletions example/create_openapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
import os.path
from typing import List

from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from fastapi.responses import PlainTextResponse

import interlink

app = FastAPI()


@app.post("/create")
async def create_pod(pod: List[interlink.Pod]) -> interlink.CreateStruct:
raise NotImplementedError


@app.post("/delete")
async def delete_pod(pod: interlink.PodRequest) -> str:
raise NotImplementedError


@app.get("/status")
async def status_pod(pods: List[interlink.PodRequest]) -> List[interlink.PodStatus]:
raise NotImplementedError


@app.get("/getLogs", response_class=PlainTextResponse)
async def get_logs(req: interlink.LogRequest) -> bytes:
raise NotImplementedError


openapi_schema = os.path.join(
os.path.dirname(__file__), *["..", "docs", "openapi", "openapi.json"]
)

with open(openapi_schema, "w") as f:
json.dump(
get_openapi(
title="interLink sidecar",
version=os.environ.get("VERSION", "v0.0.0"),
openapi_version=app.openapi()["openapi"],
description="openapi spec for interLink apis <-> provider sidecar communication",
routes=app.routes,
),
f,
)
9 changes: 9 additions & 0 deletions example/interlink-docker/interlink/InterLinkConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VKTokenFile: "$HOME/interLink/token"
InterlinkAddress: "http://XXX.XXX.XXX.XXX"
SidecarURL: "http://docker-sidecar"
InterlinkPort: "3000"
SidecarPort: "4000"
ExportPodData: true
DataRootFolder: ".local/interlink/jobs/"
VerboseLogging: true
ErrorsOnlyLogging: false
46 changes: 46 additions & 0 deletions example/interlink-docker/interlink/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3.7'
services:
interlink:
build:
context: ../../../
dockerfile: docker/Dockerfile.interlink
restart: always
#network_mode: "host"
ports:
- 3000:3000
volumes:
- type: bind
source: ./
target: /etc/interlink
environment:
- INTERLINKCONFIGPATH=/etc/interlink/InterLinkConfig.yaml
# healthcheck:
# test: ["CMD", "/check.sh"]
# interval: 10s
# timeout: 10s
# retries: 3
# start_period: 5s
docker-sidecar:
image: ghcr.io/intertwin-eu/interlink-sidecar-docker:0.0.2-pre1
restart: always
privileged: true
cap_add:
- SYS_ADMIN
#network_mode: "host"
ports:
- 4000:4000
environment:
- INTERLINKCONFIGPATH=/etc/interlink/sidecarConfig.yaml
volumes:
- type: bind
source: ./
target: /etc/interlink
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
# healthcheck:
# test: ["CMD", "/check.sh"]
# interval: 10s
# timeout: 10s
# retries: 3
# start_period: 5s
15 changes: 15 additions & 0 deletions example/interlink-docker/interlink/sidecarConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SidecarURL: "http://docker-sidecar"
SidecarPort: "4000"
SbatchPath: "/usr/bin/sbatch"
ScancelPath: "/usr/bin/scancel"
SqueuePath: "/usr/bin/squeue"
CommandPrefix: ""
ExportPodData: true
DataRootFolder: ".local/interlink/jobs/"
Tsocks: false
TsocksPath: "$WORK/tsocks-1.8beta5+ds1/libtsocks.so"
TsocksLoginNode: "login01"
BashPath: /bin/bash
VerboseLogging: true
ErrorsOnlyLogging: false

21 changes: 21 additions & 0 deletions example/interlink-docker/test_pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Pod
metadata:
name: test-pod-cfg-cowsay-dciangot
namespace: vk
annotations:
slurm-job.vk.io/flags: "--job-name=test-pod-cfg -t 2800 --ntasks=8 --nodes=1 --mem-per-cpu=2000"
spec:
restartPolicy: Never
containers:
- image: ghcr.io/grycap/cowsay
command: ["/bin/sh"]
args: ["-c", "\"touch /tmp/test.txt && sleep 60 && echo \\\"hello muu\\\" | /usr/games/cowsay \" " ]
imagePullPolicy: Always
name: cowsayo
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/hostname: test-vk
tolerations:
- key: virtual-node.interlink/no-schedule
operator: Exists
11 changes: 11 additions & 0 deletions example/interlink-docker/vk/InterLinkConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VKTokenFile: "$HOME/interLink/token"
InterlinkAddress: "http://XXX.XXX.XXX.XXX"
CommandPrefix: ""
ExportPodData: true
ServiceAccount: "interlink"
Namespace: "vk"
VerboseLogging: true
ErrorsOnlyLogging: false
CPU: 100
Memory: 128Gi
Pod: 100
101 changes: 101 additions & 0 deletions example/interlink-docker/vk/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---

apiVersion: apps/v1
kind: Deployment
metadata:
name: test-vk
labels:
nodeName: test-vk
spec:
replicas: 1
selector:
matchLabels:
nodeName: test-vk
template:
metadata:
labels:
nodeName: test-vk
spec:
initContainers:
- name: settoken
image: "docker.io/alpine:3"
command: ["sh", "-c"]
args: ["touch /opt/interlink/token"]
volumeMounts:
- name: token
mountPath: /opt/interlink
containers:
- name: jaeger
image: jaegertracing/all-in-one:1.51
- name: inttw-vk
image: ghcr.io/intertwin-eu/interlink/virtual-kubelet-inttw:latest
#image: dciangot/vk:latest
imagePullPolicy: Always
#command: ["sleep", "infinity"]
env:
- name: NODENAME
value: test-vk
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
#- name: KUBECONFIG
# value: /etc/interlink/kubeconfig
- name: KUBELET_PORT
value: "10250"
- name: CONFIGPATH
value: "/etc/interlink/InterLinkConfig.yaml"
- name: VKTOKENFILE
value: "/opt/interlink/token"
volumeMounts:
- name: config
mountPath: /etc/interlink/InterLinkConfig.yaml
subPath: InterLinkConfig.yaml
- name: token
mountPath: /opt/interlink
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 50m
memory: 100Mi
- name: refresh-token
image: ghcr.io/intertwin-eu/virtual-kubelet-inttw-refresh:latest
imagePullPolicy: Always
env:
- name: IAM_SERVER
value: "https://dodas-iam.cloud.cnaf.infn.it/"
# TODO load env IAM client from secret
- name: IAM_CLIENT_ID
value: "DUMMY"
- name: IAM_CLIENT_SECRET
value: "DUMMY"
- name: IAM_REFRESH_TOKEN
value: "DUMMY"
- name: IAM_VK_AUD
value: intertw-vk
- name: TOKEN_PATH
value: /opt/interlink/token
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 50m
memory: 100Mi
volumeMounts:
- name: token
mountPath: /opt/interlink
serviceAccountName: interlink
volumes:
- name: config
configMap:
# Provide the name of the ConfigMap you want to mount.
name: vk-config
- name: kubeconfig
configMap:
# Provide the name of the ConfigMap you want to mount.
name: vk-kubeconfig
- name: token
emptyDir: {}
13 changes: 13 additions & 0 deletions example/interlink-docker/vk/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./deployment.yaml
- ./service-account.yaml

configMapGenerator:
- name: vk-config-json
files:
- vk-cfg.json=vk-cfg.json
- name: vk-config
files:
- InterLinkConfig.yaml=InterLinkConfig.yaml
41 changes: 41 additions & 0 deletions example/interlink-docker/vk/otecol_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679

receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4319
http:
endpoint: 0.0.0.0:4318

processors:
batch:

exporters:
otlp:
endpoint: "localhost:4317"
tls:
insecure: true
logging:
verbosity: detailed

service:

pipelines:

traces:
receivers: [otlp, opencensus, jaeger, zipkin]
processors: [batch]
exporters: [logging]

metrics:
receivers: [otlp, opencensus, prometheus]
processors: [batch]
exporters: [logging]

extensions: [health_check, pprof, zpages]
Loading

0 comments on commit 2e0bea3

Please sign in to comment.