@@ -25,19 +25,19 @@ def create_deployment_object():
25
25
# Configureate Pod template container
26
26
container = client .V1Container (
27
27
name = "nginx" ,
28
- image = "nginx:1.7.9 " ,
28
+ image = "nginx:1.15.4 " ,
29
29
ports = [client .V1ContainerPort (container_port = 80 )])
30
30
# Create and configurate a spec section
31
31
template = client .V1PodTemplateSpec (
32
32
metadata = client .V1ObjectMeta (labels = {"app" : "nginx" }),
33
33
spec = client .V1PodSpec (containers = [container ]))
34
34
# Create the specification of deployment
35
- spec = client .ExtensionsV1beta1DeploymentSpec (
35
+ spec = client .AppsV1beta1DeploymentSpec (
36
36
replicas = 3 ,
37
37
template = template )
38
38
# Instantiate the deployment object
39
- deployment = client .ExtensionsV1beta1Deployment (
40
- api_version = "extensions /v1beta1" ,
39
+ deployment = client .AppsV1beta1Deployment (
40
+ api_version = "apps /v1beta1" ,
41
41
kind = "Deployment" ,
42
42
metadata = client .V1ObjectMeta (name = DEPLOYMENT_NAME ),
43
43
spec = spec )
@@ -55,7 +55,7 @@ def create_deployment(api_instance, deployment):
55
55
56
56
def update_deployment (api_instance , deployment ):
57
57
# Update container image
58
- deployment .spec .template .spec .containers [0 ].image = "nginx:1.9.1 "
58
+ deployment .spec .template .spec .containers [0 ].image = "nginx:1.16.0 "
59
59
# Update the deployment
60
60
api_response = api_instance .patch_namespaced_deployment (
61
61
name = DEPLOYMENT_NAME ,
@@ -80,16 +80,16 @@ def main():
80
80
# utility. If no argument provided, the config will be loaded from
81
81
# default location.
82
82
config .load_kube_config ()
83
- extensions_v1beta1 = client .ExtensionsV1beta1Api ()
83
+ apps_v1beta1 = client .AppsV1beta1Api ()
84
84
# Create a deployment object with client-python API. The deployment we
85
85
# created is same as the `nginx-deployment.yaml` in the /examples folder.
86
86
deployment = create_deployment_object ()
87
87
88
- create_deployment (extensions_v1beta1 , deployment )
88
+ create_deployment (apps_v1beta1 , deployment )
89
89
90
- update_deployment (extensions_v1beta1 , deployment )
90
+ update_deployment (apps_v1beta1 , deployment )
91
91
92
- delete_deployment (extensions_v1beta1 )
92
+ delete_deployment (apps_v1beta1 )
93
93
94
94
95
95
if __name__ == '__main__' :
0 commit comments