review-apps: Configure helm for the CI deployment

This commit is contained in:
Paul Montero 2018-12-30 14:23:29 -05:00
parent 3608a9d2b1
commit 83e1871e0f
No known key found for this signature in database
GPG Key ID: 08F88C7D828194E7
10 changed files with 102 additions and 66 deletions

View File

@ -1,4 +1,4 @@
image: registry.gitlab.fpcomplete.com/fpco/default-build-image:1954
image: registry.gitlab.fpcomplete.com/fpco/default-build-image:5826
cache:
key: "$CI_BUILD_NAME"
@ -13,7 +13,8 @@ stages:
variables:
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
DEPLOYMENT_IMAGE: "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_SLUG}_${CI_PIPELINE_ID}"
#DEPLOYMENT_IMAGE: "${CI_REGISTRY_IMAGE}:${CI_BUILD_REF_SLUG}_${CI_PIPELINE_ID}"
DEPLOYMENT_IMAGE: "registry.gitlab.fpcomplete.com/fpco-mirrors/stackage-server:master_4296"
DEPLOYMENT_NAME: "stackage-server-prod"
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-prod"
CRON_DEPLOYMENT_NAME: "stackage-server-cron-prod"
@ -35,24 +36,30 @@ variables:
kubectl apply -f <(envsubst <etc/kube/deployment_template.yaml) &&
kubectl apply -f <(envsubst <etc/kube/cron_deployment_template.yaml) &&
kubectl apply -f <(envsubst <etc/kube/hoogle_deployment_template.yaml)
- &HELMUPGRADE
helm upgrade -i "${DEPLOYMENT_NAME}" etc/helm --set name="${DEPLOYMENT_NAME}" --set app="${DEPLOYMENT_APP}" --set hoogleName="${HOOGLE_DEPLOYMENT_NAME}" --set hoogleApp="${HOOGLE_DEPLOYMENT_APP}" --set cronName="${CRON_DEPLOYMENT_NAME}" --set cronApp="${HOOGLE_DEPLOYMENT_APP}" --set image.image="${DEPLOYMENT_IMAGE}" --values etc/helm/values/$CI_ENVIRONMENT_NAME.yaml --namespace fpco-public
- &HELMCHECK
helm ls &&
helm status "${DEPLOYMENT_NAME}"
build:
stage: build
script:
# Clear *_TOKEN variables during code build so that compile-time code can't access them
- CI_BUILD_TOKEN="" KUBE_TOKEN="" PROD_KUBE_TOKEN="" PROD_DOCKER_PASSWORD="" etc/scripts/stage_docker.sh --install-ghc --test
- docker build -t "${DEPLOYMENT_IMAGE}" etc/docker
- docker login -u gitlab-ci-token -p "${CI_BUILD_TOKEN}" "${CI_REGISTRY}"
- docker push "${DEPLOYMENT_IMAGE}"
- |
if [[ "$CI_BUILD_REF_NAME" == "master" ]]; then
docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:latest"
docker push "${CI_REGISTRY_IMAGE}:latest"
fi
if [[ "$CI_BUILD_REF_NAME" == "ci-cron" ]]; then
docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:ci-cron"
docker push "${CI_REGISTRY_IMAGE}:ci-cron"
fi
#build:
# stage: build
# script:
# # Clear *_TOKEN variables during code build so that compile-time code can't access them
# - apt-get update && apt-get install -y --no-install-recommends libpq-dev git rsync
# - CI_BUILD_TOKEN="" KUBE_TOKEN="" PROD_KUBE_TOKEN="" PROD_DOCKER_PASSWORD="" etc/scripts/stage_docker.sh --install-ghc --test
# - docker build -t "${DEPLOYMENT_IMAGE}" etc/docker
# - docker login -u gitlab-ci-token -p "${CI_BUILD_TOKEN}" "${CI_REGISTRY}"
# - docker push "${DEPLOYMENT_IMAGE}"
# - |
# if [[ "$CI_BUILD_REF_NAME" == "master" ]]; then
# docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:latest"
# docker push "${CI_REGISTRY_IMAGE}:latest"
# fi
# if [[ "$CI_BUILD_REF_NAME" == "ci-cron" ]]; then
# docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:ci-cron"
# docker push "${CI_REGISTRY_IMAGE}:ci-cron"
# fi
deploy_prod:
stage: deploy
@ -88,12 +95,13 @@ deploy_prod:
deploy_ci:
stage: deploy
only:
- ci
#only:
# - ci
environment:
name: stackage-server-ci
url: https://ci.stackage.org/
variables:
KUBE_NAMESPACE: "fpco-public"
DEPLOYMENT_NAME: "stackage-server-ci"
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-ci"
CRON_DEPLOYMENT_NAME: "stackage-server-cron-ci"
@ -103,8 +111,6 @@ deploy_ci:
HOST: ci.stackage.org
script:
- *KUBELOGIN
- *KUBEAPPLY
- kubectl apply -f <(envsubst <etc/kube/ingress_template.yaml)
- kubectl rollout status "deployment/$DEPLOYMENT_NAME"
- kubectl rollout status "deployment/$HOOGLE_DEPLOYMENT_NAME"
- kubectl rollout status "deployment/$CRON_DEPLOYMENT_NAME"
- echo $KUBE_NAMESPACE
- *HELMUPGRADE
#- *HELMCHECK

View File

@ -11,6 +11,7 @@ spec:
metadata:
labels:
app: {{ .Values.cronApp }}
release: {{ .Release.Name }}
spec:
imagePullSecrets:
- name: registry-key

View File

@ -20,8 +20,8 @@ spec:
ports:
- name: http
containerPort: 3000
command:
- stackage-server
command: ["stackage-server"]
workingDir: /app
env:
- name: APPROOT
value: {{ .Values.image.env.approot | quote }}
@ -30,10 +30,6 @@ spec:
secretKeyRef:
name: {{ .Values.name }}
key: PGCONN
livenessProbe:
httpGet:
path: /
port: 3000
readinessProbe:
httpGet:
path: /
@ -42,6 +38,23 @@ spec:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 5
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
resources:
{{ toYaml .Values.stackageResources.resources | indent 12 }}
{{- with .Values.nodeSelector }}

View File

@ -3,11 +3,13 @@ kind: Deployment
metadata:
name: {{ .Values.hoogleName }}
spec:
replicas: {{ .Values.image.replicas }}
replicas: {{ .Values.image.replicasHoggle }}
minReadySeconds: 5
template:
metadata:
labels:
app: {{ .Values.hoogleApp }}
release: {{ .Release.Name }}
spec:
imagePullSecrets:
- name: registry-key
@ -28,15 +30,6 @@ spec:
secretKeyRef:
name: {{ .Values.name }}
key: PGCONN
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /
@ -49,6 +42,19 @@ spec:
timeoutSeconds: 1
periodSeconds: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /
port: 3000
httpHeaders:
# Works around stackage-server's `forceSSL` redirect
- name: HTTPS
value: "on"
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
resources:
{{ toYaml .Values.stackageResources.resources | indent 12 }}
{{- with .Values.nodeSelector }}

View File

@ -4,6 +4,7 @@ metadata:
name: {{ .Values.hoogleName }}
labels:
app: {{ .Values.hoogleApp }}
release: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
ports:
@ -17,3 +18,4 @@ spec:
protocol: TCP
selector:
app: {{ .Values.hoogleApp }}
release: {{ .Release.Name }}

View File

@ -1,38 +1,39 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := .Values.name -}}
{{- $name := .Values.name -}}
{{- $hoogleName := .Values.hoogleName -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
name: {{ $name }}
labels:
app: {{ .Values.app }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- range .Values.ingress.hosts }}
rules:
- host: {{ .Values.ingress.host }}
- host: {{ . }}
http:
paths:
- path: /haddock.*
backend:
serviceName: {{ .Values.name }}
serviceName: {{ $name }}
servicePort: 80
- path: /.+/hoogle
backend:
serviceName: {{ .Values.hoogleName }}
serviceName: {{ $hoogleName }}
servicePort: 80
- backend:
serviceName: {{ .Values.name }}
serviceName: {{ $name }}
servicePort: 80
{{- end }}
tls:
- hosts:
{{- range .Values.ingress.hosts }}
- {{ . }}
{{- end }}
secretName: {{ $fullName }}-tls
secretName: {{ $name }}-tls
{{- end }}

View File

@ -4,9 +4,7 @@ metadata:
name: {{ .Values.name }}
labels:
app: {{ .Values.app }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
@ -19,5 +17,5 @@ spec:
targetPort: http
protocol: TCP
selector:
app: {{ template "stackage-server.name" . }}
app: {{ .Values.app }}
release: {{ .Release.Name }}

View File

@ -1,5 +1,5 @@
image:
pullPolicy: IfNotPresent
pullPolicy: Always
minReadySeconds: 5
service:

View File

@ -1,6 +1,13 @@
replicaCount: 1
#name: stackage-server-prod
#app: stackage-server-prod
#hoogleName: stackage-server-hoogle-prod
#hoogleApp: stackage-server-hoogle-prod
#cronName: stackage-server-cron-prod
#cronApp: stackage-server-cron-prod
image:
replicas: 1
replicasHoggle: 2
env:
approot: "stackage.org"
@ -21,5 +28,3 @@ cronResources:
limits:
cpu: 300m
memory: 4096Mi

View File

@ -1,15 +1,19 @@
name: stackage-server-ci
app: stackage-server-ci
hoogleName: stackage-server-hoogle-ci
hoogleApp: stackage-server-hoogle-ci
cronName: stackage-server-cron-ci
cronApp: stackage-server-cron-ci
#name: stackage-server-ci
#app: stackage-server-ci
#hoogleName: stackage-server-hoogle-ci
#hoogleApp: stackage-server-hoogle-ci
#cronName: stackage-server-cron-ci
#cronApp: stackage-server-cron-ci
image:
replicas: 1
replicasHoggle: 2
env:
#approot: "https://ci.stackage.org"
approot: ""
approot: "https://ci.stackage.org"
ingress:
hosts:
- ci.stackage.org
stackageResources:
resources: