-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dea059
commit 7a33857
Showing
6 changed files
with
234 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,241 @@ | ||
## Deploy a Kubernetes cluster in Local | ||
# Kubernetes Development | ||
|
||
1. Start cluster use minikube and docker | ||
## Table of Contents | ||
|
||
1. [Architecture](#architecture) | ||
2. [Development Environment Setup](#development-environment-setup) | ||
3. [Production Environment Setup](#production-environment-setup) | ||
4. [Kubernetes Cluster Deployment](#kubernetes-cluster-deployment) | ||
- [Deploy Ingress Nginx](#deploy-ingress-nginx) | ||
- [Installation](#installation) | ||
- [Configuration](#configuration) | ||
- [Verification](#verification) | ||
- [Uninstallation](#uninstallation) | ||
- [Deploy Postgres](#deploy-postgres) | ||
- [Local Installation](#local-installation) | ||
- [EKS Installation](#eks-installation) | ||
- [Local Uninstallation](#local-uninstallation) | ||
- [EKS Uninstallation](#eks-uninstallation) | ||
- [Deploy Backend](#deploy-backend) | ||
- [Deploy Frontend](#deploy-frontend) | ||
- [Deploy Qdrant](#deploy-qdrant) | ||
- [Deploy Image Search](#deploy-image-search) | ||
- [Deploy Text Search](#deploy-text-search) | ||
5. [References](#references) | ||
|
||
## Architecture | ||
|
||
<p align="center"> | ||
<img src="./../assets/kubernetes-architecture.png" alt="Kubernetes Architecture Diagram" /> | ||
<br> | ||
<em>Fig: Kubernetes Architecture</em> | ||
</p> | ||
|
||
## Development Environment Setup | ||
|
||
This section covers the steps to set up a Kubernetes development environment. | ||
|
||
### Start Kubernetes with Docker Desktop | ||
|
||
Initiate Kubernetes within Docker Desktop for local development. | ||
|
||
### Show Node Status | ||
|
||
Check the status of Kubernetes nodes. | ||
|
||
``` | ||
kubectl get nodes | ||
``` | ||
|
||
### Build and Push Docker Images | ||
|
||
Commands to build Docker images and push them to Docker Hub. | ||
|
||
``` | ||
docker compose build | ||
docker compose push | ||
``` | ||
|
||
## Production Environment Setup | ||
|
||
Guidelines for setting up a Kubernetes environment suitable for production. | ||
|
||
### Create and Manage Cluster and NodeGroup | ||
|
||
- **Creating a Cluster and Node Group** | ||
``` | ||
eksctl create cluster -f cluster-config-eksctl.yaml | ||
``` | ||
- **Deleting a Cluster and Node Group** | ||
``` | ||
eksctl delete cluster -f cluster-config-eksctl.yaml --disable-nodegroup-eviction | ||
``` | ||
|
||
### Node Status Verification | ||
|
||
Same as in the development environment setup. | ||
|
||
### Install aws-ebs-csi-driver | ||
|
||
``` | ||
kubectl apply -k "github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/?ref=release-1.25" | ||
``` | ||
|
||
Instructions to install the AWS EBS CSI driver in the production environment. | ||
|
||
## Kubernetes Cluster Deployment | ||
|
||
### Deploy Ingress Nginx | ||
|
||
#### Installation | ||
|
||
1. **Install Ingress Nginx Controller** | ||
``` | ||
helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx | ||
``` | ||
minikube start --driver=docker | ||
This command installs the Ingress Nginx controller using Helm. | ||
|
||
#### Configuration | ||
|
||
1. **Configure Ingress Nginx Service** | ||
``` | ||
2. Show node ready | ||
kubectl apply -f ingress-nginx-service.yaml | ||
``` | ||
kubectl get nodes | ||
Apply the configuration defined in `ingress-nginx-service.yaml`. | ||
|
||
#### Verification | ||
|
||
1. **Check Ingress Nginx** | ||
``` | ||
3. Build and push image to docker hub | ||
kubectl get ingress | ||
``` | ||
docker compose build | ||
docker compose push | ||
Verify the ingress setup by listing all ingress resources. | ||
|
||
#### Uninstallation | ||
|
||
1. **Remove Ingress Nginx** | ||
``` | ||
4. Install Qdrant Helm Chart | ||
helm uninstall ingress-nginx | ||
kubectl delete -f ingress-nginx-service.yaml | ||
``` | ||
Uninstall the Ingress Nginx controller and delete its service configuration. | ||
|
||
- Add repo | ||
``` | ||
helm repo add qdrant https://qdrant.github.io/qdrant-helm | ||
``` | ||
- Update repo | ||
``` | ||
helm repo update | ||
``` | ||
- Install repo | ||
``` | ||
helm upgrade -i qdrant-db qdrant/qdrant | ||
``` | ||
- Check repo | ||
``` | ||
helm list | ||
``` | ||
### Deploy Postgres | ||
|
||
5. Deploy kubenetes template | ||
#### Local Installation | ||
|
||
1. **Apply Postgres Configuration for Local** | ||
``` | ||
kubectl apply -f image-search-deployment.yaml,image-search-service.yaml | ||
kubectl apply -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml | ||
``` | ||
Set `storageClassName: standard` in `postgres-pvc.yaml` for local deployment. | ||
|
||
#### EKS Installation | ||
|
||
1. **Apply Postgres Configuration for EKS** | ||
``` | ||
kubectl apply -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml | ||
``` | ||
Set `storageClassName: gp3` in `postgres-pvc.yaml` for EKS deployment. | ||
|
||
#### Local Uninstallation | ||
|
||
1. **Remove Postgres in Local** | ||
``` | ||
kubectl delete -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml | ||
``` | ||
|
||
#### EKS Uninstallation | ||
|
||
1. **Remove Postgres in EKS** | ||
``` | ||
kubectl delete -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml | ||
``` | ||
|
||
**1. Deploy backend** | ||
### Deploy Backend | ||
|
||
1. **Install Backend Service** | ||
|
||
``` | ||
kubectl apply -f backend-deployment.yaml,backend-service.yaml | ||
``` | ||
|
||
Deploy the backend service using the specified Kubernetes configurations. | ||
|
||
2. **Uninstall Backend Service** | ||
``` | ||
kubectl delete -f backend-deployment.yaml,backend-service.yaml | ||
``` | ||
Remove the backend service from the cluster. | ||
|
||
### Deploy Frontend | ||
|
||
1. **Set Up Environment Variables** | ||
|
||
- For local deployment: `NEXT_PUBLIC_API_URL=http://localhost/api` | ||
- For production: Retrieve the IP address of the load balancer from `kubectl get ingress` and set `NEXT_PUBLIC_API_URL=http://{ip-address-loadbalancer}/api`. | ||
|
||
**2. Deploy Ingress Nginx** | ||
2. **Deploy Frontend Service** | ||
|
||
``` | ||
helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace | ||
kubectl --namespace ingress-nginx get services -o wide -w ingress-nginx-controller | ||
helm uninstall ingress-nginx --namespace ingress-nginx | ||
kubectl apply -f ingress-nginx-service.yaml | ||
kubectl delete -f ingress-nginx-service.yaml | ||
kubectl get ingress | ||
kubectl apply -f frontend-deployment.yaml,frontend-service.yaml | ||
``` | ||
|
||
**3. Deploy Postgres** | ||
Apply the frontend deployment and service configurations. | ||
|
||
3. **Uninstall Frontend Service** | ||
``` | ||
kubectl apply -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml | ||
kubectl delete -f postgres-deployment.yaml,postgres-service.yaml,postgres-pvc.yaml,postgres-pv.yaml | ||
kubectl delete -f frontend-deployment.yaml,frontend-service.yaml | ||
``` | ||
|
||
**3. Deploy Qdrant** | ||
### Deploy Qdrant | ||
|
||
1. **Install Qdrant Database** | ||
|
||
``` | ||
helm upgrade --install qdrant-db qdrant --repo https://qdrant.github.io/qdrant-helm | ||
``` | ||
|
||
**4. Deploy Image Search** | ||
Install Qdrant using the Helm chart. | ||
|
||
2. **Uninstall Qdrant Database** | ||
``` | ||
kubectl apply -f image-search-deployment.yaml,image-search-service.yaml | ||
kubectl delete -f image-search-deployment.yaml,image-search-service.yaml | ||
helm uninstall qdrant-db | ||
kubectl delete pvc -l app.kubernetes.io/instance=qdrant-db | ||
``` | ||
|
||
6. Show dashboard | ||
### Deploy Image Search | ||
|
||
1. **Install Image Search Service** | ||
|
||
``` | ||
minikube dashboard | ||
kubectl apply -f image-search-deployment.yaml,image-search-service.yaml | ||
``` | ||
7. Get service | ||
|
||
2. **Uninstall Image Search Service** | ||
``` | ||
minikube service image-search-service | ||
kubectl delete -f image-search-deployment.yaml,image-search-service.yaml | ||
``` | ||
8. Destroy kubenetes template | ||
- Delete app | ||
``` | ||
kubectl delete -f image-search-deployment.yaml,image-search-service.yaml | ||
``` | ||
- Uninstall repo | ||
``` | ||
helm uninstall qdrant-db | ||
``` | ||
- Delete the qdrant volume | ||
``` | ||
kubectl delete pvc -l app.kubernetes.io/instance=qdrant-db | ||
``` | ||
- Delete cluster | ||
``` | ||
minikube delete | ||
``` | ||
|
||
## Production enviroments | ||
### Deploy Text Search | ||
|
||
**1. Create Cluster and NodeGroup** | ||
1. **Install Text Search Service** | ||
|
||
``` | ||
eksctl create cluster -f cluster-config-eksctl.yaml | ||
eksctl upgrade cluster -f cluster-config-eksctl.yaml | ||
eksctl delete cluster -f cluster-config-eksctl.yaml | ||
``` | ||
``` | ||
kubectl apply -f text-search-deployment.yaml,text-search-service.yaml | ||
``` | ||
|
||
2. **Uninstall Text Search Service** | ||
``` | ||
kubectl delete -f text-search-deployment.yaml,text-search-service.yaml | ||
``` | ||
|
||
## References | ||
|
||
### Refrence | ||
Useful links for additional information and external resources. | ||
|
||
- https://github.com/qdrant/qdrant-helm/tree/main/charts/qdrant | ||
- https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-helm-chart.html | ||
- https://github.com/elastic/cloud-on-k8s/tree/main/deploy/eck-stack | ||
- [EKSCTL Getting Started](https://eksctl.io/getting-started/) | ||
- [AWS EBS CSI Driver Installation Guide](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/install.md) | ||
- [Qdrant Helm Charts](https://github.com/qdrant/qdrant-helm/tree/main/charts/qdrant) | ||
- [Elastic Cloud on Kubernetes Documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-helm-chart.html) | ||
- [Elastic Cloud Kubernetes Deployment](https://github.com/elastic/cloud-on-k8s/tree/main/deploy/eck-stack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters