Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 36f2129

Browse filesBrowse files
k8s-ci-robotfabianvf
authored andcommitted
Merge pull request kubernetes-client#888 from micw523/update-nginx
Deprecate extensions/v1beta1 deployment (cherry picked from commit 41971cc)
1 parent 59f4bfd commit 36f2129
Copy full SHA for 36f2129

11 files changed

+68
-80
lines changed

‎examples/create_deployment.py

Copy file name to clipboardExpand all lines: examples/create_deployment.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def main():
2727

2828
with open(path.join(path.dirname(__file__), "nginx-deployment.yaml")) as f:
2929
dep = yaml.safe_load(f)
30-
k8s_beta = client.ExtensionsV1beta1Api()
31-
resp = k8s_beta.create_namespaced_deployment(
30+
k8s_apps_v1 = client.AppsV1Api()
31+
resp = k8s_apps_v1.create_namespaced_deployment(
3232
body=dep, namespace="default")
3333
print("Deployment created. status='%s'" % str(resp.status))
3434

‎examples/create_deployment_from_yaml.py

Copy file name to clipboardExpand all lines: examples/create_deployment_from_yaml.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def main():
2424
config.load_kube_config()
2525
k8s_client = client.ApiClient()
2626
utils.create_from_yaml(k8s_client, "nginx-deployment.yaml")
27-
k8s_api = client.ExtensionsV1beta1Api(k8s_client)
27+
k8s_api = client.AppsV1Api(k8s_client)
2828
deps = k8s_api.read_namespaced_deployment("nginx-deployment", "default")
2929
print("Deployment {0} created".format(deps.metadata.name))
3030

‎examples/deployment_examples.py

Copy file name to clipboardExpand all lines: examples/deployment_examples.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ def create_deployment_object():
2525
# Configureate Pod template container
2626
container = client.V1Container(
2727
name="nginx",
28-
image="nginx:1.7.9",
28+
image="nginx:1.15.4",
2929
ports=[client.V1ContainerPort(container_port=80)])
3030
# Create and configurate a spec section
3131
template = client.V1PodTemplateSpec(
3232
metadata=client.V1ObjectMeta(labels={"app": "nginx"}),
3333
spec=client.V1PodSpec(containers=[container]))
3434
# Create the specification of deployment
35-
spec = client.ExtensionsV1beta1DeploymentSpec(
35+
spec = client.AppsV1beta1DeploymentSpec(
3636
replicas=3,
3737
template=template)
3838
# Instantiate the deployment object
39-
deployment = client.ExtensionsV1beta1Deployment(
40-
api_version="extensions/v1beta1",
39+
deployment = client.AppsV1beta1Deployment(
40+
api_version="apps/v1beta1",
4141
kind="Deployment",
4242
metadata=client.V1ObjectMeta(name=DEPLOYMENT_NAME),
4343
spec=spec)
@@ -55,7 +55,7 @@ def create_deployment(api_instance, deployment):
5555

5656
def update_deployment(api_instance, deployment):
5757
# 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"
5959
# Update the deployment
6060
api_response = api_instance.patch_namespaced_deployment(
6161
name=DEPLOYMENT_NAME,
@@ -80,16 +80,16 @@ def main():
8080
# utility. If no argument provided, the config will be loaded from
8181
# default location.
8282
config.load_kube_config()
83-
extensions_v1beta1 = client.ExtensionsV1beta1Api()
83+
apps_v1beta1 = client.AppsV1beta1Api()
8484
# Create a deployment object with client-python API. The deployment we
8585
# created is same as the `nginx-deployment.yaml` in the /examples folder.
8686
deployment = create_deployment_object()
8787

88-
create_deployment(extensions_v1beta1, deployment)
88+
create_deployment(apps_v1beta1, deployment)
8989

90-
update_deployment(extensions_v1beta1, deployment)
90+
update_deployment(apps_v1beta1, deployment)
9191

92-
delete_deployment(extensions_v1beta1)
92+
delete_deployment(apps_v1beta1)
9393

9494

9595
if __name__ == '__main__':

‎examples/nginx-deployment.yaml

Copy file name to clipboardExpand all lines: examples/nginx-deployment.yaml
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: nginx-deployment
5+
labels:
6+
app: nginx
57
spec:
68
replicas: 3
9+
selector:
10+
matchLabels:
11+
app: nginx
712
template:
813
metadata:
914
labels:
1015
app: nginx
1116
spec:
1217
containers:
1318
- name: nginx
14-
image: nginx:1.7.9
19+
image: nginx:1.15.4
1520
ports:
1621
- containerPort: 80
17-

‎examples/notebooks/create_deployment.ipynb

Copy file name to clipboardExpand all lines: examples/notebooks/create_deployment.ipynb
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"outputs": [],
4848
"source": [
4949
"config.load_kube_config()\n",
50-
"extension = client.ExtensionsV1beta1Api()"
50+
"apps_api = client.AppsV1beta1Api()"
5151
]
5252
},
5353
{
@@ -70,7 +70,7 @@
7070
},
7171
"outputs": [],
7272
"source": [
73-
"deployment = client.ExtensionsV1beta1Deployment()"
73+
"deployment = client.AppsV1beta1Deployment()"
7474
]
7575
},
7676
{
@@ -93,7 +93,7 @@
9393
},
9494
"outputs": [],
9595
"source": [
96-
"deployment.api_version = \"extensions/v1beta1\"\n",
96+
"deployment.api_version = \"apps/v1beta1\"\n",
9797
"deployment.kind = \"Deployment\"\n",
9898
"deployment.metadata = client.V1ObjectMeta(name=\"nginx-deployment\")"
9999
]
@@ -118,7 +118,7 @@
118118
},
119119
"outputs": [],
120120
"source": [
121-
"spec = client.ExtensionsV1beta1DeploymentSpec()\n",
121+
"spec = client.AppsV1beta1DeploymentSpec()\n",
122122
"spec.replicas = 3"
123123
]
124124
},
@@ -207,7 +207,7 @@
207207
},
208208
"outputs": [],
209209
"source": [
210-
"extension.create_namespaced_deployment(namespace=\"default\", body=deployment)"
210+
"apps_api.create_namespaced_deployment(namespace=\"default\", body=deployment)"
211211
]
212212
},
213213
{
@@ -253,7 +253,7 @@
253253
},
254254
"outputs": [],
255255
"source": [
256-
"extension.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)"
256+
"apps_api.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)"
257257
]
258258
},
259259
{
@@ -277,10 +277,10 @@
277277
},
278278
"outputs": [],
279279
"source": [
280-
"rollback = client.ExtensionsV1beta1DeploymentRollback()\n",
281-
"rollback.api_version = \"extensions/v1beta1\"\n",
280+
"rollback = client.AppsV1beta1DeploymentRollback()\n",
281+
"rollback.api_version = \"apps/v1beta1\"\n",
282282
"rollback.kind = \"DeploymentRollback\"\n",
283-
"rollback.rollback_to = client.ExtensionsV1beta1RollbackConfig()\n",
283+
"rollback.rollback_to = client.AppsV1beta1RollbackConfig()\n",
284284
"rollback.rollback_to.revision = 0\n",
285285
"rollback.name = \"nginx-deployment\""
286286
]

‎examples/notebooks/intro_notebook.ipynb

Copy file name to clipboardExpand all lines: examples/notebooks/intro_notebook.ipynb
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
},
9090
"outputs": [],
9191
"source": [
92-
"api_instance = client.ExtensionsV1beta1Api()\n",
93-
"dep = client.ExtensionsV1beta1Deployment()\n",
94-
"spec = client.ExtensionsV1beta1DeploymentSpec()"
92+
"api_instance = client.AppsV1beta1Api()\n",
93+
"dep = client.AppsV1beta1Deployment()\n",
94+
"spec = client.AppsV1beta1DeploymentSpec()"
9595
]
9696
},
9797
{

‎kubernetes/e2e_test/test_utils.py

Copy file name to clipboardExpand all lines: kubernetes/e2e_test/test_utils.py
+12-25Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,6 @@ def test_create_apps_deployment_from_yaml(self):
5252
name="nginx-app", namespace="default",
5353
body={})
5454

55-
def test_create_extensions_deployment_from_yaml(self):
56-
"""
57-
Should be able to create an extensions/v1beta1 deployment.
58-
"""
59-
k8s_client = client.api_client.ApiClient(configuration=self.config)
60-
utils.create_from_yaml(
61-
k8s_client, self.path_prefix + "extensions-deployment.yaml")
62-
ext_api = client.ExtensionsV1beta1Api(k8s_client)
63-
dep = ext_api.read_namespaced_deployment(name="nginx-deployment",
64-
namespace="default")
65-
self.assertIsNotNone(dep)
66-
ext_api.delete_namespaced_deployment(
67-
name="nginx-deployment", namespace="default",
68-
body={})
69-
7055
def test_create_pod_from_yaml(self):
7156
"""
7257
Should be able to create a pod.
@@ -134,7 +119,7 @@ def test_create_deployment_non_default_namespace_from_yaml(self):
134119
utils.create_from_yaml(
135120
k8s_client, self.path_prefix + "dep-deployment.yaml")
136121
core_api = client.CoreV1Api(k8s_client)
137-
ext_api = client.ExtensionsV1beta1Api(k8s_client)
122+
ext_api = client.AppsV1Api(k8s_client)
138123
nmsp = core_api.read_namespace(name="dep")
139124
self.assertIsNotNone(nmsp)
140125
dep = ext_api.read_namespaced_deployment(name="nginx-deployment",
@@ -186,7 +171,7 @@ def test_create_general_list_from_yaml(self):
186171
utils.create_from_yaml(
187172
k8s_client, self.path_prefix + "list.yaml")
188173
core_api = client.CoreV1Api(k8s_client)
189-
ext_api = client.ExtensionsV1beta1Api(k8s_client)
174+
ext_api = client.AppsV1Api(k8s_client)
190175
svc = core_api.read_namespaced_service(name="list-service-test",
191176
namespace="default")
192177
self.assertIsNotNone(svc)
@@ -317,7 +302,7 @@ def test_create_from_multi_resource_yaml_with_conflict(self):
317302

318303
def test_create_from_multi_resource_yaml_with_multi_conflicts(self):
319304
"""
320-
Should create an extensions/v1beta1 deployment
305+
Should create an apps/v1 deployment
321306
and fail to create the same deployment twice.
322307
Should raise an exception that contains two error messages.
323308
"""
@@ -327,14 +312,14 @@ def test_create_from_multi_resource_yaml_with_multi_conflicts(self):
327312
k8s_client, self.path_prefix + "triple-nginx.yaml")
328313
exp_error = ('Error from server (Conflict): {"kind":"Status",'
329314
'"apiVersion":"v1","metadata":{},"status":"Failure",'
330-
'"message":"deployments.extensions \\"triple-nginx\\" '
315+
'"message":"deployments.apps \\"triple-nginx\\" '
331316
'already exists","reason":"AlreadyExists",'
332-
'"details":{"name":"triple-nginx","group":"extensions",'
317+
'"details":{"name":"triple-nginx","group":"apps",'
333318
'"kind":"deployments"},"code":409}\n'
334319
)
335320
exp_error += exp_error
336321
self.assertEqual(exp_error, str(cm.exception))
337-
ext_api = client.ExtensionsV1beta1Api(k8s_client)
322+
ext_api = client.AppsV1Api(k8s_client)
338323
dep = ext_api.read_namespaced_deployment(name="triple-nginx",
339324
namespace="default")
340325
self.assertIsNotNone(dep)
@@ -348,7 +333,8 @@ def test_create_namespaces_apps_deployment_from_yaml(self):
348333
"""
349334
k8s_client = client.api_client.ApiClient(configuration=self.config)
350335
utils.create_from_yaml(
351-
k8s_client, self.path_prefix + "apps-deployment.yaml", namespace=self.test_namespace)
336+
k8s_client, self.path_prefix + "apps-deployment.yaml",
337+
namespace=self.test_namespace)
352338
app_api = client.AppsV1beta1Api(k8s_client)
353339
dep = app_api.read_namespaced_deployment(name="nginx-app",
354340
namespace=self.test_namespace)
@@ -357,14 +343,15 @@ def test_create_namespaces_apps_deployment_from_yaml(self):
357343
name="nginx-app", namespace=self.test_namespace,
358344
body={})
359345

360-
def test_create_from_list_in_multi_resource_yaml(self):
346+
def test_create_from_list_in_multi_resource_yaml_namespaced(self):
361347
"""
362348
Should be able to create the items in the PodList and a deployment
363-
specified in the multi-resource file
349+
specified in the multi-resource file in a test namespace
364350
"""
365351
k8s_client = client.api_client.ApiClient(configuration=self.config)
366352
utils.create_from_yaml(
367-
k8s_client, self.path_prefix + "multi-resource-with-list.yaml", namespace=self.test_namespace)
353+
k8s_client, self.path_prefix + "multi-resource-with-list.yaml",
354+
namespace=self.test_namespace)
368355
core_api = client.CoreV1Api(k8s_client)
369356
app_api = client.AppsV1beta1Api(k8s_client)
370357
pod_0 = core_api.read_namespaced_pod(

‎kubernetes/e2e_test/test_yaml/dep-deployment.yaml

Copy file name to clipboardExpand all lines: kubernetes/e2e_test/test_yaml/dep-deployment.yaml
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
apiVersion: extensions/v1beta1
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: nginx-deployment
55
namespace: dep
66
spec:
77
replicas: 3
8+
selector:
9+
matchLabels:
10+
app: nginx
811
template:
912
metadata:
1013
labels:
1114
app: nginx
1215
spec:
1316
containers:
1417
- name: nginx
15-
image: nginx:1.7.9
18+
image: nginx:1.15.4
1619
ports:
1720
- containerPort: 80
18-

‎kubernetes/e2e_test/test_yaml/extensions-deployment.yaml

Copy file name to clipboardExpand all lines: kubernetes/e2e_test/test_yaml/extensions-deployment.yaml
-17Lines changed: 0 additions & 17 deletions
This file was deleted.

‎kubernetes/e2e_test/test_yaml/list.yaml

Copy file name to clipboardExpand all lines: kubernetes/e2e_test/test_yaml/list.yaml
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ items:
1111
port: 80
1212
selector:
1313
app: list-deployment-test
14-
- apiVersion: extensions/v1beta1
14+
- apiVersion: apps/v1
1515
kind: Deployment
1616
metadata:
1717
name: list-deployment-test
1818
labels:
1919
app: list-deployment-test
2020
spec:
2121
replicas: 1
22+
selector:
23+
matchLabels:
24+
app: list-deployment-test
2225
template:
2326
metadata:
2427
labels:
2528
app: list-deployment-test
2629
spec:
2730
containers:
2831
- name: nginx
29-
image: nginx
32+
image: nginx:1.15.4

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.