diff --git a/.env b/.env index d7a0876..76941f5 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ REGISTRY_PREFIX=harbor.sheldan.dev/oneplus-bot/ ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/ VERSION=1.6.22 -ABSTRACTO_VERSION=1.5.27 \ No newline at end of file +ABSTRACTO_VERSION=1.5.32 \ No newline at end of file diff --git a/Tiltfile b/Tiltfile index 8005ab6..22e098d 100644 --- a/Tiltfile +++ b/Tiltfile @@ -31,6 +31,7 @@ docker_build_with_restart( docker_build(registry + 'oneplus-bot-db-data', 'deployment/image-packaging/src/main/docker/db-data/') docker_build(registry + 'oneplus-bot-template-data', 'deployment/image-packaging/src/main/docker/template-data/') docker_build(registry + 'oneplus-bot-private-rest-api', 'deployment/image-packaging/src/main/docker/private-rest-api/', build_args={'REGISTRY_PREFIX': abstracto_registry}) +docker_build(registry + 'oneplus-bot-rest-api', 'deployment/image-packaging/src/main/docker/rest-api/', build_args={'REGISTRY_PREFIX': abstracto_registry}) local('cd tilt/oneplusbot-dev && helm dep up') diff --git a/deployment/helm/oneplus-bot/templates/rest-api-deployment.yaml b/deployment/helm/oneplus-bot/templates/rest-api-deployment.yaml new file mode 100644 index 0000000..2471125 --- /dev/null +++ b/deployment/helm/oneplus-bot/templates/rest-api-deployment.yaml @@ -0,0 +1,70 @@ +{{- if .Values.restApi.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "oneplusBot.fullname" . }}-rest-api +spec: + replicas: 1 + selector: + matchLabels: + app: rest-api + template: + metadata: + {{- with .Values.restApi.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app: rest-api + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "oneplusBot.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.restApi.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }}-rest-api + securityContext: + {{- toYaml .Values.restApi.securityContext | nindent 12 }} + image: "{{ .Values.restApi.repository }}/{{ .Values.restApi.image }}:{{ .Values.restApi.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.restApi.pullPolicy }} + env: + - name: BACKEND_HOST + value: "{{ include "oneplusBot.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local" + - name: BACKEND_PORT + value: "{{ .Values.service.port }}" + ports: + - name: {{ .Values.restApi.service.name }} + containerPort: {{ .Values.restApi.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: {{ .Values.restApi.service.port }} + initialDelaySeconds: {{ $.Values.restApi.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.restApi.livenessProbe.periodSeconds }} + failureThreshold: {{ $.Values.restApi.livenessProbe.failureThreshold }} + readinessProbe: + httpGet: + path: / + port: {{ .Values.restApi.service.port }} + initialDelaySeconds: {{ $.Values.restApi.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ $.Values.restApi.readinessProbe.periodSeconds }} + failureThreshold: {{ $.Values.restApi.readinessProbe.failureThreshold }} + resources: + {{- toYaml .Values.restApi.resources | nindent 12 }} + {{- with .Values.restApi.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.restApi.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.restApi.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/deployment/helm/oneplus-bot/templates/rest-api-ingress.yaml b/deployment/helm/oneplus-bot/templates/rest-api-ingress.yaml new file mode 100644 index 0000000..ec2eea1 --- /dev/null +++ b/deployment/helm/oneplus-bot/templates/rest-api-ingress.yaml @@ -0,0 +1,45 @@ +{{- if .Values.restApi.enabled -}} +{{- $servicePort := .Values.restApi.service.port -}} +{{- $serviceName := .Values.restApi.service.name -}} +{{- $ingressPath := .Values.restApi.ingress.path -}} +{{- $ingressPathType := .Values.restApi.ingress.pathType -}} +{{- $extraPaths := .Values.restApi.ingress.extraPaths -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-rest-api + labels: + {{- with .Values.restApi.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.restApi.ingress.annotations }} + annotations: + {{- range $key, $value := . }} + {{ $key }}: {{ tpl $value $ | quote }} + {{- end }} + {{- end }} +spec: + ingressClassName: nginx + {{- with .Values.restApi.ingress.tls }} + tls: + {{- tpl (toYaml .) $ | nindent 4 }} + {{- end }} + rules: + {{- if .Values.restApi.ingress.hosts }} + {{- range .Values.restApi.ingress.hosts }} + - host: {{ tpl . $ }} + http: + paths: + {{- with $extraPaths }} + {{- toYaml . | nindent 10 }} + {{- end }} + - path: {{ $ingressPath }} + pathType: {{ $ingressPathType }} + backend: + service: + name: {{ $serviceName }} + port: + number: {{ $servicePort }} + {{- end }} + {{- end -}} +{{- end }} diff --git a/deployment/helm/oneplus-bot/templates/rest-api-service.yaml b/deployment/helm/oneplus-bot/templates/rest-api-service.yaml new file mode 100644 index 0000000..4389281 --- /dev/null +++ b/deployment/helm/oneplus-bot/templates/rest-api-service.yaml @@ -0,0 +1,12 @@ +{{- if .Values.restApi.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.restApi.service.name }} +spec: + selector: + app: rest-api + ports: + - port: {{ .Values.restApi.service.targetPort }} + targetPort: {{ .Values.restApi.service.port }} +{{- end }} diff --git a/deployment/helm/oneplus-bot/values.yaml b/deployment/helm/oneplus-bot/values.yaml index 6b7a6e3..9a06804 100644 --- a/deployment/helm/oneplus-bot/values.yaml +++ b/deployment/helm/oneplus-bot/values.yaml @@ -21,7 +21,7 @@ templateDeployment: repository: harbor.sheldan.dev/abstracto pullPolicy: Always image: abstracto-template-deployment - tag: 1.5.27 + tag: 1.5.32 templateDeploymentData: repository: harbor.sheldan.dev/oneplus-bot pullPolicy: Always @@ -32,7 +32,7 @@ dbConfigDeployment: repository: harbor.sheldan.dev/abstracto pullPolicy: Always image: abstracto-db-deployment - tag: 1.5.27 + tag: 1.5.32 dbConfigDeploymentData: repository: harbor.sheldan.dev/oneplus-bot pullPolicy: Always @@ -76,6 +76,46 @@ privateRestApi: nodeSelector: {} tolerations: [] affinity: {} +restApi: + enabled: true + repository: harbor.sheldan.dev/oneplus-bot + pullPolicy: Always + image: oneplus-bot-rest-api + tag: 1.6.22 + podAnnotations: {} + podSecurityContext: {} + securityContext: {} + livenessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + failureThreshold: 3 + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 5 + failureThreshold: 3 + service: + port: 8080 + targetPort: 80 + name: rest-api + resources: + limits: + cpu: null + memory: null + requests: + cpu: null + memory: null + nodeSelector: {} + tolerations: [] + affinity: {} + ingress: + enabled: false + annotations: {} + labels: {} + path: / + pathType: Prefix + hosts: null + extraPaths: [] + tls: [] grafanaDeployment: repository: harbor.sheldan.dev/grafana-tools pullPolicy: Always diff --git a/deployment/image-packaging/src/main/docker/rest-api/Dockerfile b/deployment/image-packaging/src/main/docker/rest-api/Dockerfile new file mode 100644 index 0000000..ec0bc9e --- /dev/null +++ b/deployment/image-packaging/src/main/docker/rest-api/Dockerfile @@ -0,0 +1,9 @@ +ARG REGISTRY_PREFIX +ARG ABSTRACTO_VERSION +FROM ${REGISTRY_PREFIX}abstracto-rest-api-experience:${ABSTRACTO_VERSION:-latest} AS experience-api +FROM ${REGISTRY_PREFIX}abstracto-rest-api-core:${ABSTRACTO_VERSION:-latest} AS core-api + + +FROM ${REGISTRY_PREFIX}abstracto-rest-api:${ABSTRACTO_VERSION:-latest} +COPY --from=core-api /python /python +COPY --from=experience-api /python /python diff --git a/docker-compose.yml b/docker-compose.yml index 7246b25..0f6cba4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,13 @@ services: REGISTRY_PREFIX: ${ABSTRACTO_PREFIX} ABSTRACTO_VERSION: ${ABSTRACTO_VERSION} image: ${REGISTRY_PREFIX}oneplus-bot-private-rest-api:${VERSION:-latest} + rest-api-packaging: + build: + context: deployment/image-packaging/src/main/docker/rest-api + args: + REGISTRY_PREFIX: ${ABSTRACTO_PREFIX} + ABSTRACTO_VERSION: ${ABSTRACTO_VERSION} + image: ${REGISTRY_PREFIX}oneplus-bot-rest-api:${VERSION:-latest} template-data: build: context: deployment/image-packaging/src/main/docker/template-data diff --git a/pom.xml b/pom.xml index aeee65e..f3839ce 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 17 17 - 1.5.27 + 1.5.32 1.4.35