fix corn-job names
This commit is contained in:
parent
53fc7a990d
commit
740bd021f2
3 changed files with 38 additions and 29 deletions
|
@ -87,7 +87,6 @@
|
||||||
name (replace-dots-by-minus unique-name)]
|
name (replace-dots-by-minus unique-name)]
|
||||||
(->
|
(->
|
||||||
(yaml/load-as-edn "website/nginx-deployment.yaml")
|
(yaml/load-as-edn "website/nginx-deployment.yaml")
|
||||||
(assoc-in [:metadata :labels :app.kubernetes.part-of] name)
|
|
||||||
(assoc-in [:metadata :namespace] name)
|
(assoc-in [:metadata :namespace] name)
|
||||||
(replace-all-matching-substrings-beginning-with "NAME" name)
|
(replace-all-matching-substrings-beginning-with "NAME" name)
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
|
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
|
||||||
|
@ -120,6 +119,20 @@
|
||||||
(replace-all-matching-substrings-beginning-with "NAME" name))))
|
(replace-all-matching-substrings-beginning-with "NAME" name))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn-spec generate-website-build-cron map?
|
||||||
|
[config websiteconfig?]
|
||||||
|
(let [{:keys [unique-name build-cpu-request build-cpu-limit build-memory-request
|
||||||
|
build-memory-limit]} config
|
||||||
|
name (replace-dots-by-minus unique-name)]
|
||||||
|
(->
|
||||||
|
(yaml/load-as-edn "website/website-build-cron.yaml")
|
||||||
|
(replace-all-matching-substrings-beginning-with "NAME" name)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_LIMIT" build-cpu-limit)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_REQUEST" build-memory-request)
|
||||||
|
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_LIMIT" build-memory-limit))))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-website-content-volume map?
|
(defn-spec generate-website-content-volume map?
|
||||||
[config websiteconfig?]
|
[config websiteconfig?]
|
||||||
(let [{:keys [unique-name volume-size]} config
|
(let [{:keys [unique-name volume-size]} config
|
||||||
|
@ -141,21 +154,6 @@
|
||||||
(replace-all-matching-substrings-beginning-with "NAME" name))))
|
(replace-all-matching-substrings-beginning-with "NAME" name))))
|
||||||
|
|
||||||
|
|
||||||
(defn-spec generate-website-build-cron map?
|
|
||||||
[config websiteconfig?]
|
|
||||||
(let [{:keys [unique-name build-cpu-request build-cpu-limit build-memory-request
|
|
||||||
build-memory-limit]} config
|
|
||||||
name (replace-dots-by-minus unique-name)]
|
|
||||||
(->
|
|
||||||
(yaml/load-as-edn "website/website-build-cron.yaml")
|
|
||||||
(assoc-in [:metadata :labels :app.kubernetes.part-of] name)
|
|
||||||
(replace-all-matching-substrings-beginning-with "NAME" name)
|
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_REQUEST" build-cpu-request)
|
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_CPU_LIMIT" build-cpu-limit)
|
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_REQUEST" build-memory-request)
|
|
||||||
(cm/replace-all-matching-values-by-new-value "BUILD_MEMORY_LIMIT" build-memory-limit))))
|
|
||||||
|
|
||||||
|
|
||||||
; TODO: Non-Secret-Parts should be config map
|
; TODO: Non-Secret-Parts should be config map
|
||||||
(defn-spec generate-website-build-secret pred/map-or-seq?
|
(defn-spec generate-website-build-secret pred/map-or-seq?
|
||||||
[config websiteconfig?
|
[config websiteconfig?
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
metadata:
|
metadata:
|
||||||
name: NAME-build-cron
|
name: build-cron
|
||||||
|
namespace: NAME
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
spec:
|
spec:
|
||||||
|
@ -11,10 +12,15 @@ spec:
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
|
metadata:
|
||||||
|
namespace: NAME
|
||||||
|
labels:
|
||||||
|
app: build-cron
|
||||||
|
app.kubernetes.part-of: NAME-website
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- image: domaindrivenarchitecture/c4k-website-build
|
- image: domaindrivenarchitecture/c4k-website-build
|
||||||
name: NAME-build-app
|
name: build-cron-container
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
|
@ -30,14 +36,14 @@ spec:
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: content-volume
|
- name: content-volume
|
||||||
mountPath: /var/www/html/website
|
mountPath: /var/www/html/website
|
||||||
- name: hashfile-volume
|
- name: hash-state-volume
|
||||||
mountPath: /var/hashfile.d
|
mountPath: /var/hashfile.d
|
||||||
volumes:
|
volumes:
|
||||||
- name: content-volume
|
- name: content-volume
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: NAME-content-volume
|
claimName: content-volume
|
||||||
- name: hashfile-volume
|
- name: hash-state-volume
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: NAME-hashfile-volume
|
claimName: hash-state-volume
|
||||||
restartPolicy: OnFailure
|
restartPolicy: OnFailure
|
||||||
|
|
|
@ -123,8 +123,9 @@
|
||||||
(deftest should-generate-website-build-cron
|
(deftest should-generate-website-build-cron
|
||||||
(is (= {:apiVersion "batch/v1",
|
(is (= {:apiVersion "batch/v1",
|
||||||
:kind "CronJob",
|
:kind "CronJob",
|
||||||
:metadata {:name "test-io-build-cron",
|
:metadata {:name "build-cron",
|
||||||
:labels {:app.kubernetes.part-of "test-io"}},
|
:namespace "test-io",
|
||||||
|
:labels {:app.kubernetes.part-of "test-io-website"}},
|
||||||
:spec
|
:spec
|
||||||
{:schedule "0/7 * * * *",
|
{:schedule "0/7 * * * *",
|
||||||
:successfulJobsHistoryLimit 1,
|
:successfulJobsHistoryLimit 1,
|
||||||
|
@ -132,18 +133,22 @@
|
||||||
:jobTemplate
|
:jobTemplate
|
||||||
{:spec
|
{:spec
|
||||||
{:template
|
{:template
|
||||||
{:spec
|
{:metadata
|
||||||
|
{:namespace "test-io",
|
||||||
|
:labels
|
||||||
|
{:app "build-cron", :app.kubernetes.part-of "test-io-website"}}
|
||||||
|
:spec
|
||||||
{:containers
|
{:containers
|
||||||
[{:image "domaindrivenarchitecture/c4k-website-build",
|
[{:image "domaindrivenarchitecture/c4k-website-build",
|
||||||
:name "test-io-build-app",
|
:name "build-cron-container",
|
||||||
:imagePullPolicy "IfNotPresent",
|
:imagePullPolicy "IfNotPresent",
|
||||||
:resources {:requests {:cpu "500m", :memory "256Mi"}, :limits {:cpu "1700m", :memory "512Mi"}},
|
:resources {:requests {:cpu "500m", :memory "256Mi"}, :limits {:cpu "1700m", :memory "512Mi"}},
|
||||||
:command ["/entrypoint.sh"],
|
:command ["/entrypoint.sh"],
|
||||||
:envFrom [{:secretRef {:name "test-io-secret"}}],
|
:envFrom [{:secretRef {:name "test-io-secret"}}],
|
||||||
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}
|
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}
|
||||||
{:name "hashfile-volume", :mountPath "/var/hashfile.d"}]}],
|
{:name "hash-state-volume", :mountPath "/var/hashfile.d"}]}],
|
||||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-io-content-volume"}}
|
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "content-volume"}}
|
||||||
{:name "hashfile-volume", :persistentVolumeClaim {:claimName "test-io-hashfile-volume"}}],
|
{:name "hash-state-volume", :persistentVolumeClaim {:claimName "hash-state-volume"}}],
|
||||||
:restartPolicy "OnFailure"}}}}}}
|
:restartPolicy "OnFailure"}}}}}}
|
||||||
(cut/generate-website-build-cron {:issuer "staging"
|
(cut/generate-website-build-cron {:issuer "staging"
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
|
|
Loading…
Reference in a new issue