Skip to content

Commit 7ccaa68

Browse files
committed
Dockerfile-aks, nginx conf for aca and aks, Working on easy auth, working on cert manager
1 parent 3a16328 commit 7ccaa68

24 files changed

+853
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,4 @@ static/
152152

153153
# Generated manifests
154154
app/backend/manifests/azd-env-configmap.yml
155+
deploy/aks/easyauth/config-output.md

app/frontend/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ FROM nginx:alpine
1414

1515
WORKDIR /usr/share/nginx/html
1616
COPY --from=build /app/build .
17-
COPY --from=build /app/nginx/default.conf /etc/nginx/conf.d
17+
COPY --from=build /app/nginx/nginx.conf.template /etc/nginx/conf.d
1818

1919
EXPOSE 80
2020

21-
#CMD ["/bin/sh", "-c", "envsubst < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g \"daemon off;\""]
22-
CMD ["/bin/sh", "-c", "nginx -g \"daemon off;\""]
21+
CMD ["/bin/sh", "-c", "envsubst < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g \"daemon off;\""]

app/frontend/Dockerfile-aks

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:18-alpine AS build
2+
3+
# make the 'app' folder the current working directory
4+
WORKDIR /app
5+
6+
COPY . .
7+
8+
9+
# install project dependencies
10+
RUN npm install
11+
RUN npm run build
12+
13+
FROM nginx:alpine
14+
15+
WORKDIR /usr/share/nginx/html
16+
COPY --from=build /app/build .
17+
COPY --from=build /app/nginx/default.conf /etc/nginx/conf.d
18+
19+
EXPOSE 80
20+
21+
CMD ["/bin/sh", "-c", "nginx -g \"daemon off;\""]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
4+
access_log /var/log/nginx/default.access.log;
5+
error_log /var/log/nginx/default.error.log;
6+
7+
location / {
8+
root /usr/share/nginx/html;
9+
index index.html index.htm;
10+
try_files $uri $uri/ =404;
11+
}
12+
13+
location /api {
14+
proxy_ssl_server_name on;
15+
proxy_http_version 1.1;
16+
proxy_pass $REACT_APP_API_BASE_URL;
17+
}
18+
}

deploy/aks/azure.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ services:
2424
host: aks
2525
k8s:
2626
namespace: azure-open-ai
27+
docker:
28+
path: ./Dockerfile-aks
2729

2830
infra:
2931
path: ./infra
@@ -35,7 +37,12 @@ hooks:
3537
run: ./scripts/predeploy.ps1
3638
interactive: true
3739
continueOnError: false
38-
postprovision:
40+
posix:
41+
shell: sh
42+
run: ./scripts/predeploy.sh
43+
interactive: true
44+
continueOnError: false
45+
postdeploy:
3946
windows:
4047
shell: pwsh
4148
run: ./scripts/prepdocs.ps1
@@ -46,3 +53,15 @@ hooks:
4653
run: ./scripts/prepdocs.sh
4754
interactive: true
4855
continueOnError: false
56+
postup:
57+
windows:
58+
shell: pwsh
59+
run: ./scripts/easyauth.ps1
60+
interactive: true
61+
continueOnError: false
62+
postdown:
63+
windows:
64+
shell: pwsh
65+
run: ./scripts/easyauth-down.ps1
66+
interactive: true
67+
continueOnError: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: ClusterIssuer
3+
metadata:
4+
name: letsencrypt
5+
spec:
6+
acme:
7+
server: https://acme-v02.api.letsencrypt.org/directory
8+
9+
privateKeySecretRef:
10+
name: letsencrypt
11+
solvers:
12+
- http01:
13+
ingress:
14+
class: nginx
15+
podTemplate:
16+
spec:
17+
nodeSelector:
18+
"kubernetes.io/os": linux
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: easyauth-ingress-default
5+
annotations:
6+
nginx.ingress.kubernetes.io/auth-url: "https://$host/easyauth/auth"
7+
nginx.ingress.kubernetes.io/auth-signin: "https://$host/easyauth/login"
8+
nginx.ingress.kubernetes.io/auth-response-headers: "x-injected-userinfo,x-injected-name,x-injected-oid,x-injected-preferred-username,x-injected-sub,x-injected-tid,x-injected-email,x-injected-groups,x-injected-scp,x-injected-roles,x-injected-graph"
9+
cert-manager.io/cluster-issuer: letsencrypt
10+
#nginx.ingress.kubernetes.io/rewrite-target: "/$1"
11+
kubernetes.io/ingress.class: "nginx"
12+
spec:
13+
ingressClassName: nginx
14+
tls:
15+
- hosts:
16+
- aks-openai-easy-auth-proxy.westeurope.cloudapp.azure.com
17+
secretName: aks-openai-easy-auth-proxy.westeurope.cloudapp.azure.com-tls
18+
rules:
19+
- host: aks-openai-easy-auth-proxy.westeurope.cloudapp.azure.com
20+
http:
21+
paths:
22+
- path: /api
23+
pathType: Prefix
24+
backend:
25+
service:
26+
name: backend-service
27+
port:
28+
number: 80
29+
- path: /
30+
pathType: Prefix
31+
backend:
32+
service:
33+
name: frontend-service
34+
port:
35+
number: 80
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: easyauth-proxy
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.2
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
appVersion: 1.0.2
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "easyauth-proxy.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "easyauth-proxy.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "easyauth-proxy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "easyauth-proxy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
echo "Visit http://127.0.0.1:8080 to use your application"
20+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
21+
{{- end }}

0 commit comments

Comments
 (0)