Skip to content

Commit ab162c3

Browse files
authored
IaC Documentation (#128)
* Microservices Documentation
1 parent bca8032 commit ab162c3

File tree

7 files changed

+138
-96
lines changed

7 files changed

+138
-96
lines changed

docs/content/advanced/microservices.md

Lines changed: 71 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -63,86 +63,61 @@ You will need to build the {{< short_app_ref >}} container images and stage them
6363

6464
### Ingress
6565

66-
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**.
66+
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 [OCI Native Ingress Controller](https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengsettingupnativeingresscontroller.htm), which was enabled on the **OKE** cluster as part of the **IaC**, will be used to for public Ingress access.
6767

68-
This example will create the loadbalancer exposing port 80 for the {{< short_app_ref >}} GUI and port 8000 for the {{< short_app_ref >}} API Server. It is _HIGHLY_ recommended to protect these ports with [Network Security Groups](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/networksecuritygroups.htm) (**NSGs**).
68+
The [Flexible LoadBalancer](https://docs.oracle.com/en-us/iaas/Content/NetworkLoadBalancer/overview.htm) was provisioned using the **IaC**. This example will create the Listeners and Backends to expose port 80 for the {{< short_app_ref >}} GUI and port 8000 for the {{< short_app_ref >}} API Server on the existing LoadBalancer.
6969

70-
The service manifest has two values that should be supplied:
70+
It is _HIGHLY_ recommended to protect these ports with [Network Security Groups](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/networksecuritygroups.htm) (**NSGs**).
7171

72+
The service manifest has five values that should be supplied:
73+
74+
- `<lb_compartment_ocid>` - OCID of the LoadBalancer Compartment
75+
- `<lb_subnet_ocid>` - OCID of the Subnet for the LoadBalancer
76+
- `<lb_ocid>` - OCID of the LoadBalancer provisioned by IaC
7277
- `<lb_nsg_ocid>` - **NSG** OCID's to protect the LB ports
73-
- `<lb_reserved_ip>` - A reserved IP address for the Loadbalancer
78+
- `<lb_reserved_ip_ocid>` - A reserved IP address for the Loadbalancer
7479
7580
These will be output as part of the **IaC** but can be removed from the code if not reserving an IP or protecting the Load Balancer.
7681
77-
1. Create a `ingress.yaml`:
78-
```yaml
79-
controller:
80-
kind: DaemonSet
81-
# Service is configured via its own manifest and is conditional
82-
service:
83-
enabled: false
84-
config:
85-
ssl-redirect: "false" # NGINX isn't using any TLS certificates, terminated at LB
86-
use-forwarded-headers: "true" # NGINX will decide on redirection based on headers
87-
updateStrategy:
88-
rollingUpdate:
89-
maxUnavailable: 1
90-
type: RollingUpdate
91-
```
92-
93-
1. Install the Ingress-Nginx Controller:
94-
```bash
95-
helm upgrade \
96-
--install ingress-nginx ingress-nginx \
97-
--repo https://kubernetes.github.io/ingress-nginx \
98-
--namespace ingress-nginx \
99-
--create-namespace \
100-
-f ingress.yaml
101-
```
102-
103-
1. Create a `service.yaml` file (replace `<...>` values or remove):
82+
1. Create a `native_ingress.yaml`:
10483
```yaml
105-
apiVersion: v1
106-
kind: Service
107-
metadata:
108-
annotations:
109-
oci.oraclecloud.com/load-balancer-type: lb
110-
service.beta.kubernetes.io/oci-load-balancer-shape: flexible
111-
service.beta.kubernetes.io/oci-load-balancer-shape-flex-max: "100"
112-
service.beta.kubernetes.io/oci-load-balancer-shape-flex-min: "10"
113-
oci.oraclecloud.com/oci-network-security-groups: "<lb_nsg_ocid>"
114-
service.beta.kubernetes.io/oci-load-balancer-security-list-management-mode: None
115-
name: ingress-nginx-controller
116-
namespace: ingress-nginx
117-
spec:
118-
allocateLoadBalancerNodePorts: true
119-
externalTrafficPolicy: Cluster
120-
internalTrafficPolicy: Cluster
121-
ipFamilies:
122-
- IPv4
123-
ipFamilyPolicy: SingleStack
124-
loadBalancerIP: "<lb_reserved_ip>"
125-
ports:
126-
- appProtocol: http
127-
name: client
128-
port: 80
129-
protocol: TCP
130-
targetPort: http
131-
- appProtocol: http
132-
name: server
133-
port: 8000
134-
protocol: TCP
135-
targetPort: http
136-
selector:
137-
app.kubernetes.io/component: controller
138-
app.kubernetes.io/instance: ingress-nginx
139-
app.kubernetes.io/name: ingress-nginx
140-
type: LoadBalancer
141-
```
142-
143-
1. Apply the Service:
144-
```bash
145-
kubectl apply -f service.yaml
84+
apiVersion: v1
85+
kind: Namespace
86+
metadata:
87+
name: hologram
88+
---
89+
apiVersion: "ingress.oraclecloud.com/v1beta1"
90+
kind: IngressClassParameters
91+
metadata:
92+
name: native-ic-params
93+
namespace: ai-explorer
94+
spec:
95+
compartmentId: <compartment_ocid>
96+
subnetId: <lb_subnet_ocid>
97+
loadBalancerName: "ai-explorer-lb"
98+
reservedPublicAddressId: <lb_reserved_ip_ocid>
99+
isPrivate: false
100+
maxBandwidthMbps: 1250
101+
minBandwidthMbps: 10
102+
---
103+
apiVersion: networking.k8s.io/v1
104+
kind: IngressClass
105+
metadata:
106+
name: native-ic
107+
namespace: hologram
108+
annotations:
109+
ingressclass.kubernetes.io/is-default-class: "true"
110+
oci-native-ingress.oraclecloud.com/network-security-group-ids: <lb_nsg_ocid>
111+
oci-native-ingress.oraclecloud.com/id: <lb_ocid>
112+
oci-native-ingress.oraclecloud.com/delete-protection-enabled: "true"
113+
spec:
114+
controller: oci.oraclecloud.com/native-ingress-controller
115+
parameters:
116+
scope: Namespace
117+
namespace: hologram
118+
apiGroup: ingress.oraclecloud.com
119+
kind: IngressClassParameters
120+
name: native-ic-params
146121
```
147122
148123
### The {{< short_app_ref >}}
@@ -205,16 +180,23 @@ If you deployed a GPU node pool as part of the **IaC**, you can deploy Ollama an
205180
secretName: "api-key"
206181
207182
# -- API Server configuration
208-
ai-explorer-server:
183+
server:
209184
enabled: true
210185
image:
211186
repository: <server_repository>
212187
tag: "latest"
213188
214189
ingress:
215190
enabled: true
191+
className: native-ic
216192
annotations:
217193
nginx.ingress.kubernetes.io/upstream-vhost: "<lb_reserved_ip>"
194+
oci-native-ingress.oraclecloud.com/http-listener-port: "8000"
195+
oci-native-ingress.oraclecloud.com/protocol: TCP
196+
197+
service:
198+
http:
199+
type: "NodePort"
218200
219201
# -- Oracle Autonomous Database Configuration
220202
adb:
@@ -224,26 +206,32 @@ If you deployed a GPU node pool as part of the **IaC**, you can deploy Ollama an
224206
authN:
225207
secretName: "db-authn"
226208
227-
ai-explorer-client:
209+
client:
228210
enabled: true
229211
image:
230212
repository: <client_repository>
231213
tag: "latest"
232214
233215
ingress:
234216
enabled: true
217+
className: native-ic
235218
annotations:
236219
nginx.ingress.kubernetes.io/upstream-vhost: "<lb_reserved_ip>"
220+
oci-native-ingress.oraclecloud.com/http-listener-port: "80"
221+
oci-native-ingress.oraclecloud.com/protocol: TCP
237222
238-
client:
239-
features:
240-
disableTestbed: "false"
241-
disableApi: "false"
242-
disableTools: "false"
243-
disableDbCfg: "true"
244-
disableModelCfg: "false"
245-
disableOciCfg: "true"
246-
disableSettings: "true"
223+
service:
224+
http:
225+
type: "NodePort"
226+
227+
features:
228+
disableTestbed: "false"
229+
disableApi: "false"
230+
disableTools: "false"
231+
disableDbCfg: "true"
232+
disableModelCfg: "false"
233+
disableOciCfg: "true"
234+
disableSettings: "true"
247235
248236
ollama:
249237
enabled: true

helm/charts/client/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ spec:
6969
{{- toYaml .Values.resources | nindent 12 }}
7070
{{- end }}
7171
env:
72-
{{- range $key, $value := .Values.client.features }}
72+
{{- range $key, $value := .Values.features }}
7373
{{- if ne $value "false" }}
7474
- name: {{ snakecase $key | upper }}
7575
value: {{ $value | quote }}

helm/charts/server/templates/deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ spec:
136136
- name: ON_PREM_HF_URL
137137
value: {{ .models.huggingface.urlPort }}
138138
{{- end }}
139-
{{- end }}
140-
{{- end }}
139+
{{- if and .models.ollama .models.ollama.enabled }}
141140
- name: ON_PREM_OLLAMA_URL
142141
value: {{ include "ollama.serviceUrl" . }}
142+
{{- end }}
143+
{{- end }}
144+
{{- end }}
143145
volumeMounts:
144146
- name: tmp
145147
mountPath: "/app/tmp"

helm/charts/server/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ adb:
6060

6161
# -- Model Configuration
6262
models:
63+
ollama:
64+
enabled: false
6365
openAI:
6466
secretName: ""
6567
secretKey: ""

opentofu/kubernetes.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323

2424
k8s_manifest = templatefile("templates/k8s_manifest.yaml", {
2525
label = local.label_prefix
26-
compartment_ocid = local.compartment_ocid
26+
compartment_ocid = oci_load_balancer.service_lb[0].compartment_id
2727
lb_ocid = oci_load_balancer.service_lb[0].id
2828
lb_subnet_ocid = module.network.public_subnet_ocid
2929
lb_ip_ocid = oci_core_public_ip.service_lb[0].id

opentofu/output.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,51 @@ output "kubeconfig_cmd" {
2020
var.region,
2121
oci_containerengine_cluster.default_cluster.endpoint_config[0].is_public_ip_enabled ? "PUBLIC_ENDPOINT" : "PRIVATE_ENDPOINT"
2222
)
23+
}
24+
25+
// For Microservices Documentation
26+
output "lb_compartment_ocid" {
27+
description = "LoadBalancer Compartment OCID"
28+
value = oci_load_balancer.service_lb[0].compartment_id
29+
}
30+
31+
output "lb_subnet_ocid" {
32+
description = "LoadBalancer Subnet OCID"
33+
value = module.network.public_subnet_ocid
34+
}
35+
36+
output "lb_ocid" {
37+
description = "LoadBalancer OCID"
38+
value = oci_load_balancer.service_lb[0].id
39+
}
40+
41+
output "lb_nsg_ocid" {
42+
description = "LoadBalancer NSG OCID(s)"
43+
value = format("%s, %s", oci_core_network_security_group.service_lb_app_client[0].id, oci_core_network_security_group.service_lb_app_server[0].id)
44+
}
45+
46+
output "lb_reserved_ip_ocid" {
47+
description = "LoadBalancer IP OCID(s)"
48+
value = oci_core_public_ip.service_lb[0].id
49+
}
50+
51+
output "lb_reserved_ip" {
52+
description = "LoadBalancer IP"
53+
value = oci_core_public_ip.service_lb[0].ip_address
54+
}
55+
56+
output "adb_ocid" {
57+
description = "ADB OCID"
58+
value = oci_database_autonomous_database.default_adb.id
59+
}
60+
61+
output "adb_service" {
62+
description = "ADB ServiceName"
63+
value = format("%s_TP", oci_database_autonomous_database.default_adb.db_name)
64+
}
65+
66+
output "adb_password" {
67+
description = "ADB ADMIN Password"
68+
value = oci_database_autonomous_database.default_adb.admin_password
69+
sensitive = true
2370
}

opentofu/templates/helm_values.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ server:
4141
passwordKey: "password"
4242
serviceKey: "service"
4343

44+
models:
45+
ollama:
46+
enabled: ${k8s_node_pool_gpu_deploy}
47+
4448
client:
4549
enabled: true
4650
image:
@@ -60,15 +64,14 @@ client:
6064
http:
6165
type: "NodePort"
6266

63-
sandbox:
64-
features:
65-
disableTestbed: "true"
66-
disableApi: "false"
67-
disableTools: "false"
68-
disableDbCfg: "true"
69-
disableModelCfg: "true"
70-
disableOciCfg: "true"
71-
disableSettings: "true"
67+
features:
68+
disableTestbed: "true"
69+
disableApi: "false"
70+
disableTools: "false"
71+
disableDbCfg: "true"
72+
disableModelCfg: "true"
73+
disableOciCfg: "true"
74+
disableSettings: "true"
7275

7376
ollama:
7477
enabled: ${k8s_node_pool_gpu_deploy}

0 commit comments

Comments
 (0)