File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-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+
19+ from kubernetes import client , config
20+
21+
22+ def main ():
23+ # Configs can be set in Configuration class directly or using helper
24+ # utility. If no argument provided, the config will be loaded from
25+ # default location.
26+ config .load_kube_config ()
27+
28+ with open (path .join (path .dirname (__file__ ), "nginx-deployment.yaml" )) as f :
29+ dep = yaml .load (f )
30+ k8s_beta = client .ExtensionsV1beta1Api ()
31+ resp = k8s_beta .create_namespaced_deployment (
32+ body = dep , namespace = "default" )
33+ print ("Deployment created. status='%s'" % str (resp .status ))
34+
35+
36+ if __name__ == '__main__' :
37+ 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