fabric8
fabric8 copied to clipboard
provide a fabric8 goal to run a docker container as if its inside a kubernetes environment
its gonna be handy to run a local docker build as if it were part of a kubernetes cluster; but without having to push the image onto kubernetes and create a Replication Controller using it etc.
i.e. just run a single docker container as if its been created by a Replication Controller.
Mostly thats just
- use the env vars from the kubernetes.json file
- set the env vars from the services available in a namespace on a remote kubernetes environment
- ensure that any service IPs are accessible (e.g. use routes if they are available - if not am not sure how else we can do that bit - for http we could use api/v1beta2/proxy/service/foo but for TCP stuff I'm not sure ;)
I guess DNS should fix the service IPs thing ultimately? Or maybe this only works for services with a route?
this relates to https://github.com/rhuss/docker-maven-plugin/issues/119 as well - if we're a really fast way to spin up a docker container using a local build; we'd want to set the env vars properly so it can reuse the kubernetes configuration and services
I wonder, as this is mostly about setting env vars - if we could somehow have a tool to generate the env vars for a namespace to a temporary local file - that the docker plugin could reuse?
e.g. we generate target/docker/envVars.properties or something which the docker:run maven plugin reuses if its present (and enabled) to set the env vars when running things?
As mostly all those env vars should be static for a single namespace (once the services are all created)
I just raised this issue on docker-maven-plugin to make it easier to pass in a file for the environment variables https://github.com/rhuss/docker-maven-plugin/issues/128 for times when we want to generate environment variables programatically - e.g. via using the REST API on a remote kubernetes environment
Maybe we need to generate 2 files for the kubernetes services environment variables
- properties file that the docker maven plugin (or maven properties plugin) can reuse
- a shell script file containing export commands so that folks can source it on their shell...
export FOO_SERVICE_HOST=blah
export FOO_SERVICE_PORT=123
...
then folks could type:
source target/fabric8/env.sh
to then have their local environment variables defined as if they are running inside kubernetes; so that folks could use "mvn exec:java" and the like...
We don't need to use maven properties plugin. Since we create a mojo of our own, to create the properties file, that mojo can also set the properties to "project properties". Then the docker maven plugin can find them.