Skip to content

Instantly share code, notes, and snippets.

@detiber
Created June 15, 2017 19:49
Show Gist options
  • Save detiber/49cbca9f98fa206d68cc71417482f978 to your computer and use it in GitHub Desktop.
Save detiber/49cbca9f98fa206d68cc71417482f978 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
from github3 import login
from kubernetes.client.rest import ApiException
from openshift import config
from openshift.client import ApiClient, UserOpenshiftIoV1Api, V1Group
from yaml import load
...
def openshift_client():
api_client = config.new_client_from_config()
api_client.host = 'https://kubernetes.default.svc'
with open('/var/run/secrets/kubernetes.io/serviceaccount/token') as token_file:
api_client.config.api_key = {'authorization': token_file.read()}
with open('/var/run/secrets/kubernetes.io/serviceaccount/ca.crt') as ca_file:
api_client.config.ssl_ca_cert = ca_file.read()
return api_client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment