A Spring Cloud Deployer SPI implementation which extends Spring Cloud Deployer Kubernetes and adds functionality afforded by OpenShift 3 as the deployment environment.
The following app URI's/Resources are supported:
docker:
resources as supported by the Kubernetes deployermaven:
resources as supported by the Local deployer
The OpenShift deployer aims to implement most of the functionality available in the Kubernetes deployer.
This currently includes the ability to deploy/launch docker:
registered apps/tasks.
Some Kubernetes functionality is implemented in more OpenShift specific ways.
For example, the LoadBalancer
option is implemented as a
Route
resource in OpenShift.
An example stream definition can be deployed as follows:
dataflow:>app register --type source --name time --uri docker:springcloudstream/time-source-kafka:latest
Successfully registered application 'source:time'
dataflow:>app register --type sink --name log --uri docker:springcloudstream/log-sink-kafka:latest
Successfully registered application 'sink:log'
dataflow:>stream create --name timelog --definition "time | log"
Created new stream 'timelog'
dataflow:>stream deploy timelog
Deployed stream 'timelog'
Apps or tasks registered with the maven:
URI are also supported by the OpenShift deployer.
An OpenShift BuildConfig/Build is triggered when
a Maven resource is deployed and there is no existing successful build for the same artifact.
The Build uses the Docker strategy
and various strategies to determine which input source to use:
- If a remote Git URI is specified when creating the stream/task definition using the
spring.cloud.deployer.openshift.build.git.uri
property, this repository will be used and has the highest precedence. - If
src/main/docker/Dockerfile
is detected in the Maven artifact Jar, then it is assumed that theDockerfile
will exist in that location in a remote Git repository. In that case, the Git repository source is used in conjunction with the Docker build strategy. The remote Git URI and ref are extracted from the<scm><connection></connection></scm>
and<scm><tag></tag></scm>
tags in thepom.xml
of the Maven Jar artifact. For example, if the<scm><connection>
value wasscm:git:[email protected]:spring-cloud/spring-cloud-dataflow.git
, then the remote Git URI would be parsed asssh://[email protected]:spring-cloud/spring-cloud-dataflow.git
. In short, theDockerfile
from the remote Git repository for the app being deployed will be used as the source for the image build. Of course, you can include and customise whatever and however you like in thisDockerfile
. - The other strategy uses the contents of a
Dockerfile
located in one of three locations as the Dockerfile source:- A file system location of a Dockerfile indicated by the
spring.cloud.deployer.openshift.deployment.dockerfile
deployment property. E.g.--properties "spring.cloud.deployer.openshift.deployment.dockerfile=/tmp/deployer/Dockerfile"
. The contents of this file will be used as the source input for the build. - The inline Dockerfile content as provided in the
spring.cloud.deployer.openshift.deployment.dockerfile
deployment property. E.g.--properties "spring.cloud.deployer.openshift.deployment.dockerfile=FROM java:8\n RUN wget ..."
- The default
Dockerfile
provided by the OpenShift deployer. Located insrc/main/resources
.
- A file system location of a Dockerfile indicated by the
An example stream definition can be deployed as follows:
dataflow:>app register --type source --name http --uri maven://org.springframework.cloud.stream.app:http-source-kafka:1.0.0.BUILD-SNAPSHOT
Successfully registered application 'source:time'
dataflow:>app register --type sink --name log --uri maven://org.springframework.cloud.stream.app:log-sink-kafka:1.0.0.BUILD-SNAPSHOT
Successfully registered application 'sink:log'
dataflow:>stream create --name httplog --definition "http | log"
Created new stream 'httplog'
dataflow:>stream deploy httplog
Deployed stream 'httplog'
Global deployer settings
spring.cloud.deployer.openshift.forceBuild
(default: false
)
Force a build to be triggered for every app deployment regardless of previous build status.
spring.cloud.deployer.openshift.defaultRoutingSubdomain
(default: router.default.svc.cluster.local
)
The default router subdomain to use for Route's. See here for more.
spring.cloud.deployer.openshift.build.git.secret
The source secret to be used if the remote Git repository requires authentication.
spring.cloud.deployer.openshift.image.tag
The default image tag to associate with Build's and DeploymentConfig's
Properties defined on the stream/task definition
spring.cloud.deployer.openshift.build.git.uri
A remote Git URI containing the Dockerfile
to use as the input source.
spring.cloud.deployer.openshift.build.git.ref
The Git branch/tag to use with the remote Git repository.
Properties defined on deployment of a defined stream/task
spring.cloud.deployer.openshift.build.git.dockerfile
The path where the Dockerfile is expected in the Git repository.
spring.cloud.deployer.openshift.build.git.secret
The source secret to be used if the remote Git repository requires authentication.
spring.cloud.deployer.openshift.forceBuild
Force an specific application to always trigger a new Build regardless of the previous build status.
spring.cloud.deployer.openshift.deployment.service.account
A Service Account that should be associated with the application container.
spring.cloud.deployer.openshift.image.tag
The default image tag to associate with Build's and DeploymentConfig's.
spring.cloud.deployer.openshift.deployment.dockerfile
An absolute path on the file system to a Dockerfile or an inline Dockerfile definition.
spring.cloud.deployer.openshift.deployment.nodeSelector
A comma separated list of labels which indicate where to schedule pods.
Labels are in the format region: primary,role: node
.
spring.cloud.deployer.openshift.deployment.route.host
The host
value to use for the Route resource.
spring.cloud.deployer.kubernetes.createLoadBalancer
/ spring.cloud.deployer.openshift.createRoute
Boolean flag indicating whether a Route resource should be created for an application.
The integration tests require a running OpenShift 3 instance. Specify the connection details to your running OpenShift instance as System properties/environment variables before running the tests. E.g.
$ export KUBERNETES_NAMESPACE=test
$ ./mvnw -Dopenshift.url=https://172.28.128.4:8443 \
-Dkubernetes.master=https://172.28.128.4:8443 \
-Dkubernetes.trust.certificates=true \
-Dkubernetes.auth.basic.username=admin \
-Dkubernetes.auth.basic.password=admin \
test
Please see the following posts for more information: