in source/compute_plane/python/lambda/drainer/handler.py [0:0]
def create_kube_config(eks, cluster_name):
"""Creates the Kubernetes config file required when instantiating the API client."""
cluster_info = eks.describe_cluster(name=cluster_name)['cluster']
certificate = cluster_info['certificateAuthority']['data']
endpoint = cluster_info['endpoint']
kube_config = {
'apiVersion': 'v1',
'clusters': [
{
'cluster':
{
'server': endpoint,
'certificate-authority-data': certificate
},
'name': 'k8s'
}],
'contexts': [
{
'context':
{
'cluster': 'k8s',
'user': 'aws'
},
'name': 'aws'
}],
'current-context': 'aws',
'Kind': 'config',
'users': [
{
'name': 'aws',
'user': 'lambda'
}]
}
with open(KUBE_FILEPATH, 'w') as f:
yaml.dump(kube_config, f, default_flow_style=False)