Created
June 8, 2017 22:43
-
-
Save djkonro/2a2d162203e22a09b06cc8ca86a9586a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kubernetes import client, config | |
config.load_kube_config() | |
# create an instance of the API class | |
api_instance = client.CoreV1Api() | |
service = client.V1Service() | |
service.api_version = 'v1' | |
service.kind = 'Service' | |
service.metadata = client.V1ObjectMeta(name='my-service') | |
spec = client.V1ServiceSpec() | |
spec.selector = {'app': 'MyApp'} | |
spec.ports = [client.V1ServicePort(protocol='TCP', port=80, target_port='9376')] | |
service.spec = spec | |
api_response = api_instance.create_namespaced_service(namespace='default', body=service) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment