Rollout deployment

* Replace BACKEND_URL with GRAPHQL_URI environment (DRY)
* Trigger rollout deployments by a simple label update
* DRY configmap and secret configuration
This commit is contained in:
Robert Schäfer 2019-03-21 10:57:26 +01:00
parent b21cafb983
commit c6d9ea052f
15 changed files with 38 additions and 71 deletions

View File

@ -47,6 +47,7 @@
"cors": "~2.8.5",
"cross-env": "~5.2.0",
"date-fns": "2.0.0-alpha.27",
"debug": "~4.1.1",
"dotenv": "~7.0.0",
"express": "~4.16.4",
"faker": "~4.1.0",
@ -86,7 +87,6 @@
"babel-jest": "~24.5.0",
"chai": "~4.2.0",
"cucumber": "~5.1.0",
"debug": "~4.1.1",
"eslint": "~5.15.1",
"eslint-config-standard": "~12.0.0",
"eslint-plugin-import": "~2.16.0",

View File

@ -3,13 +3,13 @@
kind: ConfigMap
data:
GRAPHQL_PORT: "4000"
GRAPHQL_URI: "https://nitro-staging.human-connection.org/api"
GRAPHQL_URI: "http://nitro-backend.human-connection:4000"
MOCK: "false"
NEO4J_URI: "bolt://nitro-neo4j.human-connection:7687"
NEO4J_USER: "neo4j"
NEO4J_AUTH: none
NEO4J_AUTH: "none"
CLIENT_URI: "https://nitro-staging.human-connection.org"
MAPBOX_TOKEN: pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ
MAPBOX_TOKEN: "pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ"
metadata:
name: configmap
namespace: human-connection

View File

@ -4,10 +4,16 @@
metadata:
name: nitro-backend
namespace: human-connection
labels:
commit: "COMMIT"
spec:
replicas: 1
minReadySeconds: 15
progressDeadlineSeconds: 60
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: "100%"
selector:
matchLabels:
human-connection.org/selector: deployment-human-connection-backend
@ -23,42 +29,11 @@
imagePullPolicy: Always
ports:
- containerPort: 4000
env:
- name: COMMIT
value: <BACKEND_COMMIT>
- name: MOCK
value: "false"
- name: CLIENT_URI
valueFrom:
configMapKeyRef:
name: configmap
key: CLIENT_URI
- name: GRAPHQL_PORT
valueFrom:
configMapKeyRef:
name: configmap
key: GRAPHQL_PORT
- name: GRAPHQL_URI
valueFrom:
configMapKeyRef:
name: configmap
key: GRAPHQL_URI
- name: MAPBOX_TOKEN
valueFrom:
configMapKeyRef:
name: configmap
key: MAPBOX_TOKEN
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: human-connection
key: JWT_SECRET
optional: false
- name: NEO4J_URI
valueFrom:
configMapKeyRef:
name: configmap
key: NEO4J_URI
envFrom:
- configMapRef:
name: configmap
- secretRef:
name: human-connection
volumeMounts:
- mountPath: /nitro-backend/public/uploads
name: uploads

View File

@ -6,7 +6,6 @@
namespace: human-connection
spec:
replicas: 1
strategy: {}
selector:
matchLabels:
human-connection.org/selector: deployment-human-connection-neo4j
@ -21,16 +20,12 @@
image: humanconnection/neo4j:latest
imagePullPolicy: Always
env:
- name: COMMIT
value: <BACKEND_COMMIT>
- name: NEO4J_apoc_import_file_enabled
value: "true"
- name: NEO4J_dbms_memory_pagecache_size
value: 1G
- name: NEO4J_dbms_memory_heap_max__size
value: 1G
- name: NEO4J_AUTH
value: none
- name: NEO4J_URI
valueFrom:
configMapKeyRef:

View File

@ -3,6 +3,8 @@ kind: Deployment
metadata:
name: nitro-web
namespace: human-connection
labels:
commit: "COMMIT"
spec:
replicas: 2
minReadySeconds: 15
@ -18,27 +20,14 @@ spec:
spec:
containers:
- name: web
envFrom:
- configMapRef:
name: configmap
- secretRef:
name: human-connection
env:
- name: COMMIT
value: <WEBAPP_COMMIT>
- name: HOST
value: 0.0.0.0
- name: BACKEND_URL
valueFrom:
configMapKeyRef:
name: configmap
key: GRAPHQL_URI
- name: MAPBOX_TOKEN
valueFrom:
configMapKeyRef:
name: configmap
key: MAPBOX_TOKEN
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: human-connection
key: JWT_SECRET
optional: false
image: humanconnection/nitro-web:latest
ports:
- containerPort: 3000

View File

@ -10,10 +10,10 @@ metadata:
spec:
tls:
- hosts:
- nitro-master.human-connection.org
- nitro-staging.human-connection.org
secretName: tls
rules:
- host: nitro-master.human-connection.org
- host: nitro-staging.human-connection.org
http:
paths:
- path: /

View File

@ -3,6 +3,7 @@ kind: Secret
data:
JWT_SECRET: "Yi8mJjdiNzhCRiZmdi9WZA=="
MONGODB_PASSWORD: "TU9OR09EQl9QQVNTV09SRA=="
PRIVATE_KEY_PASSPHRASE: "YTdkc2Y3OHNhZGc4N2FkODdzZmFnc2FkZzc4"
metadata:
name: human-connection
namespace: human-connection

View File

@ -12,7 +12,7 @@ services:
context: webapp
target: build-and-test
environment:
- BACKEND_URL=http://backend:4123
- GRAPHQL_URI=http://backend:4123
backend:
image: humanconnection/nitro-backend:builder
build:

View File

@ -13,7 +13,7 @@ services:
- hc-network
environment:
- HOST=0.0.0.0
- BACKEND_URL=http://backend:4000
- GRAPHQL_URI=http://backend:4000
- MAPBOX_TOKEN="pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.bZ8KK9l70omjXbEkkbHGsQ"
backend:
image: humanconnection/nitro-backend:latest

4
scripts/deploy.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
sed -i "s/<COMMIT>/${TRAVIS_COMMIT}/g" patch-deployment.yaml
kubectl --namespace=human-connection patch deployment nitro-backend -p "$(cat patch-deployment.yaml)"
kubectl --namespace=human-connection patch deployment nitro-web -p "$(cat patch-deployment.yaml)"

View File

@ -0,0 +1,3 @@
metadata:
labels:
commit: <COMMIT>

View File

@ -6,5 +6,5 @@ services:
context: .
target: build-and-test
environment:
- BACKEND_URL=http://backend:4123
- GRAPHQL_URI=http://backend:4123
- NODE_ENV=test

View File

@ -13,7 +13,7 @@ services:
- hc-network
environment:
- HOST=0.0.0.0
- BACKEND_URL=http://backend:4000
- GRAPHQL_URI=http://backend:4000
- MAPBOX_TOKEN="pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.bZ8KK9l70omjXbEkkbHGsQ"
networks:

View File

@ -123,7 +123,7 @@ module.exports = {
proxy: {
'/api': {
// make this configurable (nuxt-dotenv)
target: process.env.BACKEND_URL || 'http://localhost:4000',
target: process.env.GRAPHQL_URI || 'http://localhost:4000',
pathRewrite: { '^/api': '' },
toProxy: true, // cloudflare needs that
changeOrigin: true,

View File

@ -1,5 +1,5 @@
export default ({ app }) => {
const backendUrl = process.env.BACKEND_URL || 'http://localhost:4000'
const backendUrl = process.env.GRAPHQL_URI || 'http://localhost:4000'
return {
httpEndpoint: process.server ? backendUrl : '/api',
httpLinkOptions: {