-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheks.py
50 lines (44 loc) · 1.36 KB
/
eks.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
from kubernetes import client, config
config.load_kube_config()
api_client = client.ApiClient()
deployment = client.V1Deployment(
metadata=client.V1ObjectMeta(name="flask-resume"),
spec=client.V1DeploymentSpec(
replicas=1,
selector=client.V1LabelSelector(
match_labels={"app": "flask-resume"}
),
template=client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(
labels={"app": "flask-resume"}
),
spec=client.V1PodSpec(
containers=[
client.V1Container(
name="my-flask-container",
image="363309830189.dkr.ecr.us-east-2.amazonaws.com/flask-resume:latest",
ports=[client.V1ContainerPort(container_port=5000)]
)
]
)
)
)
)
api_instance = client.AppsV1Api(api_client)
api_instance.create_namespaced_deployment(
namespace="default",
body=deployment
)
service = client.V1Service(
metadata=client.V1ObjectMeta(name="flask-resume"),
spec=client.V1ServiceSpec(
selector={"app": "flask-resume"},
ports=[client.V1ServicePort(port=5000)]
)
)
# Create the service
api_instance = client.CoreV1Api(api_client)
api_instance.create_namespaced_service(
namespace="default",
body=service
)