Skip to content

Instantly share code, notes, and snippets.

@pathcl
Created March 12, 2020 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathcl/ae528942c696d980068a4d3f52e79008 to your computer and use it in GitHub Desktop.
Save pathcl/ae528942c696d980068a4d3f52e79008 to your computer and use it in GitHub Desktop.
kubernetes python api example
#
from kubernetes import client, config
from kubernetes.utils import create_from_yaml
k8s_config = config.load_kube_config(
config_file="/yourkubeconfig/kubeconfig")
k8s_client = client.api_client.ApiClient(configuration=k8s_config)
# taken from here https://raw.githubusercontent.com/pathcl/hellok8s/master/helloworld.yaml
create_from_yaml(yaml_file='helloworld.yaml',
k8s_client=k8s_client, verbose=True, namespace="default")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment