Skip to content

Commit

Permalink
✨(richie) add ImageStream and BuildConfig
Browse files Browse the repository at this point in the history
Service pods are now based on a locally built image instead of
DockerHub's raw image. This allows us to add project-specific
contrains or customization.
  • Loading branch information
jmaupetit committed Sep 4, 2018
1 parent 103408f commit eabd4f4
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
38 changes: 38 additions & 0 deletions apps/richie/templates/app/bc.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: "v1"
kind: "BuildConfig"
metadata:
# FIXME
#
# As mentionned in the official documentation [1]:
#
# Configuration change triggers currently only work when creating a new
# BuildConfig. In a future release, configuration change triggers will also
# be able to launch a build whenever a BuildConfig is updated.
#
# Hence, we must force BuildConfig to always get created with a unique name.
# This is a temporary solution that needs to be improved as soon as OKD
# triggers a new build upon BC object update.
#
# References:
#
# 1. https://docs.okd.io/latest/dev_guide/builds/triggering_builds.html#config-change-triggers
name: "richie-{{ deployment_stamp }}"
namespace: "{{ project_name }}"
labels:
app: "richie"
service: "richie"
version: "{{ richie_image_tag }}"
deployment_stamp: "{{ deployment_stamp }}"
spec:
strategy:
type: Docker
source:
dockerfile: |-
FROM {{ richie_image_name }}:{{ richie_image_tag }}
# Add new statements here
triggers:
- type: "ConfigChange"
output:
to:
kind: "ImageStreamTag"
name: "richie:{{ richie_image_tag }}-live"
6 changes: 4 additions & 2 deletions apps/richie/templates/app/dc.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
name: "richie-app-{{ deployment_stamp }}"
namespace: "{{ project_name }}"
spec:
replicas: 1 # number of pods we want
replicas: 1 # number of pods we want
template:
metadata:
labels:
Expand All @@ -21,7 +21,9 @@ spec:
spec:
containers:
- name: richie
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
# We point to a local registry image build for this "live" image (see
# ImageStream and BuildConfig templates)
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
imagePullPolicy: IfNotPresent
env:
- name: DJANGO_SETTINGS_MODULE
Expand Down
8 changes: 8 additions & 0 deletions apps/richie/templates/app/is.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: "v1"
kind: "ImageStream"
metadata:
name: "richie"
namespace: "{{ project_name }}"
labels:
app: "richie"
service: "richie"
4 changes: 3 additions & 1 deletion apps/richie/templates/app/job_collectstatic.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ spec:
envFrom:
- secretRef:
name: richie-{{ secret_id }}
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
# We point to a local registry image build for this "live" image (see
# ImageStream and BuildConfig templates)
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
command: ["python", "manage.py", "collectstatic", "--noinput"]
volumeMounts:
- mountPath: /data/static
Expand Down
4 changes: 3 additions & 1 deletion apps/richie/templates/app/job_db_migrate.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
envFrom:
- secretRef:
name: richie-{{ secret_id }}
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
# We point to a local registry image build for this "live" image (see
# ImageStream and BuildConfig templates)
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
command: ["python", "manage.py", "migrate"]
restartPolicy: Never
4 changes: 3 additions & 1 deletion apps/richie/templates/app/job_regenerate_indexes.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ spec:
envFrom:
- secretRef:
name: richie-{{ secret_id }}
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
# We point to a local registry image build for this "live" image (see
# ImageStream and BuildConfig templates)
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
command: ["python", "manage.py", "regenerate_indexes"]
restartPolicy: Never

0 comments on commit eabd4f4

Please sign in to comment.