Skip to content

Commit 020aeb1

Browse files
author
Alan Christie
committed
- Pipelines deployment (OpenShift) is now a template
- Adds Ansible role/playbook for deployment
1 parent d177fbb commit 020aeb1

File tree

10 files changed

+128
-19
lines changed

10 files changed

+128
-19
lines changed

deploy.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# A simple deployment script for OpenShift.
44
# It is assumed that your OpenShift Squonk application has been deployed
55
# and that you are running this from the Squonk project/namespace
6-
# and have logged in as an appropriate user and have run `source setenv.sh`
6+
# and have logged in as an appropriate user and have run `source setenv.sh`.
7+
#
8+
# You will need to first delete any prior job (or look at the related
9+
# Ansible playbook/role in this project - which does =things a little better)
710

811
set -e pipefail
912

1013
oc login -u $OC_ADMIN
1114
oc project $OC_PROJECT
12-
oc create -f post-service-descriptors.yaml
15+
oc process -f post-service-descriptors.yaml | oc create -f -
1316

1417
echo "Squonk pipelines deployment is underway..."

openshift/ansible/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Squonk Ansible OpenShift Pipelines Deployment
2+
A simple way to (re)deploy the pipelines to OpenShift: -
3+
4+
ansible-playbook playbooks/pipelines/deploy.yaml
5+
6+
> Remember to first `source` an appropriately crafted
7+
`setenv.sh` script first! (see below)
8+
9+
## Prerequisites
10+
Before running the playbook: -
11+
12+
1. You're on the bastion node
13+
1. You have installed Ansible (any version from 2.5)
14+
1. The `oc` command-set is available to you as a user
15+
1. An OpenShift cluster has been installed
16+
1. There is an `admin` user known to the cluster
17+
1. You have setup your own `setenv.sh`
18+
(typically in Squonk's `openshift/templates`)
19+
and you have run `source setenv.sh` using it.
20+
21+
## MiniShift considerations
22+
While it's a work-in-progress, it should also work on MiniShift.

openshift/ansible/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory = inventory
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
oc_admin: "{{ ansible_env.OC_ADMIN }}"
4+
oc_admin_password: "{{ ansible_env.OC_ADMIN_PASSWORD }}"
5+
oc_master_hostname: "{{ ansible_env.OC_MASTER_HOSTNAME }}"
6+
oc_project: "{{ ansible_env.OC_PROJECT }}"
7+
oc_pipelines_sd_poster_image_tag: "{{ ansible_env.OC_PIPELINES_SD_POSTER_IMAGE_TAG }}"
8+
9+
# Various retry timeouts (seconds)...
10+
pod_ready_timeout: 600
11+
12+
# Our template directory
13+
# (relative to the role_path directory)
14+
t_dir: ../../../..

openshift/ansible/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[localhost]
2+
127.0.0.1 ansible_connection=local
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
- hosts: localhost
4+
5+
roles:
6+
- pipelines
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../roles/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
job_name: pipelines-sd-poster
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
3+
# Login and move to the Squonk project
4+
# and then remove any existing poster job
5+
# before deploying a new one (and waiting for completion).
6+
7+
- name: Login (admin)
8+
shell: oc login {{ oc_master_hostname }} -u {{ oc_admin }} -p {{ oc_admin_password }}
9+
changed_when: False
10+
11+
- name: Move to Squonk Project
12+
shell: oc project {{ oc_project }}
13+
changed_when: False
14+
15+
- name: Get jobs
16+
shell: oc get jobs
17+
register: jobs_result
18+
changed_when: False
19+
20+
- name: Delete existing SD poster job
21+
shell: oc delete jobs/{{ job_name }}
22+
when: jobs_result.stdout | regex_search('^%s' % job_name, multiline=True)
23+
24+
- name: Run SD poster job (always)
25+
shell: >
26+
oc process
27+
-f {{ role_path }}/{{ t_dir }}/post-service-descriptors.yaml
28+
-p POSTER_IMAGE_TAG={{ oc_pipelines_sd_poster_image_tag }}
29+
| oc create -f -
30+
31+
- name: Wait for SD poster success
32+
shell: oc describe jobs/{{ job_name }} | grep '1 Succeeded' | grep 1
33+
delay: 10
34+
retries: "{{ (pod_ready_timeout | int / 10) | int }}"
35+
register: result
36+
until: result.rc == 0
37+
changed_when: False

post-service-descriptors.yaml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,42 @@
22

33
# The OpenShift Job definition for the Squonk Pipelines SD-Loader image.
44
# With Squonk running you can execute this in the Squonk project namespace
5-
# to enable the defined pipelines.
5+
# to enable the defined pipelines
6+
# (by using the Ansible playbook 'pipelines/deploy.yaml')
67
#
7-
# oc create -f post-service-descriptors.yaml
8+
# oc process -f post-service-descriptors.yaml | oc create -f -
9+
# oc delete job --selector template=pipelines-sd-poster
810

9-
kind: Job
10-
apiVersion: batch/v1
11+
kind: Template
12+
apiVersion: v1
1113
metadata:
12-
generateName: pipelines-sd-poster-
13-
spec:
14-
template:
15-
spec:
16-
initContainers:
17-
- image: yauritux/busybox-curl
18-
name: wait-for-core-before-pipelines-post
19-
command: ['sh', '-c',
20-
'until (( curl http://coreservices:8080/rest/ping --connect-timeout 5 )); do sleep 2; done']
21-
containers:
22-
- image: squonk/rdkit-pipelines-sdposter:latest
23-
name: pipelines-sd-poster
24-
restartPolicy: Never
14+
name: pipelines-sd-poster
15+
labels:
16+
template: pipelines-sd-poster
17+
18+
parameters:
19+
20+
- name: POSTER_IMAGE_TAG
21+
value: latest
22+
23+
objects:
24+
25+
- kind: Job
26+
apiVersion: batch/v1
27+
metadata:
28+
name: pipelines-sd-poster
29+
spec:
30+
template:
31+
spec:
32+
33+
initContainers:
34+
- image: yauritux/busybox-curl
35+
name: wait-for-core-before-pipelines-post
36+
command: ['sh', '-c',
37+
'until (( curl http://coreservices:8080/rest/ping --connect-timeout 5 )); do sleep 2; done']
38+
39+
containers:
40+
- image: squonk/rdkit-pipelines-sdposter:${POSTER_IMAGE_TAG}
41+
name: pipelines-sd-poster
42+
43+
restartPolicy: Never

0 commit comments

Comments
 (0)