From 33fd2b3fb1de65586df22b7070982124e5211f88 Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Thu, 8 Apr 2021 17:35:23 +0200 Subject: [PATCH] fix(strapi): nodeSelector (#113) * fix(strapi): nodeSelector * plop * fix: test perf * fix(docker): remove devDeps --- .k8s/__tests__/__snapshots__/dev.ts.snap | 4 +++- .k8s/__tests__/__snapshots__/preprod.ts.snap | 4 +++- .k8s/__tests__/__snapshots__/prod.ts.snap | 4 +++- .k8s/components/strapi.ts | 11 +++++++---- back/strapi/Dockerfile | 2 ++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.k8s/__tests__/__snapshots__/dev.ts.snap b/.k8s/__tests__/__snapshots__/dev.ts.snap index 564020884..7e294b6ea 100644 --- a/.k8s/__tests__/__snapshots__/dev.ts.snap +++ b/.k8s/__tests__/__snapshots__/dev.ts.snap @@ -415,7 +415,7 @@ spec: cpu: 500m memory: 256Mi requests: - cpu: 100m + cpu: 200m memory: 128Mi startupProbe: failureThreshold: 12 @@ -468,6 +468,8 @@ spec: - persistentVolumeClaim: claimName: 1000jours-strapi-uploads name: uploads + nodeSelector: + workload: les1000jours-strapi --- apiVersion: v1 kind: ConfigMap diff --git a/.k8s/__tests__/__snapshots__/preprod.ts.snap b/.k8s/__tests__/__snapshots__/preprod.ts.snap index 7e3c02bf6..8d21197f8 100644 --- a/.k8s/__tests__/__snapshots__/preprod.ts.snap +++ b/.k8s/__tests__/__snapshots__/preprod.ts.snap @@ -377,7 +377,7 @@ spec: cpu: 500m memory: 256Mi requests: - cpu: 100m + cpu: 200m memory: 128Mi startupProbe: failureThreshold: 12 @@ -430,6 +430,8 @@ spec: - persistentVolumeClaim: claimName: 1000jours-strapi-uploads name: uploads + nodeSelector: + workload: les1000jours-strapi --- apiVersion: v1 kind: ConfigMap diff --git a/.k8s/__tests__/__snapshots__/prod.ts.snap b/.k8s/__tests__/__snapshots__/prod.ts.snap index 1e4c27e05..297147c55 100644 --- a/.k8s/__tests__/__snapshots__/prod.ts.snap +++ b/.k8s/__tests__/__snapshots__/prod.ts.snap @@ -354,7 +354,7 @@ spec: cpu: 500m memory: 256Mi requests: - cpu: 100m + cpu: 200m memory: 128Mi startupProbe: failureThreshold: 12 @@ -407,6 +407,8 @@ spec: - persistentVolumeClaim: claimName: 1000jours-strapi-uploads name: uploads + nodeSelector: + workload: les1000jours-strapi --- apiVersion: v1 kind: ConfigMap diff --git a/.k8s/components/strapi.ts b/.k8s/components/strapi.ts index 96b0efd19..ee8a1d098 100644 --- a/.k8s/components/strapi.ts +++ b/.k8s/components/strapi.ts @@ -64,7 +64,7 @@ const strapiManifests = create("strapi", { }, resources: { requests: { - cpu: "100m", + cpu: "200m", memory: "128Mi", }, limits: { @@ -85,7 +85,7 @@ const strapiManifests = create("strapi", { //@ts-expect-error const deployment = getManifestByKind(strapiManifests, Deployment) as Deployment; -const pvcName = "1000jours-strapi-uploads" +const pvcName = "1000jours-strapi-uploads"; if (deployment && deployment?.spec?.template.spec) { deployment.spec.template.spec.volumes = [ @@ -96,12 +96,15 @@ if (deployment && deployment?.spec?.template.spec) { name: "uploads", }, ]; + deployment.spec.template.spec.nodeSelector = { + workload: "les1000jours-strapi", + }; } const pvc = new PersistentVolumeClaim({ metadata: { name: pvcName, - annotations: {} + annotations: {}, }, spec: { accessModes: ["ReadWriteOnce"], @@ -110,7 +113,7 @@ const pvc = new PersistentVolumeClaim({ storage: "1Gi", }, }, - volumeMode: "Filesystem" + volumeMode: "Filesystem", }, }); diff --git a/back/strapi/Dockerfile b/back/strapi/Dockerfile index afbc9b81f..182e751bd 100644 --- a/back/strapi/Dockerfile +++ b/back/strapi/Dockerfile @@ -14,4 +14,6 @@ ENV NODE_ENV production RUN yarn build-ts RUN yarn build +RUN yarn install --production + CMD ["yarn", "start"]