- deployment config . (Example: https://github.com/bcgov/angular-scaffold/blob/master/openshift/templates/angular-on-nginx/angular-on-nginx-deploy.json)
- build config (Example: https://github.com/bcgov/angular-scaffold/blob/master/openshift/templates/angular-on-nginx/angular-on-nginx-build.json)
Checkout: https://github.com/BCDevOps/openshift-project-tools.git Add following to your PATH:
- openshift-project-tools/bin
- Create a project to house the Jenkins instance that will be responsible for promoting application images (via OpenShift ImageStreamTags) across environment; the exact project name used was "{project-name}-tools".
- Create the BuildConfiguration within this project using the
occommand and "{project-name}-build.json" file:
oc process -f {project-name}-build.json | oc create -f -
This build config is in the openshift namespace as it uses the {base-image-name} S2I strategy.
- Deploy a Jenkins instance with persistent storage into the tools project ({project-name}-tools) using the web gui
- Create an OpenShift project for each "environment" (e.g. DEV, TEST, PROD); Exact names used were {project-name}-dev, {project-name}-test, {project-name}-prod
- Configure the access controls to allow the Jenkins instance to tag imagestreams in the environment projects, and to allow the environment projects to pull images from the tools project:
oc policy add-role-to-user system:image-puller system:serviceaccount:{project-name}-dev:default -n {project-name}-tools
oc policy add-role-to-user edit system:serviceaccount:{project-name}-tools:default -n {project-name}-dev
oc policy add-role-to-user system:image-puller system:serviceaccount:{project-name}-test:default -n {project-name}-tools
oc policy add-role-to-user edit system:serviceaccount:{project-name}-tools:default -n {project-name}-test
oc policy add-role-to-user system:image-puller system:serviceaccount:{project-name}-prod:default -n {project-name}-tools
oc policy add-role-to-user edit system:serviceaccount:{project-name}-tools:default -n {project-name}-prod
https://console.pathfinder.gov.bc.ca:8443/console/project/-tools/browse/builds/?tab=configuration displays the webhook urls. Copy the GitHub one. https://console.pathfinder.gov.bc.ca:8443/oapi/v1/namespaces/{project-name}-tools/buildconfigs/devxp/webhooks/github
In the GitHub repository go to Settings > Webhooks > Add webhook Create a webhook for the push event only to Payload URL copied from URL above. Content type: application/json
Create the deploy configuration
- Use the JSON file in this directory and
octool to create the necessary app resources within each project (user and password can be found in the postgresql deployment environment variables in the web gui):
oc process -f <project-name>-environment.json -v DATABASE_USER=<user> -v DATABASE_PASSWORD=<password> -v APP_DEPLOYMENT_TAG=<tag> -v APPLICATION_DOMAIN=<appname>-<env>.pathfinder.gov.bc.ca | oc create -f -
Where APP_DEPLOYMENT_TAG used is dev, test, prod. The deployment config uses the -tools namespace since that is where the image stream resides.
- Login to https://console.pathfinder.gov.bc.ca:8443; you'll be prompted for GitHub authorization.
- Download OpenShift command line tools, unzip, and add
octo your PATH. - Copy command line login string from https://console.pathfinder.gov.bc.ca:8443/console/command-line. It will look like
oc login https://console.pathfinder.gov.bc.ca:8443 --token=xtyz123xtyz123xtyz123xtyz123 - Paste the login string into a terminal session. You are now authenticated against OpenShift and will be able to execute
occommands.oc -hprovides a summary of available commands.
Free OpenShift book from RedHat – good overview
Red Hat Container Development Kit
- https://docs.openshift.com/container-platform/3.6/dev_guide/application_lifecycle/new_app.html#dev-guide-new-app
- https://docs.openshift.com/container-platform/3.6/dev_guide/builds/index.html
- https://docs.openshift.com/container-platform/3.6/dev_guide/templates.html#writing-templates
- https://github.com/BCDevOps/BCDevOps-Guide