fabric8:create-routes
The maven fabric8:create-routes
goal queries all the Services in the current namespace which expose ports 80 or 443 and create a new OpenShift Route if one doesn't already exist
You can use the maven property fabric8.domain
or the environment variable $KUBERNETES_DOMAIN
to define the DNS host to expose services as OpenShift Routes
For a summary of the options see the Maven Property Reference
Default Configuration
The Kubernetes environment and authentication is defined by the kubernetes-api environment variables. In particular:
KUBERNETES_MASTER
- the location of the kubernetes masterKUBERNETES_NAMESPACE
- the default namespace used on operations
Defaults from OpenShift
If no configuration is supplied through maven properties or environment variables, the fabric8:create-routes
goal will try to find the current login token and namespace by parsing the users ~/.kube/config
file.
This means that if you use the OpenShift command line tool oc
you can login and change projects (namespaces in kubernetes speak) and those will be used by default by the fabric8:create-routes
goal. e.g.
oc login
oc project cheese
mvn fabric8:create-routes
In the above, if there is no KUBERNETES_NAMESPACE
environment variable or maven property called fabric8.namespace
then the fabric8:create-routes
goal will apply the Kubernetes resources to the cheese
namespace.
Example
To generate any missing routes for services use the following goal:
mvn fabric8:create-routes
Note if you are not in a maven project which has the fabric8 maven plugin enabled then you can use the more verbose version:
mvn io.fabric8:fabric8-maven-plugin:2.2.89:create-routes
To specify an explicit namespace and domain in recreate mode:
mvn fabric8:create-routes -Dfabric8.domain=foo.acme.com -Dfabric8.namespace=cheese
Templates
Applying an OpenShift template works the same as a regular List
of Kubernetes resources.
One difference is that you may wish to override some of the template parameter values as you apply the template which you can do on the command line via system properties.
mvn fabric8:create-routes -Dfabric8.apply.FOO=bar
The above will apply the OpenShift template defined in target/classes/kubernetes.json
overriding the template parameter FOO
with the value bar
before processing the template and creating/updating the resources.
Maven Properties
The following maven property values are used to configure the behaviour of the apply goal:
Parameter | Description |
---|---|
fabric8.domain | The domain to expose the services as OpenShift Routes. Defaults to $KUBERNETES_DOMAIN . |
fabric8.namespace | Specifies the namespace (or OpenShift project name) to apply the kubernetes resources to. If not specified it will use the KUBERNETES_NAMESPACE environment variable or use the Defaults from OpenShift |