8000 Merge pull request #1 from FingerLiu/example-patch-deployment · FingerLiu/client-python@94336ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 94336ba

Browse files
authored
Merge pull request #1 from FingerLiu/example-patch-deployment
Add example to patch a deployment
2 parents dbb0908 + cd8e17f commit 94336ba

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

examples/patch_deployment.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2016 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pprint import pprint
16+
17+
from kubernetes import client, config
18+
19+
20+
def main():
21+
"""
22+
Update image of container1 in deployment deploy1:
23+
"""
24+
# Configs can be set in Configuration class directly or using helper
25+
# utility. If no argument provided, the config will be loaded from
26+
# default location.
27+
config.load_kube_config()
28+
29+
api_instance = client.AppsV1beta1Api()
30+
31+
body = {
32+
"spec": {
33+
"template": {
34+
"spec": {
35+
"containers": [
36+
{
37+
"name": "container1",
38+
"image":"gcr.io/xxx/image:tag"
39+
}
40+
]
41+
}
42+
}
43+
}
44+
}
45+
46+
api_response = api_instance.patch_namespaced_deployment('deploy1', 'default', body, pretty=True)
47+
48+
pprint(api_response)
49+
50+
51+
if __name__ == '__main__':
52+
main()

0 commit comments

Comments
 (0)
0