Skip to content

Commit 03f2f2a

Browse files
committed
✨(richie) add ImageStream and BuildConfig
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.
1 parent debe193 commit 03f2f2a

File tree

6 files changed

+59
-5
lines changed

6 files changed

+59
-5
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: "v1"
2+
kind: "BuildConfig"
3+
metadata:
4+
# FIXME
5+
#
6+
# As mentionned in the official documentation [1]:
7+
#
8+
# Configuration change triggers currently only work when creating a new
9+
# BuildConfig. In a future release, configuration change triggers will also
10+
# be able to launch a build whenever a BuildConfig is updated.
11+
#
12+
# Hence, we must force BuildConfig to always get created with a unique name.
13+
# This is a temporary solution that needs to be improved as soon as OKD
14+
# triggers a new build upon BC object update.
15+
#
16+
# References:
17+
#
18+
# 1. https://docs.okd.io/latest/dev_guide/builds/triggering_builds.html#config-change-triggers
19+
name: "richie-{{ deployment_stamp }}"
20+
namespace: "{{ project_name }}"
21+
labels:
22+
app: "richie"
23+
service: "richie"
24+
version: "{{ richie_image_tag }}"
25+
deployment_stamp: "{{ deployment_stamp }}"
26+
spec:
27+
strategy:
28+
type: Docker
29+
source:
30+
dockerfile: |-
31+
FROM {{ richie_image_name }}:{{ richie_image_tag }}
32+
# Add new statements here
33+
triggers:
34+
- type: "ConfigChange"
35+
output:
36+
to:
37+
kind: "ImageStreamTag"
38+
name: "richie:{{ richie_image_tag }}-live"

apps/richie/templates/app/dc.yml.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
name: "richie-app-{{ deployment_stamp }}"
1010
namespace: "{{ project_name }}"
1111
spec:
12-
replicas: 1 # number of pods we want
12+
replicas: 1 # number of pods we want
1313
template:
1414
metadata:
1515
labels:
@@ -21,7 +21,9 @@ spec:
2121
spec:
2222
containers:
2323
- name: richie
24-
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
24+
# We point to a local registry image build for this "live" image (see
25+
# ImageStream and BuildConfig templates)
26+
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
2527
imagePullPolicy: IfNotPresent
2628
env:
2729
- name: DJANGO_SETTINGS_MODULE
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: "v1"
2+
kind: "ImageStream"
3+
metadata:
4+
name: "richie"
5+
namespace: "{{ project_name }}"
6+
labels:
7+
app: "richie"
8+
service: "richie"

apps/richie/templates/app/job_collectstatic.yml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ spec:
3838
envFrom:
3939
- secretRef:
4040
name: richie-{{ secret_id }}
41-
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
41+
# We point to a local registry image build for this "live" image (see
42+
# ImageStream and BuildConfig templates)
43+
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
4244
command: ["python", "manage.py", "collectstatic", "--noinput"]
4345
volumeMounts:
4446
- mountPath: /data/static

apps/richie/templates/app/job_db_migrate.yml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ spec:
3838
envFrom:
3939
- secretRef:
4040
name: richie-{{ secret_id }}
41-
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
41+
# We point to a local registry image build for this "live" image (see
42+
# ImageStream and BuildConfig templates)
43+
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
4244
command: ["python", "manage.py", "migrate"]
4345
restartPolicy: Never

apps/richie/templates/app/job_regenerate_indexes.yml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
envFrom:
4141
- secretRef:
4242
name: richie-{{ secret_id }}
43-
image: "{{ richie_image_name }}:{{ richie_image_tag }}"
43+
# We point to a local registry image build for this "live" image (see
44+
# ImageStream and BuildConfig templates)
45+
image: "{{ internal_docker_registry }}/{{ project_name }}/richie:{{ richie_image_tag }}-live"
4446
command: ["python", "manage.py", "regenerate_indexes"]
4547
restartPolicy: Never

0 commit comments

Comments
 (0)