OpenShift plugin
With the Deploy OpenShift plugin, you can deploy OpenShift and Kubernetes resource types directly from Deploy.
For information about the plugin requirements and the supported OpenShift version, see the OpenShift Plugin Reference.
The supported basic resource types are:
Project
- a Kubernetes namespace with additional annotations, and the main entity used to deploy and manage resourcesPod
- one or more Docker containers running on a host machineService
- an internal load balancer that exposes a number of pods connected to itRoute
- a route exposes a service at a hostname and makes it available externallyImageStream
- a number of Docker container images identified by a tagBuildConfig
- the definition of a build process, which involves taking input parameters or source code and producing a runnable Docker imageDeploymentConfig
- the definition of a deployment strategy, which involves the creation of a Replication Controller, the triggers to create a new deployment, the strategy for transitioning between deployments, and the life cycle hooks
Features
- Creating Projects
- Configuring ImageStreams
- Deploying containers in the form of DeploymentConfigs including all the configuration settings such as environment variables, networking and volume settings, as well as liveness and readiness probes
- Deploying volume configuration through PersistentVolumes, PersistentVolumeClaims, and StorageClasses
- Deploying proxy objects such as Services and Routes
- Deploying configuration objects such as ConfigMaps and Secrets
Setup in OpenShift
To deploy on OpenShift, you must have two parameters:
- the OpenShift instance URL
- the authentication token
To retrieve the parameters:
- Log in to the web interface of OpenShift, click on the ? symbol on the top right of the page, and select Command Line Tools.
- Click on the copy link next to After downloading and installing it, you can start by logging in using this current session token:.
This provides you with a command string in the copy buffer. Paste the string in a location to display it. The string should look like this: oc login <server url> --token=<token>
.
For information about the instance URL, see example
And your token will be (example): MF7tvOr8PR2F2WvkrJ11flPAiGW6u98hkPuORusyqTC
Initial deployment
To deploy on OpenShift, you must create a Project.
To create a new project:
- Hover over Infrastructure, click , and select New > OpenShift > Server.
- Enter the Name, Server URL, and the OpenShift Token. If the server is self-hosted and does not have a valid HTTPS certificate, un-check the Verify Certificates checkbox.
- Hover over Environments, click , select New > Environment, and add it as a member of the previously created Infrastructure.
- Hover over Applications, click , select New > Application, and call it Projects. Under the new application, create a New > Provisioning Package and call it First Project.
Inside First Project you can create a New > OpenShift > ProjectSpec.
You can use the same string for all parameters (Name, Project Name, Description, and Project Display Name). In this example you can use: xld-first-project
.
To deploy your first project on OpenShift:
Hover over the First Project, click , select Deploy, and the select the previously created environment to deploy the project.
Deploying resources
With a project already deployed, you can deploy resources to it.
- Create a new application with the name Resources and create a New > Deployment Package with the name First Resources. Under First Resources, create a New > OpenShift > ResourcesFile.
- Specify the name hello-pod for the new ResourcesFile and do not enter information in the other text fields. Add the following code to the new
hello-pod.json
file and load it as an artifact:{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "hello-openshift",
"creationTimestamp": null,
"labels": {
"name": "hello-openshift"
}
},
"spec": {
"containers": [
{
"name": "hello-openshift",
"image": "openshift/hello-openshift",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name":"tmp",
"mountPath":"/tmp"
}
],
"terminationMessagePath": "/dev/termination-log",
"imagePullPolicy": "IfNotPresent",
"capabilities": {},
"securityContext": {
"capabilities": {},
"privileged": false
}
}
],
"volumes": [
{
"name":"tmp",
"emptyDir": {}
}
],
"restartPolicy": "Always",
"dnsPolicy": "ClusterFirst",
"serviceAccount": ""
},
"status": {}
} - Load the new artifact into Deploy and save it.
- Click on First Resources and deploy the pod. When the pod is running, you can create a service that maps to it.
- Under the First Resources deployment package, create a New > OpenShift > ResourcesFile and enter the name hello-service. Add the following code to the new
hello-service.json
file and load it as an artifact:{
"metadata": {
"name": "hello-openshift"
},
"kind": "Service",
"spec": {
"sessionAffinity": "None",
"ports": [
{
"targetPort": 8080,
"nodePort": 0,
"protocol": "TCP",
"port": 80
}
],
"type": "ClusterIP",
"selector": {
"name": "hello-openshift"
}
},
"apiVersion": "v1"
} - Load the artifact into Deploy and save it. You can re-deploy the First Resources deployment package to add the
hello-service
service to the OpenShift instance.
Create a route resource
The new pod has the port 8080 exposed and the service connected to it exposes port 80. To make the pod and service externally reachable, you must create a new route.
- To create a route, click New > OpenShift > ResourcesFile and enter the name hello-route. Add the following code into the new
hello-route.json
file and load it as an artifact:{
"metadata": {
"name": "hello-route"
},
"kind": "Route",
"spec": {
"to": {
"kind": "Service",
"name": "hello-openshift"
}
},
"apiVersion": "v1"
} - Load the artifact into Deploy and save it. Re-deploy the First Resources deployment package to allow the new route to expose the service connected to a pod. If you go to the OpenShift Console, it should show the public URL. Click the URL to display the
Hello Openshift!
message.