return ("x{0}".format(component_name))[:63]
def _configure_api():
- #TODO: real configuration
- config.load_kube_config(os.path.join(os.environ["HOME"], '.kube/config'))
+ # Look for a kubernetes config file in ~/.kube/config
+ kubepath = os.path.join(os.environ["HOME"], '.kube/config')
+ if os.path.exists(kubepath):
+ config.load_kube_config(kubepath)
+ else:
+ # Maybe we're running in a k8s container and we can use info provided by k8s
+ # We would like to use:
+ # config.load_incluster_config()
+ # but this looks into os.environ for kubernetes host and port, and from
+ # the plugin those aren't visible. So we use the InClusterConfigLoader class,
+ # where we can set the environment to what we like.
+ # This is probably brittle! Maybe there's a better alternative.
+ localenv = {
+ config.incluster_config.SERVICE_HOST_ENV_NAME : "kubernetes.default.svc.cluster.local",
+ config.incluster_config.SERVICE_PORT_ENV_NAME : "443"
+ }
+ config.incluster_config.InClusterConfigLoader(
+ token_filename=config.incluster_config.SERVICE_TOKEN_FILENAME,
+ cert_filename=config.incluster_config.SERVICE_CERT_FILENAME,
+ environ=localenv
+ ).load_and_set()
def _create_container_object(name, image, always_pull, env={}, container_ports=[], volume_mounts = []):
# Set up environment variables
<groupId>org.onap.dcaegen2.platform.plugins</groupId>
<artifactId>k8s</artifactId>
<name>k8s-plugin</name>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
setup(
name='k8splugin',
description='Cloudify plugin for containerized components deployed using Kubernetes',
- version="1.0.1",
+ version="1.1.0",
author='J. F. Lucas, Michael Hwang, Tommy Carpenter',
packages=['k8splugin','k8sclient','msb','configure'],
zip_safe=False,