Skip to content

Commit 2eadfac

Browse files
committed
WIP
1 parent 805a02f commit 2eadfac

File tree

8 files changed

+43
-120
lines changed

8 files changed

+43
-120
lines changed

scenarios/AksOpenAiTerraform/scripts/build-image.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

scenarios/AksOpenAiTerraform/scripts/deploy-app.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

scenarios/AksOpenAiTerraform/scripts/install.sh renamed to scenarios/AksOpenAiTerraform/scripts/deploy.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Variables
2+
SUBSCRIPTION_ID=$(az account show --query id --output tsv)
3+
TENANT_ID=$(az account show --query tenantId --output tsv)
4+
RESOURCE_GROUP=$(terraform output resource_group_name)
5+
LOCATION="westus3"
6+
7+
# Build/Push App's Docker image
8+
ACR_NAME=$(terraform output resource_group_name)
9+
az acr login --name $ACR_NAME
10+
ACR_URL=$(az acr show --name $ACR_NAME --query loginServer --output tsv)
11+
docker build -t $ACR_URL/$ACR_NAME.azurecr.io/magic8ball:v1 ./app --push
12+
113
# Get AKS credentials
214
az aks get-credentials \
315
--admin \
@@ -11,7 +23,7 @@ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 -o get_
1123
chmod 700 get_helm.sh
1224
./get_helm.sh &>/dev/null
1325

14-
# NGINX ingress controller
26+
# Install NGINX ingress controller
1527
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
1628
helm install nginx-ingress ingress-nginx/ingress-nginx \
1729
--create-namespace \
@@ -24,23 +36,42 @@ helm install nginx-ingress ingress-nginx/ingress-nginx \
2436
--set controller.metrics.serviceMonitor.enabled=true \
2537
--set controller.metrics.serviceMonitor.additionalLabels.release="prometheus" \
2638

27-
# Cert manager
39+
# Install Cert manager
2840
helm repo add jetstack https://charts.jetstack.io
2941
helm install cert-manager jetstack/cert-manager \
3042
--create-namespace \
3143
--namespace "cert-manager" \
3244
--set installCRDs=true \
3345
--set nodeSelector."kubernetes\.io/os"=linux
3446

35-
# Prometheus
47+
# Install Prometheus
3648
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
3749
helm install prometheus prometheus-community/kube-prometheus-stack \
3850
--create-namespace \
3951
--namespace prometheus \
4052
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
4153
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false
4254

43-
kubectl create namespace $namespace # Create workload namespace
55+
NAMESPACE="magic8ball"
56+
kubectl create namespace $NAMESPACE
4457
kubectl apply -f cluster-issuer.yml
4558
kubectl apply -f service-account.yml
46-
kubectl apply -n $namespace -f ingress.yml
59+
kubectl apply -n $NAMESPACE -f ingress.yml
60+
kubectl apply -n $NAMESPACE -f config-map.yml
61+
kubectl apply -n $NAMESPACE -f deployment.yml
62+
kubectl apply -f "service.yml" -n $NAMESPACE
63+
64+
# Add DNS Record
65+
ingressName="magic8ball-ingress"
66+
publicIpAddress=$(kubectl get ingress $ingressName -n $namespace -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
67+
if [ -n $publicIpAddress ]; then
68+
echo "[$publicIpAddress] external IP address of the application gateway ingress controller successfully retrieved from the [$ingressName] ingress"
69+
else
70+
echo "Failed to retrieve the external IP address of the application gateway ingress controller from the [$ingressName] ingress"
71+
exit
72+
fi
73+
az network dns record-set a add-record \
74+
--zone-name "contoso.com" \
75+
--resource-group $RESOURCE_GROUP \
76+
--record-set-name magic8ball \
77+
--ipv4-address $publicIpAddress

scenarios/AksOpenAiTerraform/scripts/dns.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

scenarios/AksOpenAiTerraform/scripts/manifests/deployment.yml

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -75,49 +75,6 @@ spec:
7575
initialDelaySeconds: 60
7676
periodSeconds: 30
7777
timeoutSeconds: 5
78-
env:
79-
- name: TITLE
80-
valueFrom:
81-
configMapKeyRef:
82-
name: magic8ball-configmap
83-
key: TITLE
84-
- name: IMAGE_WIDTH
85-
valueFrom:
86-
configMapKeyRef:
87-
name: magic8ball-configmap
88-
key: IMAGE_WIDTH
89-
- name: LABEL
90-
valueFrom:
91-
configMapKeyRef:
92-
name: magic8ball-configmap
93-
key: LABEL
94-
- name: TEMPERATURE
95-
valueFrom:
96-
configMapKeyRef:
97-
name: magic8ball-configmap
98-
key: TEMPERATURE
99-
- name: AZURE_OPENAI_TYPE
100-
valueFrom:
101-
configMapKeyRef:
102-
name: magic8ball-configmap
103-
key: AZURE_OPENAI_TYPE
104-
- name: AZURE_OPENAI_BASE
105-
valueFrom:
106-
configMapKeyRef:
107-
name: magic8ball-configmap
108-
key: AZURE_OPENAI_BASE
109-
- name: AZURE_OPENAI_KEY
110-
valueFrom:
111-
configMapKeyRef:
112-
name: magic8ball-configmap
113-
key: AZURE_OPENAI_KEY
114-
- name: AZURE_OPENAI_MODEL
115-
valueFrom:
116-
configMapKeyRef:
117-
name: magic8ball-configmap
118-
key: AZURE_OPENAI_MODEL
119-
- name: AZURE_OPENAI_DEPLOYMENT
120-
valueFrom:
121-
configMapKeyRef:
122-
name: magic8ball-configmap
123-
key: AZURE_OPENAI_DEPLOYMENT
78+
envFrom:
79+
- configMapKeyRef:
80+
name: magic8ball-configmap

scenarios/AksOpenAiTerraform/scripts/vars.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

scenarios/AksOpenAiTerraform/terraform/modules/aks/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
2020
image_cleaner_enabled = true
2121
image_cleaner_interval_hours = 72
2222

23+
workload_identity_enabled = true
24+
oidc_issuer_enabled = true
25+
2326
default_node_pool {
2427
name = "system"
2528
node_count = 1

scenarios/AksOpenAiTerraform/terraform/modules/aks/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ output "id" {
77
}
88

99
output "aks_identity_principal_id" {
10-
value = azurerm_user_assigned_identity.aks.id
10+
value = azurerm_user_assigned_identity.aks.principal_id
1111
}
1212

1313
output "kubelet_identity_object_id" {

0 commit comments

Comments
 (0)