duongnh-aidev/ZodSP(opens in a new tab)
Language: Python
Serving Zero-Shot Object Detection Service into Google Kubernetes Engine
- stars
- 6
- watchers
- 1
- forks
- 0
- open issues
- 0
- Last updated
- 02/19/2025
Language: Python
Serving Zero-Shot Object Detection Service into Google Kubernetes Engine
This repo will show you how to deploy your own Zero-shot Object Detection API onto GKE using CI/CD ⭐⭐⭐
gcloud init Y
gcloud -v
gcloud components install gke-gcloud-auth-plugin
Kubernetes Engine Admin role therefore you will have full management of Kubernetes Cluster and their Kubernetes API object for your service account.credentials in terraform/main.tf with your json directory.GRANT ACCESS, then add new principals, this principal is your service account created in step 1.3. Finally, select Owner role.project_id in terraform/variables.tf with your project id on Google Cloud. Then run the following command to create GKE cluster:gcloud auth application-default login
cd terraform
terraform init
terraform plan
terraform applyterraform/variables.tf to your desired setting.enable_autopilot=true in terraform/main.tf as Prometheus service cannot scrape node metrics from Autopilot cluster.alias k=kubectl
k get nodesUsing Helm Chart to deploy the application on GKE. See the installation here.
cd helm/nginx-ingress k create ns nginx-ingress kubens nginx-ingress helm upgrade --install nginx-ingress-controller .
cd helm/app k create ns model-serving kubens model-serving helm upgrade --install app .
k get ing
zod.com (set up in helm/app/templates/nginx-ingress.yaml) of this IP to /etc/hostssudo nano /etc/hosts [YOUR_INGRESS_IP_ADDRESS] zod.com
zod.com/docsUsing Prometheus and Grafana for monitoring both node and containers (pods). Prometheus will scrape the metrics from both node and containers then display by using Grafana UI. Lastly, the system health alerts will be sent to Discord.
monitoringhelm repo add prometheus-community https://prometheus-community.github.io/helm-charts k create ns monitoring kubens monitoring helm install kube-prometheus-stack --namespace monitoring prometheus-community/kube-prometheus-stack
k port-forward -n monitoring svc/kube-prometheus-stack-prometheus 9090:9090
k port-forward -n monitoring svc/kube-prometheus-stack-grafana 8080:80
username: admin password: prom-operator
Jenkins is deployed on Google Compute Engine using Ansible.
NOTE: Make sure you have installed miniforge, you can see the installation here.
Then you can install ansible by running the below command:
conda create -n [your_desired_env_name] python=3.11 conda activate [your_desired_env_name] pip install ansible
Check if ansible is successfully installed
ansible --version
service account, and select Compute Admin role (Full control of all Compute Engine resources) for your service account.secrets directory. Update your project and service_account_file in ansible/deploy_jenkins/create_compute_instance.yaml.cd ansible
ansible-playbook create_compute_instance.yaml
[YOUR DIR]/.ssh/id_rsassh-keygen -t rsa
Then run cat [YOUR DIR]/.ssh/id_rsa.pub and copy the content.
cp example.inventory inventory and replace all value inside the double single quotes in the created inventory file.cd ansible/deploy_jenkins
ansible-playbook -i ../inventory deploy_jenkins.yaml
ssh -i ~/.ssh/id_rsa YOUR_USERNAME@YOUR_EXTERNAL_IPsudo docker ps
sudo docker exec -ti serving_grounding_dino-jenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword
Copy the password and you can access Jenkins UI.
sudo docker restart serving_grounding_dino-jenkins
kubectl create clusterrolebinding model-serving-admin-binding \ --clusterrole=admin \ --serviceaccount=model-serving:default \ --namespace=model-serving kubectl create clusterrolebinding anonymous-admin-binding \ --clusterrole=admin \ --user=system:anonymous \ --namespace=model-serving
python client.py
python client -u [YOUR_API_URL] -p [YOUR_PROMPT] -i [YOUR_IMAGE_PATH]