File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
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 os import path
16
+
17
+ import yaml
18
+ from kubernetes import client , config
19
+
20
+
21
+ def main ():
22
+ # Configs can be set in Configuration class directly or using helper
23
+ # utility. If no argument provided, the config will be loaded from
24
+ # default location.
25
+ config .load_kube_config ()
26
+
27
+ with open (path .join (path .dirname (__file__ ), "nginx-deployment.yaml" )) as f :
28
+ dep = yaml .load (f )
29
+ k8s_beta = client .ExtensionsV1beta1Api ()
30
+ resp = k8s_beta .create_namespaced_deployment (
31
+ body = dep , namespace = "default" )
32
+ print ("Deployment created. status='%s'" % str (resp .status ))
33
+
34
+
35
+ if __name__ == '__main__' :
36
+ main ()
Original file line number Diff line number Diff line change
1
+ apiVersion : extensions/v1beta1
2
+ kind : Deployment
3
+ metadata :
4
+ name : nginx-deployment
5
+ spec :
6
+ replicas : 3
7
+ template :
8
+ metadata :
9
+ labels :
10
+ app : nginx
11
+ spec :
12
+ containers :
13
+ - name : nginx
14
+ image : nginx:1.7.9
15
+ ports :
16
+ - containerPort : 80
17
+
You can’t perform that action at this time.
0 commit comments