The Custom strategy allows you to provide your own deployment behavior.
The following is an example of the Custom strategy:
strategy:
type: Custom
customParams:
image: organization/strategy
command: [ "command", "arg1" ]
environment:
- name: ENV_1
value: VALUE_1
In the above example, the organization/strategy
container image provides the
deployment behavior. The optional command
array overrides any CMD
directive
specified in the image’s Dockerfile. The optional environment variables
provided are added to the execution environment of the strategy process.
Additionally, OpenShift Origin provides the following environment variables to the
deployment process:
Environment Variable |
Description |
OPENSHIFT_DEPLOYMENT_NAME
|
The name of the new deployment (a replication controller). |
OPENSHIFT_DEPLOYMENT_NAMESPACE
|
The name space of the new deployment. |
The replica count of the new deployment will initially be zero. The
responsibility of the strategy is to make the new deployment active using the
logic that best serves the needs of the user.
Alternatively, use customParams
to inject the custom deployment logic into the
existing deployment strategies. Provide a custom shell script logic and call the
openshift-deploy
binary. Users do not have to supply their custom deployer
container image, but the default OpenShift Origin deployer image will be used
instead:
strategy:
type: Rolling
customParams:
command:
- /bin/sh
- -c
- |
set -e
openshift-deploy --until=50%
echo Halfway there
openshift-deploy
echo Complete
This will result in following deployment:
Started deployment #2
--> Scaling up custom-deployment-2 from 0 to 2, scaling down custom-deployment-1 from 2 to 0 (keep 2 pods available, don't exceed 3 pods)
Scaling custom-deployment-2 up to 1
--> Reached 50% (currently 50%)
Halfway there
--> Scaling up custom-deployment-2 from 1 to 2, scaling down custom-deployment-1 from 2 to 0 (keep 2 pods available, don't exceed 3 pods)
Scaling custom-deployment-1 down to 1
Scaling custom-deployment-2 up to 2
Scaling custom-deployment-1 down to 0
--> Success
Complete
If the custom deployment strategy process requires access to the OpenShift Origin API or the
Kubernetes API the container that executes the strategy can use the service account token
available inside the container for authentication.