From 7fa4efa005e0511687c11c23c3d7318c4e9f78aa Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Mon, 23 Sep 2024 11:22:13 +0200 Subject: [PATCH] maint: update deployment code Added workflow to build image and push to image registry, added helm code to create --- .github/workflows/dockerimg.yaml | 35 +++ .helm/README.md | 22 ++ .helm/adhoc/configmap.yaml | 13 + .helm/adhoc/old-ingress.yaml | 22 ++ .helm/voluba-linear-backend/.helmignore | 23 ++ .helm/voluba-linear-backend/Chart.yaml | 24 ++ .../voluba-linear-backend/templates/NOTES.txt | 22 ++ .../templates/_helpers.tpl | 62 +++++ .../templates/deployment.yaml | 68 ++++++ .../voluba-linear-backend/templates/hpa.yaml | 32 +++ .../templates/ingress.yaml | 61 +++++ .../templates/service.yaml | 15 ++ .../templates/serviceaccount.yaml | 13 + .../templates/tests/test-connection.yaml | 15 ++ .helm/voluba-linear-backend/values.yaml | 108 +++++++++ openshift-deployment/README.rst | 16 -- .../openshift-prod-export.yaml | 223 ------------------ 17 files changed, 535 insertions(+), 239 deletions(-) create mode 100644 .github/workflows/dockerimg.yaml create mode 100644 .helm/README.md create mode 100644 .helm/adhoc/configmap.yaml create mode 100644 .helm/adhoc/old-ingress.yaml create mode 100644 .helm/voluba-linear-backend/.helmignore create mode 100644 .helm/voluba-linear-backend/Chart.yaml create mode 100644 .helm/voluba-linear-backend/templates/NOTES.txt create mode 100644 .helm/voluba-linear-backend/templates/_helpers.tpl create mode 100644 .helm/voluba-linear-backend/templates/deployment.yaml create mode 100644 .helm/voluba-linear-backend/templates/hpa.yaml create mode 100644 .helm/voluba-linear-backend/templates/ingress.yaml create mode 100644 .helm/voluba-linear-backend/templates/service.yaml create mode 100644 .helm/voluba-linear-backend/templates/serviceaccount.yaml create mode 100644 .helm/voluba-linear-backend/templates/tests/test-connection.yaml create mode 100644 .helm/voluba-linear-backend/values.yaml delete mode 100644 openshift-deployment/README.rst delete mode 100644 openshift-deployment/openshift-prod-export.yaml diff --git a/.github/workflows/dockerimg.yaml b/.github/workflows/dockerimg.yaml new file mode 100644 index 0000000..72e0dff --- /dev/null +++ b/.github/workflows/dockerimg.yaml @@ -0,0 +1,35 @@ +name: '[build] docker image' + +on: + push: + branches: + # - "master" + - "*" + +env: + DOCKER_REPO: docker-registry.ebrains.eu + DOCKER_NS: voluba + DOCKER_IMG: voluba-linear-backend + DOCKER_TAG: latest + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + docker_tag=${{ env.DOCKER_REPO }}/${{ env.DOCKER_NS }}/${{ env.DOCKER_IMG }}:${{ env.DOCKER_TAG }} + echo docker_tag=$docker_tag + docker build -t $docker_tag . + + echo DOCKER_BUILT_TAG=$docker_tag >> $GITHUB_ENV + + - name: 'Push to docker registry' + run: | + echo "Login to docker registry" + docker login \ + -u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \ + -p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \ + docker-registry.ebrains.eu + echo "Pushing $DOCKER_BUILT_TAG" + docker push $DOCKER_BUILT_TAG diff --git a/.helm/README.md b/.helm/README.md new file mode 100644 index 0000000..c39945d --- /dev/null +++ b/.helm/README.md @@ -0,0 +1,22 @@ +# Deployment + +This directory describes how voluba linear backend is deployed on ebrains infrastructure. + +## Provisioned service + +The services provided by ebrains, used in the deployment: + +- docker registry +- rancher cluster + +## Requirements + +- helm + +## Scripts + +At root directory (i.e. parent of ) + +```bash +helm install voluba-backend .helm/voluba-linear-backend +``` diff --git a/.helm/adhoc/configmap.yaml b/.helm/adhoc/configmap.yaml new file mode 100644 index 0000000..b1f6fad --- /dev/null +++ b/.helm/adhoc/configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +data: + config.py: | + CORS_ORIGINS = '*' + PROXY_FIX = { + 'x_for': 1, + 'x_host': 1, + 'x_port': 1, + 'x_proto': 1, + } +kind: ConfigMap +metadata: + name: instance-dir diff --git a/.helm/adhoc/old-ingress.yaml b/.helm/adhoc/old-ingress.yaml new file mode 100644 index 0000000..018ac9d --- /dev/null +++ b/.helm/adhoc/old-ingress.yaml @@ -0,0 +1,22 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + labels: + name: voluba-old-lbe-hostname-ingress + name: voluba-old-lbe-hostname-ingress +spec: + rules: + - host: voluba-linear-backend.apps.hbp.eu + http: + paths: + - backend: + service: + name: voluba-backend + port: + number: 8080 + path: / + pathType: Prefix + tls: + - hosts: + - voluba-linear-backend.apps.hbp.eu + secretName: voluba-lbe-old-hostname-secret diff --git a/.helm/voluba-linear-backend/.helmignore b/.helm/voluba-linear-backend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/.helm/voluba-linear-backend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/.helm/voluba-linear-backend/Chart.yaml b/.helm/voluba-linear-backend/Chart.yaml new file mode 100644 index 0000000..dda7c6d --- /dev/null +++ b/.helm/voluba-linear-backend/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: voluba-linear-backend +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.2.0.dev0" diff --git a/.helm/voluba-linear-backend/templates/NOTES.txt b/.helm/voluba-linear-backend/templates/NOTES.txt new file mode 100644 index 0000000..c44fb25 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "voluba-linear-backend.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "voluba-linear-backend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "voluba-linear-backend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "voluba-linear-backend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/.helm/voluba-linear-backend/templates/_helpers.tpl b/.helm/voluba-linear-backend/templates/_helpers.tpl new file mode 100644 index 0000000..858bf25 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "voluba-linear-backend.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "voluba-linear-backend.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "voluba-linear-backend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "voluba-linear-backend.labels" -}} +helm.sh/chart: {{ include "voluba-linear-backend.chart" . }} +{{ include "voluba-linear-backend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "voluba-linear-backend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "voluba-linear-backend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "voluba-linear-backend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "voluba-linear-backend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/.helm/voluba-linear-backend/templates/deployment.yaml b/.helm/voluba-linear-backend/templates/deployment.yaml new file mode 100644 index 0000000..c27b049 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "voluba-linear-backend.fullname" . }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "voluba-linear-backend.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "voluba-linear-backend.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/.helm/voluba-linear-backend/templates/hpa.yaml b/.helm/voluba-linear-backend/templates/hpa.yaml new file mode 100644 index 0000000..3e836bb --- /dev/null +++ b/.helm/voluba-linear-backend/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "voluba-linear-backend.fullname" . }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "voluba-linear-backend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/.helm/voluba-linear-backend/templates/ingress.yaml b/.helm/voluba-linear-backend/templates/ingress.yaml new file mode 100644 index 0000000..d390d90 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "voluba-linear-backend.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/.helm/voluba-linear-backend/templates/service.yaml b/.helm/voluba-linear-backend/templates/service.yaml new file mode 100644 index 0000000..2cfceda --- /dev/null +++ b/.helm/voluba-linear-backend/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "voluba-linear-backend.fullname" . }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "voluba-linear-backend.selectorLabels" . | nindent 4 }} diff --git a/.helm/voluba-linear-backend/templates/serviceaccount.yaml b/.helm/voluba-linear-backend/templates/serviceaccount.yaml new file mode 100644 index 0000000..b491140 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "voluba-linear-backend.serviceAccountName" . }} + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/.helm/voluba-linear-backend/templates/tests/test-connection.yaml b/.helm/voluba-linear-backend/templates/tests/test-connection.yaml new file mode 100644 index 0000000..5eb8b86 --- /dev/null +++ b/.helm/voluba-linear-backend/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "voluba-linear-backend.fullname" . }}-test-connection" + labels: + {{- include "voluba-linear-backend.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "voluba-linear-backend.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/.helm/voluba-linear-backend/values.yaml b/.helm/voluba-linear-backend/values.yaml new file mode 100644 index 0000000..8d0641c --- /dev/null +++ b/.helm/voluba-linear-backend/values.yaml @@ -0,0 +1,108 @@ +# Default values for voluba-linear-backend. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: docker-registry.ebrains.eu/voluba/voluba-linear-backend + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8080 + +# see adhoc ingress +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +livenessProbe: + httpGet: + path: /health + port: http +readinessProbe: + httpGet: + path: /health + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: + +# created from adhoc +- configMap: + defaultMode: 420 + name: instance-dir + name: instance-dir-mounted-vol +# Additional volumeMounts on the output Deployment definition. +volumeMounts: +- name: instance-dir-mounted-vol + mountPath: /instance + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/openshift-deployment/README.rst b/openshift-deployment/README.rst deleted file mode 100644 index bc25d9e..0000000 --- a/openshift-deployment/README.rst +++ /dev/null @@ -1,16 +0,0 @@ -Deploying to production -======================= - -As an example, these are the instructions for restoring the production deployment on https://okd.hbp.eu/. - -#. You can use the deployment configuration saved in ``_ provided in the repository as a starting point. Edit the route contained in this file to use the correct URL. -#. Create the project named `voluba-linear-backend` on https://okd.hbp.eu/ -#. Log in using the command-line ``oc`` tool (https://okd.hbp.eu/console/command-line), switch to the `voluba-linear-backend` project with ``oc project voluba-linear-backend`` -#. Import the objects from your edited YAML file using ``oc create -f openshift-prod-export.yaml`` -#. Re-create the Persistent Volume Claims and upload the data (none for this project). -#. Edit the Config Maps if needed, re-create the needed Secrets (namely ``github-webhook-secret``). -#. Start the build. The deployment should follow automatically. -#. For production, increase the number of replicas in order to be more resilient to node failures: go to `Applications` -> `Deployments` -> `flask` -> `Configuration` and change the number of `Replicas` to 3. -#. Go to `Builds` -> `Builds` -> `flask` -> `Configuration`, copy the GitHub Webhook URL and configure it into the GitHub repository (https://github.com/HumanBrainProject/voluba-linear-backend/settings/hooks). Make sure to set the Content Type to ``application/json``. - -The deployment configuration is saved to ``_ by running ``oc get -o yaml --export is,bc,dc,svc,route,pvc,cm,horizontalpodautoscaler > openshift-prod-export.yaml`` (`status`, `resourceVersion`, `generation`, `@sha256`, `PersistentVolumeClaim` metadata (`volumeName`, `finalizers`, `annotations`) and `secret` information is stripped manually, see https://collab.humanbrainproject.eu/#/collab/38996/nav/270508 for other edits that may be necessary). diff --git a/openshift-deployment/openshift-prod-export.yaml b/openshift-deployment/openshift-prod-export.yaml deleted file mode 100644 index 40b915e..0000000 --- a/openshift-deployment/openshift-prod-export.yaml +++ /dev/null @@ -1,223 +0,0 @@ -apiVersion: v1 -items: -- apiVersion: image.openshift.io/v1 - kind: ImageStream - metadata: - annotations: - openshift.io/generated-by: OpenShiftWebConsole - creationTimestamp: 2020-01-29T13:25:14Z - labels: - app: voluba-linear-backend - name: voluba-linear-backend - namespace: voluba-linear-backend - selfLink: /apis/image.openshift.io/v1/namespaces/voluba-linear-backend/imagestreams/voluba-linear-backend - uid: c88facd2-429a-11ea-89e4-fa163e061b5f - spec: - lookupPolicy: - local: false -- apiVersion: build.openshift.io/v1 - kind: BuildConfig - metadata: - annotations: - openshift.io/generated-by: OpenShiftWebConsole - creationTimestamp: 2020-01-29T13:25:14Z - labels: - app: voluba-linear-backend - name: voluba-linear-backend - namespace: voluba-linear-backend - selfLink: /apis/build.openshift.io/v1/namespaces/voluba-linear-backend/buildconfigs/voluba-linear-backend - uid: c89a5a9e-429a-11ea-89e4-fa163e061b5f - spec: - failedBuildsHistoryLimit: 5 - nodeSelector: null - output: - to: - kind: ImageStreamTag - name: voluba-linear-backend:latest - postCommit: - script: | - set -e - # Without PIP_IGNORE_INSTALLED=0 the Debian version of pip would - # re-install all dependencies in the user's home directory - # (https://github.com/pypa/pip/issues/4222#issuecomment-417672236) - PIP_IGNORE_INSTALLED=0 python3 -m pip install --user /source[tests] - cd /source - python3 -m pytest tests/ - resources: {} - runPolicy: Serial - source: - git: - ref: master - uri: https://github.com/HumanBrainProject/voluba-linear-backend.git - type: Git - strategy: - dockerStrategy: - dockerfilePath: Dockerfile - forcePull: true - type: Docker - successfulBuildsHistoryLimit: 5 - triggers: - - github: - secretReference: - name: github-webhook-secret - type: GitHub -- apiVersion: apps.openshift.io/v1 - kind: DeploymentConfig - metadata: - annotations: - openshift.io/generated-by: OpenShiftWebConsole - creationTimestamp: 2020-01-29T13:25:14Z - labels: - app: voluba-linear-backend - name: voluba-linear-backend - namespace: voluba-linear-backend - selfLink: /apis/apps.openshift.io/v1/namespaces/voluba-linear-backend/deploymentconfigs/voluba-linear-backend - uid: c8a23770-429a-11ea-89e4-fa163e061b5f - spec: - replicas: 3 - revisionHistoryLimit: 10 - selector: - deploymentconfig: voluba-linear-backend - strategy: - activeDeadlineSeconds: 21600 - resources: {} - rollingParams: - intervalSeconds: 1 - maxSurge: 25% - maxUnavailable: 25% - timeoutSeconds: 600 - updatePeriodSeconds: 1 - type: Rolling - template: - metadata: - creationTimestamp: null - labels: - app: voluba-linear-backend - deploymentconfig: voluba-linear-backend - spec: - containers: - - env: - - name: INSTANCE_PATH - value: /instance - image: docker-registry.default.svc:5000/voluba-linear-backend/voluba-linear-backend - imagePullPolicy: Always - livenessProbe: - failureThreshold: 3 - httpGet: - path: /health - port: 8080 - scheme: HTTP - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 60 - name: voluba-linear-backend - ports: - - containerPort: 8080 - protocol: TCP - readinessProbe: - failureThreshold: 3 - httpGet: - path: /health - port: 8080 - scheme: HTTP - initialDelaySeconds: 5 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 10 - resources: {} - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - volumeMounts: - - mountPath: /instance - name: volume-innr5 - dnsPolicy: ClusterFirst - restartPolicy: Always - schedulerName: default-scheduler - securityContext: {} - terminationGracePeriodSeconds: 30 - volumes: - - configMap: - defaultMode: 420 - name: instance-dir - name: volume-innr5 - test: false - triggers: - - imageChangeParams: - automatic: true - containerNames: - - voluba-linear-backend - from: - kind: ImageStreamTag - name: voluba-linear-backend:latest - namespace: voluba-linear-backend - lastTriggeredImage: docker-registry.default.svc:5000/voluba-linear-backend/voluba-linear-backend - type: ImageChange - - type: ConfigChange -- apiVersion: v1 - kind: Service - metadata: - annotations: - openshift.io/generated-by: OpenShiftWebConsole - creationTimestamp: 2020-01-29T13:25:14Z - labels: - app: voluba-linear-backend - name: voluba-linear-backend - namespace: voluba-linear-backend - selfLink: /api/v1/namespaces/voluba-linear-backend/services/voluba-linear-backend - uid: c8ac1a96-429a-11ea-89e4-fa163e061b5f - spec: - clusterIP: 172.30.119.239 - ports: - - name: 8080-tcp - port: 8080 - protocol: TCP - targetPort: 8080 - selector: - deploymentconfig: voluba-linear-backend - sessionAffinity: None - type: ClusterIP -- apiVersion: route.openshift.io/v1 - kind: Route - metadata: - annotations: - openshift.io/generated-by: OpenShiftWebConsole - creationTimestamp: 2020-01-29T13:25:14Z - labels: - app: voluba-linear-backend - name: voluba-linear-backend - namespace: voluba-linear-backend - selfLink: /apis/route.openshift.io/v1/namespaces/voluba-linear-backend/routes/voluba-linear-backend - uid: c8b4ba98-429a-11ea-89e4-fa163e061b5f - spec: - host: voluba-linear-backend.apps.hbp.eu - port: - targetPort: 8080-tcp - tls: - insecureEdgeTerminationPolicy: Redirect - termination: edge - to: - kind: Service - name: voluba-linear-backend - weight: 100 - wildcardPolicy: None -- apiVersion: v1 - data: - config.py: | - CORS_ORIGINS = '*' - PROXY_FIX = { - 'x_for': 1, - 'x_host': 1, - 'x_port': 1, - 'x_proto': 1, - } - kind: ConfigMap - metadata: - creationTimestamp: 2020-01-29T13:25:14Z - name: instance-dir - namespace: voluba-linear-backend - selfLink: /api/v1/namespaces/voluba-linear-backend/configmaps/instance-dir - uid: c8bfa735-429a-11ea-89e4-fa163e061b5f -kind: List -metadata: - resourceVersion: "" - selfLink: ""