15
15
from kubernetes import client , config
16
16
17
17
18
- def create_deployment (extensions_v1_beta1 ):
18
+ def create_deployment (apps_v1_api ):
19
19
container = client .V1Container (
20
20
name = "deployment" ,
21
- image = "ratanboddu/flaskapp:basic " ,
21
+ image = "gcr.io/google-appengine/fluentd-logger " ,
22
22
image_pull_policy = "Never" ,
23
23
ports = [client .V1ContainerPort (container_port = 5678 )],
24
24
)
@@ -27,18 +27,18 @@ def create_deployment(extensions_v1_beta1):
27
27
metadata = client .V1ObjectMeta (labels = {"app" : "deployment" }),
28
28
spec = client .V1PodSpec (containers = [container ]))
29
29
# Spec
30
- spec = client .ExtensionsV1beta1DeploymentSpec (
30
+ spec = client .V1DeploymentSpec (
31
31
replicas = 1 ,
32
32
template = template )
33
33
# Deployment
34
- deployment = client .ExtensionsV1beta1Deployment (
35
- api_version = "extensions/v1beta1 " ,
34
+ deployment = client .V1Deployment (
35
+ api_version = "apps/v1 " ,
36
36
kind = "Deployment" ,
37
37
metadata = client .V1ObjectMeta (name = "deployment" ),
38
38
spec = spec )
39
39
# Creation of the Deployment in specified namespace
40
40
# (Can replace "default" with a namespace you may have created)
41
- extensions_v1_beta1 .create_namespaced_deployment (
41
+ apps_v1_api .create_namespaced_deployment (
42
42
namespace = "default" , body = deployment
43
43
)
44
44
@@ -64,20 +64,20 @@ def create_service():
64
64
core_v1_api .create_namespaced_service (namespace = "default" , body = body )
65
65
66
66
67
- def create_ingress (extensions_v1_beta1 ):
68
- body = client .ExtensionsV1beta1Ingress (
67
+ def create_ingress (networking_v1_beta1_api ):
68
+ body = client .NetworkingV1beta1Ingress (
69
69
api_version = "networking.k8s.io/v1beta1" ,
70
70
kind = "Ingress" ,
71
71
metadata = client .V1ObjectMeta (name = "ingress-example" , annotations = {
72
72
"nginx.ingress.kubernetes.io/rewrite-target" : "/"
73
73
}),
74
- spec = client .ExtensionsV1beta1IngressSpec (
75
- rules = [client .ExtensionsV1beta1IngressRule (
74
+ spec = client .NetworkingV1beta1IngressSpec (
75
+ rules = [client .NetworkingV1beta1IngressRule (
76
76
host = "boddulabs.com" ,
77
- http = client .ExtensionsV1beta1HTTPIngressRuleValue (
78
- paths = [client .ExtensionsV1beta1HTTPIngressPath (
77
+ http = client .NetworkingV1beta1HTTPIngressRuleValue (
78
+ paths = [client .NetworkingV1beta1HTTPIngressPath (
79
79
path = "/" ,
80
- backend = client .ExtensionsV1beta1IngressBackend (
80
+ backend = client .NetworkingV1beta1IngressBackend (
81
81
service_port = 5678 ,
82
82
service_name = "service-example" )
83
83
@@ -89,7 +89,7 @@ def create_ingress(extensions_v1_beta1):
89
89
)
90
90
# Creation of the Deployment in specified namespace
91
91
# (Can replace "default" with a namespace you may have created)
92
- extensions_v1_beta1 .create_namespaced_ingress (
92
+ networking_v1_beta1_api .create_namespaced_ingress (
93
93
namespace = "default" ,
94
94
body = body
95
95
)
@@ -98,13 +98,12 @@ def create_ingress(extensions_v1_beta1):
98
98
def main ():
99
99
# Fetching and loading local Kubernetes Information
100
100
config .load_kube_config ()
101
- # For incluster details
102
- # config.load_incluster_config()
103
- extensions_v1_beta1 = client .ExtensionsV1beta1Api ()
101
+ apps_v1_api = client .AppsV1Api ()
102
+ networking_v1_beta1_api = client .NetworkingV1beta1Api ()
104
103
105
- create_deployment (extensions_v1_beta1 )
104
+ create_deployment (apps_v1_api )
106
105
create_service ()
107
- create_ingress (extensions_v1_beta1 )
106
+ create_ingress (networking_v1_beta1_api )
108
107
109
108
110
109
if __name__ == "__main__" :
0 commit comments