Skip to content

Commit

Permalink
Issue #42: Created new deployment for finesse-guidance (#43)
Browse files Browse the repository at this point in the history
* issue #42: created new deployment for finesse-guidance

* issue #42: scaled down replicas to 1 (gke quota issue) and fixed yaml linting error

* issue #42: fixed yaml linting errors

* issue #42: fixed yaml linting error for guidance-frontend deployment

* issue #42: fixed yaml linting error for guidance ingresses
  • Loading branch information
ThomasCardin authored Feb 15, 2024
1 parent c3c19fd commit f17edc5
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: secrets-reader
namespace: finesse-guidance

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: finesse-backend
namespace: finesse-guidance
spec:
replicas: 1
selector:
matchLabels:
app: finesse-backend
template:
metadata:
labels:
app: finesse-backend
annotations:
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/role: 'secrets-reader'
vault.hashicorp.com/tls-skip-verify: 'true'
vault.hashicorp.com/agent-inject-template-.env: |
{{- with secret "apps/finesse-new" -}}
AZURE_OPENAI_CHATGPT_DEPLOYMENT="{{ .Data.data.AZURE_OPENAI_CHATGPT_DEPLOYMENT }}"
AZURE_OPENAI_GPT_DEPLOYMENT="{{ .Data.data.AZURE_OPENAI_GPT_DEPLOYMENT }}"
FINESSE_BACKEND_AZURE_SEARCH_API_KEY="{{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_API_KEY }}"
FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT="{{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT }}"
FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME="{{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME }}"
FINESSE_BACKEND_GITHUB_STATIC_FILE_URL="{{ .Data.data.FINESSE_BACKEND_GITHUB_STATIC_FILE_URL }}"
FINESSE_BACKEND_STATIC_FILE_URL="{{ .Data.data.FINESSE_BACKEND_STATIC_FILE_URL }}"
FINESSE_BACKEND_DEBUG_MODE="{{ .Data.data.FINESSE_BACKEND_DEBUG_MODE }}"
FINESSE_WEIGHTS="{{ .Data.data.FINESSE_WEIGHTS }}"
LOUIS_DSN="{{ .Data.data.LOUIS_DSN }}"
LOUIS_SCHEMA="{{ .Data.data.LOUIS_SCHEMA }}"
OPENAI_API_ENGINE="{{ .Data.data.OPENAI_API_ENGINE }}"
OPENAI_API_KEY="{{ .Data.data.OPENAI_API_KEY }}"
OPENAI_API_VERSION="{{ .Data.data.OPENAI_API_VERSION }}"
OPENAI_ENDPOINT="{{ .Data.data.OPENAI_ENDPOINT }}"
FINESSE_BACKEND_AZURE_SEARCH_PARAMS={{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_PARAMS }}
FINESSE_BACKEND_AZURE_SEARCH_TRANSFORM_MAP={{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_TRANSFORM_MAP }}
{{- end }}
spec:
serviceAccountName: secrets-reader
containers:
- name: finesse-backend
image: ghcr.io/ai-cfia/finesse-backend:main
imagePullPolicy: Always
command: ["/bin/sh", "-c"]
args:
- >
cp /vault/secrets/.env . &&
gunicorn --bind :8080 --workers 1 --threads 8 --timeout 0 --forwarded-allow-ips "*" app:app
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 60
periodSeconds: 10

---
apiVersion: v1
kind: Service
metadata:
name: finesse-backend-svc
namespace: finesse-guidance
spec:
clusterIP: None
selector:
app: finesse-backend
ports:
- protocol: TCP
port: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: finesse-frontend
namespace: finesse-guidance
spec:
replicas: 1
selector:
matchLabels:
app: finesse-frontend
template:
metadata:
labels:
app: finesse-frontend
spec:
serviceAccountName: secrets-reader
containers:
- name: finesse-frontend
image: ghcr.io/ai-cfia/finesse-frontend:main
imagePullPolicy: Always
ports:
- containerPort: 3000
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 60
periodSeconds: 10

---
apiVersion: v1
kind: Service
metadata:
name: finesse-frontend-svc
namespace: finesse-guidance
spec:
clusterIP: None
selector:
app: finesse-frontend
ports:
- protocol: TCP
port: 3000
60 changes: 60 additions & 0 deletions kubernetes/apps/finesse-guidance/finesse-guidance-ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: finesse-backend-ingress
namespace: finesse-guidance
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2 # https://kubernetes.github.io/ingress-nginx/examples/rewrite/
cert-manager.io/cluster-issuer: letsencrypt-http
ingress.kubernetes.io/force-ssl-redirect: "true"
kubernetes.io/tls-acme: "true"
spec:
ingressClassName: nginx
tls:
- hosts:
- finesse-guidance.ninebasetwo.xyz
secretName: aciacfia-tls
rules:
- host: finesse-guidance.ninebasetwo.xyz
http:
paths:
- path: /api(/|$)(.*)
pathType: ImplementationSpecific
backend:
service:
name: finesse-backend-svc
port:
number: 8080

---
# For more information check https://github.com/nginxinc/kubernetes-ingress/issues/323
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: finesse-frontend-ingress
namespace: finesse-guidance
annotations:
nginx.ingress.kubernetes.io/add-base-url: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: letsencrypt-http
ingress.kubernetes.io/force-ssl-redirect: "true"
kubernetes.io/tls-acme: "true"
spec:
ingressClassName: nginx
tls:
- hosts:
- finesse-guidance.ninebasetwo.xyz
secretName: aciacfia-tls
rules:
- host: finesse-guidance.ninebasetwo.xyz
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: finesse-frontend-svc
port:
number: 3000
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: finesse-guidance
labels:
name: finesse-guidance
4 changes: 3 additions & 1 deletion kubernetes/apps/finesse/finesse-backend-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
name: finesse-backend
namespace: finesse
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
app: finesse-backend
Expand Down Expand Up @@ -41,6 +41,8 @@ spec:
OPENAI_API_KEY="{{ .Data.data.OPENAI_API_KEY }}"
OPENAI_API_VERSION="{{ .Data.data.OPENAI_API_VERSION }}"
OPENAI_ENDPOINT="{{ .Data.data.OPENAI_ENDPOINT }}"
FINESSE_BACKEND_AZURE_SEARCH_PARAMS={{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_PARAMS }}
FINESSE_BACKEND_AZURE_SEARCH_TRANSFORM_MAP={{ .Data.data.FINESSE_BACKEND_AZURE_SEARCH_TRANSFORM_MAP }}
{{- end }}
spec:
serviceAccountName: secrets-reader
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/apps/finesse/finesse-frontend-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: finesse-frontend
namespace: finesse
spec:
replicas: 2
replicas: 1
selector:
matchLabels:
app: finesse-frontend
Expand Down

0 comments on commit f17edc5

Please sign in to comment.