Skip to content

Commit

Permalink
add kube control for replay-verify
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand committed Oct 28, 2024
1 parent b92cbb8 commit 44c6628
Show file tree
Hide file tree
Showing 5 changed files with 526 additions and 0 deletions.
Binary file added testsuite/Users:bowu:projects:interna.textClipping
Binary file not shown.
14 changes: 14 additions & 0 deletions testsuite/replay-verify/controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: replay-verify
labels:
env: test
owner: bowu

spec:
containers:
- image: aptoslabs/tools:nightly
name: controller
ports:
- containerPort: 80
47 changes: 47 additions & 0 deletions testsuite/replay-verify/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from kubernetes import client, config

def init():
print("Initializing the cluster ...")
config.load_kube_config()

def list_nodes():
v1 = client.CoreV1Api()
print("Listing nodes:")
ret = v1.list_node(watch=False)
for node in ret.items:
print(f"Node Name: {node.metadata.name}")

def create_pod(pod_name, image_name, namespace="default"):
v1 = client.CoreV1Api()

# Define the pod spec
pod = client.V1Pod(
metadata=client.V1ObjectMeta(name=pod_name),
spec=client.V1PodSpec(
containers=[client.V1Container(
name=pod_name,
image=image_name,
)],
restart_policy="Never"
)
)

try:
# Create the pod
response = v1.create_namespaced_pod(namespace=namespace, body=pod)
print(f"Pod {pod_name} created. Status: {response.status.phase}")
except client.exceptions.ApiException as e:
print(f"Exception when creating pod {pod_name}: {e}")

def create_pods(image_name, count=2, namespace="default"):
for i in range(count):
pod_name = f"pod-{i+1}"
create_pod(pod_name, image_name, namespace)

if __name__ == '__main__':
print("Starting the script...")
init()
list_nodes()

# Create 10 pods using the aptoslabs/tools:nightly image
create_pods("aptoslabs/tools:nightly", count=2, namespace="default")
Loading

0 comments on commit 44c6628

Please sign in to comment.