Skip to content

Commit bca8032

Browse files
authored
IaC/Helm (#127)
* Helm and IaC
1 parent 9344bad commit bca8032

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+827
-677
lines changed

.github/workflows/pytest.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
- opened
88
- synchronize
99
- reopened
10-
paths:
11-
- "src/**"
1210

1311
# Allows running this workflow manually
1412
workflow_dispatch:

.gitignore

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
**/*.log
66
**/requirements.txt
77
app/THIRD_PARTY_LICENSES.txt
8-
helm/values*.yaml
9-
helm/service.yaml
10-
helm/ingress.yaml
118
sbin/**
129
**/*.bak
1310
**/tmp/**
1411
**/temp/**
1512
**/chatbot_graph.png
1613
**/*.sh
17-
!opentofu/oci/templates/cloudinit-oke.sh
14+
!opentofu/templates/cloudinit-oke.sh
1815
!src/entrypoint.sh
1916
!src/client/spring_ai/templates/env.sh
2017

@@ -40,6 +37,20 @@ __pycache__/
4037
*/*.egg-info
4138
**/build/
4239

40+
##############################################################################
41+
# IaC
42+
##############################################################################
43+
**/**.tfvars
44+
**/.terraform*
45+
**/terraform.tfstate*
46+
opentofu/**/examples/*.yaml
47+
48+
##############################################################################
49+
# Helm
50+
##############################################################################
51+
helm/values*.yaml
52+
!helm/values.yaml
53+
4354
##############################################################################
4455
# Random
4556
##############################################################################

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ To run the application in a container; download the [source](https://github.com/
7373

7474
```bash
7575
cd src/
76-
podman build -t oai-explorer-aio .
76+
podman build -t ai-explorer-aio .
7777
```
7878

7979
1. Start the Container:
8080

8181
```bash
82-
podman run -p 8501:8501 -it --rm oai-explorer-aio
82+
podman run -p 8501:8501 -it --rm ai-explorer-aio
8383
```
8484

8585
1. Navigate to `http://localhost:8501`.

docs/content/advanced/microservices.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,47 @@ The following example shows running the {{< short_app_ref >}} in [Oracle Kuberne
2020

2121
The command to connect to the **OKE** cluster will be output as part of the **IaC**.
2222

23+
### Images
24+
25+
You will need to build the {{< short_app_ref >}} container images and stage them in a container registry, such as the [OCI Container Registry](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryoverview.htm) (**OCIR**).
26+
27+
1. Build the {{< short_app_ref >}} images:
28+
29+
From the code source `src/` directory:
30+
```bash
31+
podman build --arch amd64 -f client/Dockerfile -t ai-explorer-client:latest .
32+
33+
podman build --arch amd64 -f server/Dockerfile -t ai-explorer-server:latest .
34+
```
35+
36+
1. Log into your container registry:
37+
38+
More information on authenticating to **OCIR** can be found [here](https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrypushingimagesusingthedockercli.htm).
39+
40+
```bash
41+
podman login <registry-domain>
42+
```
43+
44+
Example:
45+
```bash
46+
podman login iad.ocir.io
47+
```
48+
49+
You will be prompted for a username and token password.
50+
51+
1. Push the {{< short_app_ref >}} images:
52+
53+
More information on pushing images to **OCIR** can be found [here](https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrypushingimagesusingthedockercli.htm).
54+
55+
Example (the values for `<server_repository>` and `<server_repository>` are provided from the **IaC**):
56+
```bash
57+
podman tag ai-explorer-client:latest <client_repository>:latest
58+
podman push <client_repository>:latest
59+
60+
podman tag ai-explorer-server:latest <server_repository>:latest
61+
podman push <server_repository>:latest
62+
```
63+
2364
### Ingress
2465

2566
To access the {{< short_app_ref >}} GUI and API Server, you can either use a port-forward or an Ingress service. For demonstration purposes, the [Ingress-Nginx Controller](https://kubernetes.github.io/ingress-nginx/deploy/) will be used to create a [Flexible LoadBalancer](https://docs.oracle.com/en-us/iaas/Content/NetworkLoadBalancer/overview.htm) in **OCI**.
@@ -104,47 +145,6 @@ These will be output as part of the **IaC** but can be removed from the code if
104145
kubectl apply -f service.yaml
105146
```
106147

107-
### Images
108-
109-
You will need to build the {{< short_app_ref >}} container images and stage them in a container registry, such as the [OCI Container Registry](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryoverview.htm) (**OCIR**).
110-
111-
1. Build the {{< short_app_ref >}} images:
112-
113-
From the code source `src/` directory:
114-
```bash
115-
podman build --arch amd64 -f client/Dockerfile -t ai-explorer-client:latest .
116-
117-
podman build --arch amd64 -f server/Dockerfile -t ai-explorer-server:latest .
118-
```
119-
120-
1. Log into your container registry:
121-
122-
More information on authenticating to **OCIR** can be found [here](https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrypushingimagesusingthedockercli.htm).
123-
124-
```bash
125-
podman login <registry-domain>
126-
```
127-
128-
Example:
129-
```bash
130-
podman login iad.ocir.io
131-
```
132-
133-
You will be prompted for a username and token password.
134-
135-
1. Push the {{< short_app_ref >}} images:
136-
137-
More information on pushing images to **OCIR** can be found [here](https://docs.oracle.com/en-us/iaas/Content/Registry/Tasks/registrypushingimagesusingthedockercli.htm).
138-
139-
Example (the values for `<server_repository>` and `<server_repository>` are provided from the **IaC**):
140-
```bash
141-
podman tag ai-explorer-client:latest <client_repository>:latest
142-
podman push <client_repository>:latest
143-
144-
podman tag ai-explorer-server:latest <server_repository>:latest
145-
podman push <server_repository>:latest
146-
```
147-
148148
### The {{< short_app_ref >}}
149149

150150
The {{< short_app_ref >}} can be deployed using the [Helm](https://helm.sh/) chart provided with the source:

helm/Chart.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ description: A Helm chart Oracle AI Explorer for Apps
77
type: application
88
version: 0.1.0
99
appVersion: "0.1.0"
10+
icon: https://github.com/oracle-samples/ai-explorer/blob/main/src/client/media/logo.png
1011
maintainers:
1112
- name: Oracle
1213
1314
url: https://github.com/oracle-samples/ai-explorer
1415

1516
dependencies:
16-
- name: ai-explorer-server
17+
- name: server
1718
version: 0.1.0
18-
repository: file://charts/ai-explorer-server
19-
condition: ai-explorer-server.enabled
20-
- name: ai-explorer-client
19+
repository: file://charts/server
20+
condition: server.enabled
21+
- name: client
2122
version: 0.1.0
22-
repository: file://charts/ai-explorer-client
23-
condition: ai-explorer-client.enabled
23+
repository: file://charts/client
24+
condition: client.enabled
2425
- name: ollama
2526
version: 0.1.0
2627
repository: file://charts/ollama

helm/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This Helm Chart requires three Kubernetes Secrets to be created prior to install
66

77
### Registry Credentials
88

9-
**Note**: This requirement maybe deprecated in OCI/OKE: [Credential Provider](https://github.com/oracle-devrel/oke-credential-provider-for-ocir/issues/2)
9+
**Note**: This requirement is deprecated in OCI/OKE when using the IaC from opentofu: [Credential Provider](https://github.com/oracle-devrel/oke-credential-provider-for-ocir)
1010

1111
```yaml
1212
apiVersion: v1
@@ -21,7 +21,7 @@ stringData:
2121
Example:
2222
2323
```bash
24-
docker login iad.ocir.io -u <username>
24+
podman login iad.ocir.io -u <username>
2525
kubectl create secret docker-registry regcred --from-file=.dockerconfigjson=/run/user/1002/containers/auth.json
2626
```
2727

@@ -60,11 +60,11 @@ stringData:
6060
## Install
6161
6262
```bash
63-
helm upgrade --install oai-explorer .
63+
helm upgrade --install ai-explorer .
6464
```
6565

6666
## Uninstall
6767

6868
```bash
69-
helm uninstall oai-explorer
69+
helm uninstall ai-explorer
7070
```

helm/charts/oaim-sandbox/Chart.yaml renamed to helm/charts/client/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## Licensed under the Universal Permissive License v1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
apiVersion: v2
5-
name: ai-explorer-client
5+
name: client
66
description: A Helm chart Oracle AI Explorer for Apps - GUI
77
type: application
88
version: 0.1.0

helm/charts/oaim-sandbox/templates/configmap.yaml renamed to helm/charts/client/templates/configmap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
apiVersion: v1
55
kind: ConfigMap
66
metadata:
7-
name: {{ include "oai.fullname" . }}-st-config
7+
name: {{ include "app.fullname" . }}-st-config
88
labels:
9-
{{- include "oai.labels" . | nindent 4 }}
9+
{{- include "app.labels" . | nindent 4 }}
1010
data:
1111
config.toml: |
1212
[global]

helm/charts/oaim-sandbox/templates/deployment.yaml renamed to helm/charts/client/templates/deployment.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
apiVersion: apps/v1
55
kind: Deployment
66
metadata:
7-
name: {{ include "oai.fullname" . }}
7+
name: {{ include "app.fullname" . }}
88
labels:
9-
{{- include "oai.labels" . | nindent 4 }}
9+
{{- include "app.labels" . | nindent 4 }}
1010
spec:
1111
{{- if not .Values.autoscaling.enabled }}
1212
replicas: {{ .Values.replicaCount }}
1313
{{- end }}
1414
selector:
1515
matchLabels:
16-
{{- include "oai.selectorLabels" . | nindent 6 }}
16+
{{- include "app.selectorLabels" . | nindent 6 }}
1717
template:
1818
metadata:
1919
{{- with .Values.podAnnotations }}
2020
annotations:
2121
{{- toYaml . | nindent 8 }}
2222
{{- end }}
2323
labels:
24-
{{- include "oai.labels" . | nindent 8 }}
24+
{{- include "app.labels" . | nindent 8 }}
2525
{{- with .Values.podLabels }}
2626
{{- toYaml . | nindent 8 }}
2727
{{- end }}
@@ -30,7 +30,7 @@ spec:
3030
imagePullSecrets:
3131
{{- toYaml . | nindent 8 }}
3232
{{- end }}
33-
serviceAccountName: {{ include "oai.serviceAccountName" . }}
33+
serviceAccountName: {{ include "app.serviceAccountName" . }}
3434
securityContext:
3535
fsGroup: 10001
3636
containers:
@@ -45,21 +45,21 @@ spec:
4545
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4646
imagePullPolicy: {{ .Values.imagePullPolicy | default "IfNotPresent" }}
4747
ports:
48-
- name: http
48+
- name: client-port
4949
containerPort: 8501
5050
protocol: TCP
5151
livenessProbe:
5252
httpGet:
5353
path: {{ include "getPath" . }}ping
54-
port: http
54+
port: client-port
5555
initialDelaySeconds: 20
5656
periodSeconds: 20
5757
timeoutSeconds: 1
5858
failureThreshold: 3
5959
readinessProbe:
6060
httpGet:
6161
path: {{ include "getPath" . }}ping
62-
port: http
62+
port: client-port
6363
initialDelaySeconds: 10
6464
periodSeconds: 15
6565
timeoutSeconds: 1
@@ -76,7 +76,7 @@ spec:
7676
{{- end }}
7777
{{- end }}
7878
- name: API_SERVER_URL
79-
value: {{ include "ai-explorer-server.serviceUrl" . }}
79+
value: {{ include "server.serviceUrl" . }}
8080
- name: API_SERVER_PORT
8181
value: "8000"
8282
- name: API_SERVER_KEY
@@ -97,7 +97,7 @@ spec:
9797
emptyDir: {}
9898
- name: streamlit-config
9999
configMap:
100-
name: {{ include "oai.fullname" . }}-st-config
100+
name: {{ include "app.fullname" . }}-st-config
101101
{{- with .Values.volumes }}
102102
{{- toYaml . | nindent 8 }}
103103
{{- end }}

helm/charts/oaim-sandbox/templates/ingress.yaml renamed to helm/charts/client/templates/ingress.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
apiVersion: networking.k8s.io/v1
1111
kind: Ingress
1212
metadata:
13-
name: {{ include "oai.fullname" . }}-http
13+
name: {{ include "app.fullname" . }}-http
1414
labels:
15-
{{- include "oai.labels" . | nindent 4 }}
15+
{{- include "app.labels" . | nindent 4 }}
1616
{{- with .Values.ingress.annotations }}
1717
annotations:
1818
{{- toYaml . | nindent 4 }}
@@ -39,11 +39,11 @@ spec:
3939
backend:
4040
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
4141
service:
42-
name: {{ include "oai.fullname" . }}-http
42+
name: {{ include "app.fullname" . }}-http
4343
port:
44-
number: 8501
44+
number: 80
4545
{{- else }}
46-
serviceName: {{ include "oai.fullname" . }}-http
47-
servicePort: 8501
46+
serviceName: {{ include "app.fullname" . }}-http
47+
servicePort: 80
4848
{{- end }}
4949
{{- end }}

0 commit comments

Comments
 (0)