-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_python.py
51 lines (47 loc) · 1.24 KB
/
test_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from os import path, mkdir
import yaml
from kubernetes import client, config
from time import sleep
config.load_incluster_config()
with open(path.join(path.dirname(__file__), "job-node_DaemonSet.yaml")) as yaml_file:
daemon = yaml.safe_load(yaml_file)
apply_resp = client.AppsV1Api().create_namespaced_daemon_set(body=daemon, namespace="default")
pods_name = apply_resp.metadata.name
print("DaemonSet created. Daemon-Set name='%s'" % apply_resp.metadata.name)
sleep(30)
client.AppsV1Api().delete_namespaced_daemon_set(name=pods_name, namespace="default")
"""
apiVersion: apps/v1
kind: Deployment
metadata:
name: python-deployment
labels:
app: python-kube_bench
spec:
replicas: 1
selector:
matchLabels:
app: python-kube_bench
template:
metadata:
labels:
app: python-kube_bench
spec:
containers:
- name: python-cont
image: daipayan95/python-cont:latest
command: ["/bin/sh"]
---
apiVersion: v1
kind: Pod
metadata:
name: python-pod
labels:
app: python-kube_bench
spec:
containers:
- name: python-cont
image: daipayan95/python-cont:latest
#command: ["sleep", "120"]
{"fruit": "Apple","size": "Large","color": "Red"}
"""