/oci-genai-poc

Primary LanguageJavaScript

OCI Gen AI POC

Architecture

Get troubleshoot help on the FAQ

Set Up environment

Install dependencies for scripts.

cd scripts/ && npm install && cd ..

Set the environment variables

Generate genai.json file with all environment variables.

npx zx scripts/setenv.mjs

Answer the Compartment name where you want to deploy the infrastructure. Root compartment is the default.

Deploy Infrastructure

Generate terraform.tfvars file for Terraform.

npx zx scripts/tfvars.mjs
cd deploy/terraform

Init Terraform providers:

terraform init

Apply deployment:

terraform apply --auto-approve
cd ../..

Release and create Kustomization files

Build and push images:

npx zx scripts/release.mjs

Create Kustomization files

npx zx scripts/kustom.mjs

Kubernetes Deployment

export KUBECONFIG="deploy/terraform/generated/kubeconfig"
kubectl cluster-info
kubectl apply -k deploy/k8s/overlays/prod

Run get deploy a few times:

kubectl get deploy

Wait for all deployments to be Ready and Available.

NAME      READY   UP-TO-DATE   AVAILABLE   AGE
backend   1/1     1            1           3m28s
web       1/1     1            1           3m21s

Access your application:

echo $(kubectl get service \
  -n ingress-nginx \
  -o jsonpath='{.items[?(@.spec.type=="LoadBalancer")].status.loadBalancer.ingress[0].ip}')

This command will list the services on the ingress-nginx namespace and filter for the Load Balancer. If the response is an empty string, wait a bit and execute the command again. The Load Balancer takes a bit of time to create the Public IP address.

Take the Public IP to your browser.

Clean up

Delete Kubernetes components

kubectl delete -k deploy/k8s/overlays/prod

Destroy infrastructure with Terraform.

cd deploy/terraform
terraform destroy -auto-approve
cd ../..

Clean up the artifacts on Object Storage

npx zx scripts/clean.mjs

Local deployment

Run locally with these steps Local

Known Issues

Deploying artifacts as Object Storage.

There is an issue in Terraform oracle/oci provider on version v5.25.0. It is not updated to the specific version of terraform-plugin-sdk that fix the underlying gRCP limit of 4Mb.

The project would want to upload artifacts to Object Storage, like the backend jar file, which is bigger than 4Mb.

data "local_file" "backend_jar_tgz" {
  filename = "${path.module}/../../.artifacts/backend_jar.tar.gz"
}

As a workaround, a script/deliver.mjs script and a script/clean.mjs script will deliver and clean the artifacts into Object Storage and make Pre-Authenticated Requests available for Terraform resources.