Skip to content

dsf deployment dsf4openshift automatic configuration

travis edited this page Jul 11, 2019 · 1 revision

OpenShift deployment environment automatic configuration

In this section you will see how you can create a new environment instance in your OpenShift cluster to deploy devonfw projects using docker images.

Prerequisites

Add OpenShift Client to Jenkins

To integrate it, you need to have installed the plugin OpenShift Client. To install it go to Manage Jenkins clicking on left menu and enter in Manage Plugins. Go to Available tab and search it using the filter textbox in the top right corner and install it.

Configuration OpenShift Client in Jenkins

Second, you need to configure the OC Client. Go to Manage Jenkins clicking on left menu and enter in Global Tool Configuration.

Go to OpenShift Client Tools section and add a new one like this.

openshift jenkins plugin

devonfw project

You need to have a devonfw project in a git repository or a docker image uploaded to a docker registry.

Comunication between components

Jenkins must have access to git, docker registry and OpenShift.

Openshift must have access to docker registry.

Jenkinsfiles to Configure OpenShift

You can find one Jenkinsfile per devonfw technology in devonfw shop floor repository to configure automatically your OpenShift cluster.

How to use it

To use it you need to follow the next steps

Create a new pipeline

You need to create a new pipeline in your repository and point it to Jenkinsfile in devonfw shop floor repository.

openshift jenkins configure environments repo

Note: In the script path section you should use the Jenkinsfile of the technology that you need.

Build with parameters

The first time that you execute the pipeline is going to fail because Jenkins does not know that this pipeline needs parameters to execute. The better that you can do is stop it manually when Declarative: Checkout SCM is over.

Then you could see a button to Build with Parameters, click on it and fill the next form, these are the parameters:

Docker registry credentials for OpenShift

CREATE_SECRET: This option allows you to add the credentials of your docker registry in your OpenShift and stored it as a secret called docker-registry + registry_secret_name_suffix value.

Remember that you only need one secret to connect with your registry per namespace, if you are going to add more than one application in the same namespace that use the same registry, use the same name suffix and please do not create more than one secret in the same namespace. The namespace is the OpenShift project when you are going to deploy your application.

You can see your secrets stored in OpenShift going to OpenShift and click on the left menu:

openshift secrets menu
Note
If the secret exists, you should uncheck the checkbox and fill the name suffix to use it.

REGISTRY_SECRET_NAME_SUFFIX: This is the suffix of the name for your docker registry credentials stored in OpenShift as a secret. The name is going to be docker-registry + this suffix, if you use more than one docker-registry in the same namespace you need to add a suffix. For example you could add the name of your project, then to have the name as docker-registry-myprojectname you should use -myprojectname value.

Build your docker image using OpenShift and store it in your docker registry

CREATE_DOCKER_BUILDER: This option allows you to create a build configuration in your OpenShift to create the docker images of your project and store them in your docker registry. If you are going to create the builder, your application is needed, you need to specify where is your git repository and which is the branch and credentials to use it.

The following parameters of this section are only necessary if a builder is to be created.

GIT_REPOSITORY: This is the url of your git repository.

Note
If you are using production line, remember to use the internal rout of your repository, to use it you must change the base url of your production line for the internal route http://gitlab-core:80/gitlab. For example, if your production line repository is for example https://shared-services.pl.s2-eu.capgemini.com/gitlab/boat/boat-frontend.git use http://gitlab-core:80/gitlab/boat/boat-frontend.git)

GIT_BRANCH: This is the branch that we are going to use for creating the first docker image. The next time that you are going to use the builder you could use another branches.

GIT_CREDENTIALS: This is the credentials id stored in your jenkins to download the code from your git repository.

BUILD_SCRIPT: In case of use devon4ng or devon4node you could specify which is the build script used to build and create the first docker image with this builder.

JAVA_VERSION In case of use devon4j this is the java version used for your docker image.

Docker registry information

DOCKER_REGISTRY: This is the url of your docker registry.

Note
If you are using production line, the url of your registry is docker-registry- + your production line url. For example, if your production line is shared-services.pl.s2-eu.capgemini.com your docker registry is docker-registry-shared-services.pl.s2-eu.capgemini.com.

If you cannot access to your docker registry, please open an incident in i4u.

DOCKER_REGISTRY_CREDENTIALS: This is the credentials id stored in your jenkins to download or upload docker images in your docker registry.

DOCKER_TAG: This is the tag that is going to be used for the builder to push the docker image and for the deployment config to pull and deploy it.

OpenShift cluster information

OPENSHIFT_URL: This is the url of your OpenShift cluster.

OPENSHIFT_CREDENTIALS: This is the credentials id stored in your jenkins to use OpenShift.

OPENSHIFT_NAMESPACE: This is the name of the project in your OpenShift where you are going to use. The name of the project in OpenShift is called namespace.

Take care because although you see at the top of your OpenShift interface the name of the project that you are using, this name is the display-name and not the value that you need. To obtain the correct value you must check your OpenShift url like you see in the next image:

openshift namespace name

APP_NAME_SUFFIX: The name of all things created in your OpenShift project are going to be called as the configuration of your application says. Normaly, our projects use a suffix that depends on the environment. You can see the values in the next list:

  • For develop branch we use -dev

  • For release branch we use -uat

  • For master branch we use -prod

HOSTNAME: If you do not specify nothing, OpenShift is going to autogenerate a valid url for your application. You could modify the value by default but be sure that you configure everything to server your application in the route that you specify.

SECURED_PROTOCOL: If true, the protocol for the route will be https otherwise will be http.

Jenkins tools

All those parameters are the name of the tools in your Jenkinsfile.

To obtain it you need enter in your Jenkins and go to Manage Jenkins clicking on left menu and enter in Global Tool Configuration or in Managed files.

OPENSHIFT_TOOL: Is located in Global tool configuration.

openshift jenkins plugin name

NODEJS_TOOL: Is located in Global tool configuration.

jenkins openshift tool

YARN_TOOL: Is located in Global tool configuration, inside the custom tools.

jenkins yarn tool name

GLOBAL_SETTINGS_ID Is located in Managed files. You need to click on edit button and take the id.

jenkins config file management
jenkins edit configuration file

MAVEN_INSTALLATION Is located in Global tool configuration.

jenkins mave tool name
Clone this wiki locally