Skip to content

Commit

Permalink
Merge pull request #979 from solliancenet/mg-t17631
Browse files Browse the repository at this point in the history
Adding Gateway API to the ACA Quick-Start deployment (and helm chart)
  • Loading branch information
ciprianjichici authored May 16, 2024
2 parents 0c5923b + 999ec62 commit 5bb4710
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 0 deletions.
23 changes: 23 additions & 0 deletions deploy/common/helm/gateway-api/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
5 changes: 5 additions & 0 deletions deploy/common/helm/gateway-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: gateway-api
version: 0.0.0
40 changes: 40 additions & 0 deletions deploy/common/helm/gateway-api/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "gateway-api.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 "gateway-api.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 "gateway-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "gateway-api.apihost" -}}
{{- if .Values.apihost -}}
{{- printf "%s" .Values.apihost -}}
{{- else -}}
{{- printf "%s" (index .Values.ingress.hosts 0) -}}
{{- end -}}
{{- end -}}
13 changes: 13 additions & 0 deletions deploy/common/helm/gateway-api/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- $name := include "gateway-api.fullname" . -}}

apiVersion: v1
kind: ConfigMap
metadata:
name: "cfg-{{ $name }}"
labels:
app: {{ template "gateway-api.name" . }}
chart: {{ template "gateway-api.chart" .}}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
AZURE_CLIENT_ID: {{ .Values.azureWorkloadIdentity.gatewayApiClientId }}
84 changes: 84 additions & 0 deletions deploy/common/helm/gateway-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{- $name := include "gateway-api.fullname" . -}}
{{- $cfgname := printf "%s-%s" "cfg" $name -}}
{{- $secretName := printf "%s-%s" "secret" $name -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "gateway-api.fullname" . }}
labels:
app: {{ template "gateway-api.name" . }}
chart: {{ template "gateway-api.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "gateway-api.name" . }}
release: {{ .Release.Name }}
template:
metadata:
annotations:
rollme: {{ randAlphaNum 5 | quote }}
labels:
app: {{ template "gateway-api.name" . }}
release: {{ .Release.Name }}
azure.workload.identity/use: "true"
spec:
serviceAccountName: {{ .Values.serviceAccountName }}
{{ if .Values.imagePullSecrets -}}
imagePullSecrets:
{{ range .Values.imagePullSecrets -}}
- name: {{ .name }}
{{- end -}}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.env.values -}}
{{- range .Values.env.values }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end -}}
{{- end -}}
{{- if .Values.env.configmap -}}
{{- range .Values.env.configmap }}
- name: {{ .name }}
valueFrom:
configMapKeyRef:
name: {{ $cfgname }}
key: {{ .name }}
{{- end -}}
{{- end }}
{{- if .Values.env.secret -}}
{{- range .Values.env.secret }}
- name: {{ .name }}
valueFrom:
secretKeyRef:
name: {{ $secretName }}
key: {{ .name }}
{{- end -}}
{{- end }}
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{ toYaml .Values.resources | indent 12 }}
securityContext:
readOnlyRootFilesystem: true
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

41 changes: 41 additions & 0 deletions deploy/common/helm/gateway-api/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "gateway-api.fullname" . -}}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "gateway-api.name" . }}
chart: {{ template "gateway-api.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: /gateway(/|$)(.*)
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
number: 80
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions deploy/common/helm/gateway-api/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- $name := include "gateway-api.fullname" . -}}

apiVersion: v1
kind: Secret
metadata:
name: "secret-{{ $name }}"
labels:
app: {{ template "gateway-api.name" . }}
chart: {{ template "gateway-api.chart" .}}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
FoundationaLLM_AppConfig_ConnectionString: {{ .Values.appConfig.connectionString | b64enc }}
19 changes: 19 additions & 0 deletions deploy/common/helm/gateway-api/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "gateway-api.fullname" . }}
labels:
app: {{ template "gateway-api.name" . }}
chart: {{ template "gateway-api.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ template "gateway-api.name" . }}
release: {{ .Release.Name }}
9 changes: 9 additions & 0 deletions deploy/common/helm/gateway-api/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccountName }}
annotations:
azure.workload.identity/client-id: {{ .Values.azureWorkloadIdentity.gatewayApiClientId }}
azure.workload.identity/tenant-id: {{ .Values.azureWorkloadIdentity.tenantId }}
labels:
azure.workload.identity/use: "true"
35 changes: 35 additions & 0 deletions deploy/common/helm/gateway-api/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Default values for gateway-api.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
serviceAccountName: gateway-api
image:
repository: ghcr.io/solliancenet/foundationallm/gateway-api
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: latest

service:
type: ClusterIP
port: 80

resources: {}

nodeSelector: {}

tolerations: []

affinity: {}

ingress:
enabled: false

env:
configmap:
- name: AZURE_CLIENT_ID
secret:
- name: FoundationaLLM_AppConfig_ConnectionString
values:
- name: ASPNETCORE_ENVIRONMENT
value: Production
8 changes: 8 additions & 0 deletions deploy/quick-start/infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@
"appConfigEnvironmentVarName": "FoundationaLLM_AppConfig_ConnectionString",
"apiKeySecretName": "foundationallm-apis-gatekeeperapi-apikey"
},
{
"name": "gateway-api",
"useEndpoint": true,
"hasIngress": true,
"image": "${SERVICE_GATEWAYAPI_IMAGE=cropseastus2svinternal.azurecr.io/gateway-api:${FLLM_VERSION}}",
"appConfigEnvironmentVarName": "FoundationaLLM_AppConfig_ConnectionString",
"apiKeySecretName": "foundationallm-apis-gatewayapi-apikey"
},
{
"name": "gatekeeper-integration-api",
"useEndpoint": true,
Expand Down
4 changes: 4 additions & 0 deletions src/dotnet/GatewayAPI/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .

RUN dotnet restore "dotnet/Common/Common.csproj"
RUN dotnet build "dotnet/Common/Common.csproj" -c Release -o /app/build

RUN dotnet restore "dotnet/Gateway/Gateway.csproj"
RUN dotnet build "dotnet/Gateway/Gateway.csproj" -c Release -o /app/build

RUN dotnet restore "dotnet/GatewayAPI/GatewayAPI.csproj"
RUN dotnet build "dotnet/GatewayAPI/GatewayAPI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "dotnet/Common/Common.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet publish "dotnet/Gateway/Gateway.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet publish "dotnet/GatewayAPI/GatewayAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false

Expand Down
7 changes: 7 additions & 0 deletions tests/config/e2e-test-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
"helm_chart": "./deploy/common/helm/gatekeeper-integration-api",
"azd_env_key": "SERVICE_GATEKEEPERINTEGRATIONAPI_IMAGE"
},
{
"name": "gateway-api",
"context": "./src",
"dockerfile": "./src/dotnet/GatewayAPI/Dockerfile",
"helm_chart": "./deploy/common/helm/gateway-api",
"azd_env_key": "SERVICE_GATEWAYAPI_IMAGE"
},
{
"name": "langchain-api",
"context": "./src/python",
Expand Down

0 comments on commit 5bb4710

Please sign in to comment.