mdapi: boilerplate to move mdapi to openshift

Signed-off-by: Clement Verna <cverna@tutanota.com>
This commit is contained in:
Clement Verna
2019-01-11 20:19:11 +01:00
parent a9d21feb43
commit ab0cff4741
7 changed files with 209 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
- name: make the app be real
hosts: os-masters-stg[0]
user: root
gather_facts: False
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
- role: openshift/project
app: mdapi
description: mdapi is a small API exposing the metadata contained in different RPM repositories.
appowners:
- cverna
- pingou
- role: openshift/object
app: mdapi
template: imagestream.yml
objectname: imagestream.yml
- role: openshift/object
app: mdapi
template: buildconfig.yml
objectname: buildconfig.yml
- role: openshift/object
app: mdapi
template: configmap.yml
objectname: configmap.yml
- role: openshift/object
app: mdapi
file: cron.yml
objectname: cron.yml
- role: openshift/start-build
app: mdapi
buildname: asknot-build
objectname: asknot-build
- role: openshift/object
app: mdapi
file: service.yml
objectname: service.yml
- role: openshift/route
app: mdapi
routename: mdapi
host: "mdapi.{{env_suffix}}.fedoraproject.org"
serviceport: 8080-tcp
servicename: asknot
- role: openshift/object
app: mdapi
file: deploymentconfig.yml
objectname: deploymentconfig.yml
- role: openshift/rollout
app: mdapi
dcname: mdapi

View File

@@ -0,0 +1,28 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: mdapi
spec:
concurrencyPolicy: Forbid
schedule: "20 * * * *"
jobTemplate:
spec:
template:
metadata:
labels:
parent: "cronjobmdapi"
spec:
containers:
- name: mdapi
image: registry/mdapi:latest
command: ["bash", "-c", "/code/mdapi/mdapi-get_repo_md /etc/mdapi/mdapi.cfg; echo failed"]
volumeMounts:
- mountPath: /etc/mdapi
name: config-volume
readOnly: true
restartPolicy: Never
volumes:
- configMap:
defaultMode: 420
name: mdapi-configmap
name: config-volume

View File

@@ -0,0 +1,54 @@
---
apiVersion: v1
kind: DeploymentConfig
metadata:
name: mdapi
labels:
app: mdapi
service: mdapi
spec:
replicas: 1
selector:
app: mdapi
service: mdapi
template:
metadata:
labels:
app: mdapi
service: mdapi
spec:
containers:
- name: mdapi
image: registry/mdapi:latest
ports:
- containerPort: 8080
volumeMounts:
- name: config-volume
mountPath: /etc/mdapi/
readOnly: true
readinessProbe:
timeoutSeconds: 5
initialDelaySeconds: 60
httpGet:
path: /
port: 8080
livenessProbe:
timeoutSeconds: 5
initialDelaySeconds: 60
httpGet:
path: /
port: 8080
resources:
volumes:
- name: config-volume
configMap:
name: mdapi-configmap
triggers:
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- "mdapi"
from:
kind: ImageStreamTag
name: mdapi:latest

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: mdapi
name: mdapi
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: mdapi
deploymentconfig: mdapi

View File

@@ -0,0 +1,24 @@
apiVersion: v1
kind: BuildConfig
metadata:
name: mdapi-build
labels:
environment: "mdapi"
spec:
source:
git:
uri: https://pagure.io/mdapi.git
{% if env == 'staging' %}
ref: "staging"
{% else %}
ref: "production"
{% endif %}
strategy:
type: Docker
triggers:
- type: ConfigChange
- type: ImageChange
output:
to:
kind: ImageStreamTag
name: mdapi:latest

View File

@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mdapi-configmap
labels:
app: mdapi
data:
mdapi.cfg: |-
HOST = '*'
PORT = '8080'
PREFIX = '/mdapi'
DL_VERIFY = False
{% if env == 'staging' %}
KOJI_REPO = 'https://koji.stg.fedoraproject.org/repos/'
DL_SERVER = 'http://dl.phx2.fedoraproject.org'
{% else %}
KOJI_REPO = 'https://koji.fedoraproject.org/repos/'
DL_SERVER = 'http://dl.phx2.fedoraproject.org'
{% endif %}

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: ImageStream
metadata:
name: "mdapi"