Thursday, September 14, 2017

Openshift CI images: S2i image builder + gitlab CI webhook 2 / 3 (OpenShift)

Next step is creating the credentials. We'll use them to make openshift talk to gitlab - this will necessary only if your repository is authenticated.
$ ssh-keygen -b 4096 -t rsa -f mykey Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):  Enter same passphrase again:  Your identification has been saved in mykey.
Your public key has been saved in mykey.pub.
We upload the private key to openshift:
oc secrets new mygitlab-key ssh-privatekey=mykey
oc secrets add serviceaccount/builder secrets/mygitlab-key
oc secrets link builder mygitlab-key
Next we create the app configuration. You may need to customize the image location and your gitlab user / address. The new OpenShift project will be mydocsproject:
$ oc new-app <your repository>/builderimagename:latest:latest~user@gitlab.com:your_repo.git --name mydocsproject
This will generate a build image, that will fail because we haven't given access to our authenticated gitlab repository. We'll configure OpenShift to use the newly created credentials - gitlab configuration in the next post:
$ oc set build-secret --source bc/mydocsproject mygitlab-key
To provide gitlab with the webhook to trigger a deployment on push, we will need the build config's webhook:
$ oc describe bc/mydocsproject | grep -A1 "Webhook Generic"   
Webhook Generic:
       URL:           https://youropenshifturl/oapi/v1/namespaces/blablabla/generic
Next is to configure gitlab.

No comments:

Post a Comment