Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy the API Using Kubernetes #16

Open
prasadhonrao opened this issue Sep 14, 2024 · 0 comments
Open

Deploy the API Using Kubernetes #16

prasadhonrao opened this issue Sep 14, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@prasadhonrao
Copy link
Owner

Description:
We need to deploy the DevCamper API to a Kubernetes cluster for improved scalability, management, and deployment automation. This will ensure that the API can run reliably across multiple environments with flexible scaling options.

Task:

  1. Create a Kubernetes Deployment for the API:

    • Write a deployment.yaml file for deploying the API.
    • Configure the deployment to:
      • Pull the API Docker image from a container registry (e.g., Docker Hub, GCR).
      • Set up the number of replicas (for scaling purposes).
      • Define environment variables using Kubernetes secrets and config maps.
      • Use liveness and readiness probes to ensure the application is running and ready to handle traffic.
    • Set up resource requests and limits (CPU, memory) for the API pods.
  2. Create a Kubernetes Service for the API:

    • Write a service.yaml file to expose the API internally within the cluster.
    • Configure the service type as ClusterIP (for internal access) or LoadBalancer (for external access, depending on the infrastructure).
    • Ensure that the service forwards traffic to the correct API pods.
  3. Set up Kubernetes Secrets and Config Maps:

    • Create a secrets.yaml file for securely storing sensitive information (e.g., JWT_SECRET, SMTP_PASSWORD).
    • Create a configmap.yaml file for storing non-sensitive configuration (e.g., API configuration, environment settings like NODE_ENV, PORT, etc.).
  4. Set up Ingress (Optional):

    • If required, configure an ingress.yaml file to expose the API externally, routing traffic based on domain names or paths.
    • Optionally configure SSL/TLS certificates using Kubernetes Ingress and Cert-Manager.
  5. Deploy MongoDB (Optional):

    • If MongoDB is not provided externally, create a Kubernetes deployment and service for MongoDB.
    • Use Persistent Volume Claims (PVC) to ensure data persistence for MongoDB across pod restarts.
  6. Create a Kubernetes Namespace:

    • Set up a dedicated namespace for the API (e.g., devcamper-api) to organize and manage resources more efficiently.
  7. Set Up Auto-Scaling (Optional):

    • Configure a Horizontal Pod Autoscaler (HPA) to scale the API based on CPU or memory utilization.
    • Define thresholds to automatically add or remove pods based on traffic load.
  8. Testing:

    • Test the deployment locally using a local Kubernetes cluster (e.g., Minikube or Docker Desktop).
    • Ensure that the API works as expected in the cluster environment.
    • Test the readiness and liveness probes, scaling, and failover mechanisms.
  9. Document Kubernetes Setup:

    • Update or create a section in README.md or SETUP.md to include instructions on:
      • Deploying the API to a Kubernetes cluster.
      • Managing secrets and config maps.
      • Testing and scaling the API in Kubernetes.

Acceptance Criteria:

  • A complete set of Kubernetes configuration files (deployment.yaml, service.yaml, secrets.yaml, configmap.yaml, and optionally ingress.yaml, hpa.yaml).
  • The API is successfully deployed to a Kubernetes cluster with multiple replicas, and exposed via a service or ingress.
  • Environment variables and secrets are securely managed using Kubernetes Secrets and ConfigMaps.
  • Documentation is provided for deploying and managing the API using Kubernetes.
  • The API is tested in the cluster environment, with proper scaling and reliability measures.

References:

@prasadhonrao prasadhonrao added the enhancement New feature or request label Sep 14, 2024
@prasadhonrao prasadhonrao added this to the v2 milestone Sep 14, 2024
@prasadhonrao prasadhonrao self-assigned this Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant