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: cache:
key: "$CI_BUILD_NAME" key: "$CI_BUILD_NAME"
@ -13,7 +13,8 @@ stages:
variables: variables:
STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root" 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" DEPLOYMENT_NAME: "stackage-server-prod"
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-prod" HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-prod"
CRON_DEPLOYMENT_NAME: "stackage-server-cron-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/deployment_template.yaml) &&
kubectl apply -f <(envsubst <etc/kube/cron_deployment_template.yaml) && kubectl apply -f <(envsubst <etc/kube/cron_deployment_template.yaml) &&
kubectl apply -f <(envsubst <etc/kube/hoogle_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: #build:
stage: build # stage: build
script: # script:
# Clear *_TOKEN variables during code build so that compile-time code can't access them # # 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 # - apt-get update && apt-get install -y --no-install-recommends libpq-dev git rsync
- docker build -t "${DEPLOYMENT_IMAGE}" etc/docker # - CI_BUILD_TOKEN="" KUBE_TOKEN="" PROD_KUBE_TOKEN="" PROD_DOCKER_PASSWORD="" etc/scripts/stage_docker.sh --install-ghc --test
- docker login -u gitlab-ci-token -p "${CI_BUILD_TOKEN}" "${CI_REGISTRY}" # - docker build -t "${DEPLOYMENT_IMAGE}" etc/docker
- docker push "${DEPLOYMENT_IMAGE}" # - 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" # if [[ "$CI_BUILD_REF_NAME" == "master" ]]; then
docker push "${CI_REGISTRY_IMAGE}:latest" # docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:latest"
fi # docker push "${CI_REGISTRY_IMAGE}:latest"
if [[ "$CI_BUILD_REF_NAME" == "ci-cron" ]]; then # fi
docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:ci-cron" # if [[ "$CI_BUILD_REF_NAME" == "ci-cron" ]]; then
docker push "${CI_REGISTRY_IMAGE}:ci-cron" # docker tag "${DEPLOYMENT_IMAGE}" "${CI_REGISTRY_IMAGE}:ci-cron"
fi # docker push "${CI_REGISTRY_IMAGE}:ci-cron"
# fi
deploy_prod: deploy_prod:
stage: deploy stage: deploy
@ -88,12 +95,13 @@ deploy_prod:
deploy_ci: deploy_ci:
stage: deploy stage: deploy
only: #only:
- ci # - ci
environment: environment:
name: stackage-server-ci name: stackage-server-ci
url: https://ci.stackage.org/ url: https://ci.stackage.org/
variables: variables:
KUBE_NAMESPACE: "fpco-public"
DEPLOYMENT_NAME: "stackage-server-ci" DEPLOYMENT_NAME: "stackage-server-ci"
HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-ci" HOOGLE_DEPLOYMENT_NAME: "stackage-server-hoogle-ci"
CRON_DEPLOYMENT_NAME: "stackage-server-cron-ci" CRON_DEPLOYMENT_NAME: "stackage-server-cron-ci"
@ -103,8 +111,6 @@ deploy_ci:
HOST: ci.stackage.org HOST: ci.stackage.org
script: script:
- *KUBELOGIN - *KUBELOGIN
- *KUBEAPPLY - echo $KUBE_NAMESPACE
- kubectl apply -f <(envsubst <etc/kube/ingress_template.yaml) - *HELMUPGRADE
- kubectl rollout status "deployment/$DEPLOYMENT_NAME" #- *HELMCHECK
- kubectl rollout status "deployment/$HOOGLE_DEPLOYMENT_NAME"
- kubectl rollout status "deployment/$CRON_DEPLOYMENT_NAME"

View File

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

View File

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

View File

@ -3,11 +3,13 @@ kind: Deployment
metadata: metadata:
name: {{ .Values.hoogleName }} name: {{ .Values.hoogleName }}
spec: spec:
replicas: {{ .Values.image.replicas }} replicas: {{ .Values.image.replicasHoggle }}
minReadySeconds: 5
template: template:
metadata: metadata:
labels: labels:
app: {{ .Values.hoogleApp }} app: {{ .Values.hoogleApp }}
release: {{ .Release.Name }}
spec: spec:
imagePullSecrets: imagePullSecrets:
- name: registry-key - name: registry-key
@ -28,15 +30,6 @@ spec:
secretKeyRef: secretKeyRef:
name: {{ .Values.name }} name: {{ .Values.name }}
key: PGCONN key: PGCONN
livenessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 120
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe: readinessProbe:
httpGet: httpGet:
path: / path: /
@ -49,6 +42,19 @@ spec:
timeoutSeconds: 1 timeoutSeconds: 1
periodSeconds: 5 periodSeconds: 5
successThreshold: 1 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: resources:
{{ toYaml .Values.stackageResources.resources | indent 12 }} {{ toYaml .Values.stackageResources.resources | indent 12 }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
image: image:
pullPolicy: IfNotPresent pullPolicy: Always
minReadySeconds: 5 minReadySeconds: 5
service: 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: image:
replicas: 1
replicasHoggle: 2
env: env:
approot: "stackage.org" approot: "stackage.org"
@ -21,5 +28,3 @@ cronResources:
limits: limits:
cpu: 300m cpu: 300m
memory: 4096Mi memory: 4096Mi

View File

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