Start porting fedocal to openshift

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2019-01-23 13:50:51 +01:00
parent fa972e1297
commit 3c288105c9
8 changed files with 311 additions and 0 deletions

View file

@ -0,0 +1,52 @@
- 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: fedocal
description: Fedora Elections apps
appowners:
- cverna
- pingou
- role: openshift/object
app: fedocal
template: imagestream.yml
objectname: imagestream.yml
- role: openshift/object
app: fedocal
template: buildconfig.yml
objectname: buildconfig.yml
- role: openshift/object
app: fedocal
template: configmap.yml
objectname: configmap.yml
- role: openshift/start-build
app: fedocal
buildname: fedocal-build
objectname: fedocal-build
- role: openshift/object
app: fedocal
file: service.yml
objectname: service.yml
- role: openshift/route
app: fedocal
routename: fedocal
host: "calendar{{ env_suffix }}.fedoraproject.org"
serviceport: 8080-tcp
servicename: fedocal
- role: openshift/object
app: fedocal
file: deploymentconfig.yml
objectname: deploymentconfig.yml

View file

@ -0,0 +1,69 @@
---
apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: fedocal
service: fedocal
name: fedocal
spec:
replicas: 1
selector:
app: fedocal
deploymentconfig: fedocal
strategy:
type: Recreate
recreateParams:
# mid:
# failurePolicy: Abort
# execNewPod:
# containerName: fedocal
# command: ["alembic", "upgrade", "head", "-c", "/opt/app-root/config/alembic.ini"]
# env:
# - name: PYTHONPATH
# value: /opt/app-root/src
# volumes:
# - config-volume
template:
metadata:
labels:
app: fedocal
deploymentconfig: fedocal
spec:
containers:
- name: fedocal
image: fedocal:latest
ports:
- containerPort: 8080
resources: {}
volumeMounts:
- name: config-volume
mountPath: /opt/app-root/config/
readOnly: true
readinessProbe:
timeoutSeconds: 1
initialDelaySeconds: 5
httpGet:
path: /
port: 8080
livenessProbe:
timeoutSeconds: 1
initialDelaySeconds: 30
httpGet:
path: /
port: 8080
volumes:
- name: config-volume
configMap:
name: fedocal-configmap
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- fedocal
from:
kind: ImageStreamTag
name: fedocal:latest

View file

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

View file

@ -0,0 +1,56 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = /opt/app-root/src/alembic
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
#sqlalchemy.url = postgresql://<%= fedocal_app %>:<%= fedocal_appPassword %>@db-fedocal/fedocal
{% if env == 'staging' %}
sqlalchemy.url = postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@db01.stg.phx2.fedoraproject.org/{{ fedocal_db_name }}
{% else %}
sqlalchemy.url = postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@db01.phx2.fedoraproject.org/{{ fedocal_db_name }}
{% endif %}
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View file

@ -0,0 +1,30 @@
apiVersion: v1
kind: BuildConfig
metadata:
name: fedocal-build
labels:
environment: "fedocal"
spec:
output:
to:
kind: ImageStreamTag
name: fedocal:latest
source:
type: Git
git:
uri: https://pagure.io/fedocal.git
{% if env == 'staging' %}
ref: "staging"
{% else %}
ref: "production"
{% endif %}
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: python:3.6
triggers:
- type: ConfigChange
- type: ImageChange

View file

@ -0,0 +1,13 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fedocal-configmap
labels:
app: fedocal
{% macro load_file(filename) %}{% include filename %}{%- endmacro -%}
data:
alembic.ini: |-
{{ load_file('alembic.ini') | indent }}
fedocal.cfg: |-
{{ load_file('fedocal.cfg') | indent }}

View file

@ -0,0 +1,66 @@
# Beware that the quotes around the values are mandatory
### Secret key for the Flask application
SECRET_KEY='{{ fedocal_secret_key }}'
### url to the database server:
#DB_URL=mysql://user:pass@host/db_name
#DB_URL=postgres://user:pass@host/db_name
#DB_URL="postgresql://<%= fedocal_app %>:<%= fedocal_appPassword %>@db-fedocal/fedocal"
{% if env == 'staging' %}
DB_URL='postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@db01.stg.phx2.fedoraproject.org/{{ fedocal_db_name }}'
{% else %}
DB_URL='postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@db01.phx2.fedoraproject.org/{{ fedocal_db_name }}'
{% endif %}
### The FAS group in which the admin of fedocal are
ADMIN_GROUP='sysadmin-calendar'
### The address of the SMTP server used to send the reminders emails
### via the cron job.
### Default: 'localhost'
SMTP_SERVER='localhost'
### The cron job can be set with any frequency but fedocal_cron needs
### this information to accurately retrieve the meetings to remind and
### avoid sending multiple reminders for a single meeting.
### Default: 30
CRON_FREQUENCY=30
### Path to the alembic configuration file
### When creating the database, we need to tell the database which
### revision of alembic we are at and to do this we need access to the
### alembic.ini file.
PATH_ALEMBIC_INI='/opt/app-root/config/alembic.ini'
# This is required to fix login
PREFERRED_URL_SCHEME='https'
# Make browsers send session cookie only via HTTPS
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_PATH = '/calendar'
SESSION_COOKIE_NAME = 'fedocal'
# Used by SESSION_COOKIE_PATH
APPLICATION_ROOT = '/calendar/'
{% if env == 'staging' %}
APP_URL = 'https://apps.stg.fedoraproject.org/' + APPLICATION_ROOT
FAS_OPENID_ENDPOINT = 'https://id.stg.fedoraproject.org/openid/'
SITE_ROOT = 'https://apps.stg.fedoraproject.org'
SITE_URL = '%s/calendar' % SITE_ROOT
{% else %}
APP_URL = 'https://apps.fedoraproject.org/' + APPLICATION_ROOT
SITE_ROOT = 'https://apps.fedoraproject.org'
SITE_URL = '%s/calendar' % SITE_ROOT
{% endif %}
## URLs to fedmenu resources
{% if env == 'staging' %}
FEDMENU_URL = 'https://apps.stg.fedoraproject.org/fedmenu'
FEDMENU_DATA_URL = 'https://apps.stg.fedoraproject.org/js/data.js'
{% else %}
FEDMENU_URL = 'https://apps.fedoraproject.org/fedmenu'
FEDMENU_DATA_URL = 'https://apps.fedoraproject.org/js/data.js'
{% endif %}

View file

@ -0,0 +1,10 @@
---
apiVersion: v1
kind: ImageStream
metadata:
name: fedocal
spec:
lookupPolicy:
local: false
status:
dockerImageRepository: ""