diff --git a/GitOps/Jenkinsfile b/Argo-cd/Jenkinsfile similarity index 85% rename from GitOps/Jenkinsfile rename to Argo-cd/Jenkinsfile index cf62d0e76..6b4358329 100644 --- a/GitOps/Jenkinsfile +++ b/Argo-cd/Jenkinsfile @@ -1,6 +1,6 @@ @Library('Shared') _ pipeline { - agent {label 'Node'} + agent any parameters { string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Frontend Docker tag of the image built by the CI job') @@ -19,7 +19,7 @@ pipeline { stage('Git: Code Checkout') { steps { script{ - code_checkout("https://github.com/DevMadhup/Wanderlust-Mega-Project.git","main") + code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master") } } } @@ -39,13 +39,13 @@ pipeline { script{ dir('kubernetes'){ sh """ - sed -i -e s/wanderlust-backend-beta.*/wanderlust-backend-beta:${params.BACKEND_DOCKER_TAG}/g backend.yaml + sed -i -e s/wanderlust-backend.*/wanderlust-backend:${params.BACKEND_DOCKER_TAG}/g backend.yaml """ } dir('kubernetes'){ sh """ - sed -i -e s/wanderlust-frontend-beta.*/wanderlust-frontend-beta:${params.FRONTEND_DOCKER_TAG}/g frontend.yaml + sed -i -e s/wanderlust-frontend.*/wanderlust-frontend:${params.FRONTEND_DOCKER_TAG}/g frontend.yaml """ } @@ -56,7 +56,7 @@ pipeline { stage("Git: Code update and push to GitHub"){ steps{ script{ - withCredentials([gitUsernamePassword(credentialsId: 'Github-cred', gitToolName: 'Default')]) { + withCredentials([gitUsernamePassword(credentialsId: 'GitHub', gitToolName: 'Default')]) { sh ''' echo "Checking repository status: " git status @@ -68,7 +68,7 @@ pipeline { git commit -m "Updated environment variables" echo "Pushing changes to github: " - git push https://github.com/DevMadhup/Wanderlust-Mega-Project.git main + git push https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git master ''' } } @@ -101,4 +101,4 @@ pipeline { } } } -} +} \ No newline at end of file diff --git a/Automations/updatebackendnew.sh b/Automations/updatebackendnew.sh index 6a8645c20..40601f396 100755 --- a/Automations/updatebackendnew.sh +++ b/Automations/updatebackendnew.sh @@ -1,10 +1,10 @@ #!/bin/bash # Set the Instance ID and path to the .env file -INSTANCE_ID="i-0ee177c8f3cdd7103" +INSTANCE_ID="i-0175d7325693884e7" # Retrieve the public IP address of the specified EC2 instance -ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text) +ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region us-west-1 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text) # Initializing variables file_to_find="../backend/.env.docker" @@ -18,7 +18,7 @@ NC='\033[0m' echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}" -if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:5173\"" ]] +if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:31000\"" ]] then echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}" else @@ -27,9 +27,9 @@ else echo -e "${GREEN}${file_to_find}${NC} found.." echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}" sleep 7s; - sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:5173\"|g" ${file_to_find} + sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:31000\"|g" ${file_to_find} echo -e "${GREEN}env variables configured..${NC}" else echo -e "${RED}ERROR : File not found..${NC}" fi -fi +fi \ No newline at end of file diff --git a/Automations/updatefrontendnew.sh b/Automations/updatefrontendnew.sh index f5df52e2c..1696f97b2 100755 --- a/Automations/updatefrontendnew.sh +++ b/Automations/updatefrontendnew.sh @@ -1,10 +1,10 @@ #!/bin/bash # Set the Instance ID and path to the .env file -INSTANCE_ID="i-0ee177c8f3cdd7103" +INSTANCE_ID="i-0bcf7ebe5af5670f3" # Retrieve the public IP address of the specified EC2 instance -ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text) +ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region us-west-1 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text) # Initializing variables file_to_find="../frontend/.env.docker" @@ -30,4 +30,4 @@ else else echo -e "${RED}ERROR : File not found..${NC}" fi -fi +fi \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index b05f81fe8..971b307d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,9 @@ -@Library('Shared') _ +@Library('shared') _ pipeline { - agent {label 'Node'} + agent any environment{ - SONAR_HOME = tool "Sonar" - } - - parameters { - string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Setting docker image for latest push') - string(name: 'BACKEND_DOCKER_TAG', defaultValue: '', description: 'Setting docker image for latest push') + SONAR_HOME = tool "Sonarqube" } stages { @@ -18,49 +13,47 @@ pipeline { script{ cleanWs() } + sh "docker system prune -a -f" } } stage('Git: Code Checkout') { steps { script{ - code_checkout("https://github.com/DevMadhup/Wanderlust-Mega-Project.git","main") + code_clone("https://github.com/Mr-Dusara/Wanderlust-Mega-Project.git","master") } } } - stage("Trivy: Filesystem scan"){ - steps{ - script{ - trivy_scan() - } - } - } - - stage("OWASP: Dependency check"){ - steps{ - script{ - owasp_dependency() - } - } - } + stage("Trivy: Filesystem scan"){ + steps{ + script{ + trivy_scan() + } + } + } + // stage("OWASP: Dependency check"){ + // steps{ + // script{ + // owasp_dependency() + // } + // } + // } stage("SonarQube: Code Analysis"){ steps{ script{ - sonarqube_analysis("Sonar","wanderlust","wanderlust") + sonar_analysis("Sonar","wanderlust","wanderlust") } } } - - stage("SonarQube: Code Quality Gates"){ + stage("SonarQube: Code Quality Gates"){ steps{ script{ - sonarqube_code_quality() + code_quality() } } } - stage('Exporting environment variables') { parallel{ stage("Backend env setup"){ @@ -84,37 +77,35 @@ pipeline { } } } - - stage("Docker: Build Images"){ + stage("Docker: Build Images"){ steps{ script{ dir('backend'){ - docker_build("wanderlust-backend-beta","${params.BACKEND_DOCKER_TAG}","madhupdevops") + image_build("wanderlust-backend","$BUILD_NUMBER","dooms002") } dir('frontend'){ - docker_build("wanderlust-frontend-beta","${params.FRONTEND_DOCKER_TAG}","madhupdevops") - } + image_build("wanderlust-frontend","$BUILD_NUMBER","dooms002") + } } } } - stage("Docker: Push to DockerHub"){ steps{ script{ - docker_push("wanderlust-backend-beta","${params.BACKEND_DOCKER_TAG}","madhupdevops") - docker_push("wanderlust-frontend-beta","${params.FRONTEND_DOCKER_TAG}","madhupdevops") + docker_push("wanderlust-backend","$BUILD_NUMBER","dooms002") + docker_push("wanderlust-frontend","$BUILD_NUMBER","dooms002") } } } } - post{ - success{ - archiveArtifacts artifacts: '*.xml', followSymlinks: false - build job: "Wanderlust-CD", parameters: [ - string(name: 'FRONTEND_DOCKER_TAG', value: "${params.FRONTEND_DOCKER_TAG}"), - string(name: 'BACKEND_DOCKER_TAG', value: "${params.BACKEND_DOCKER_TAG}") - ] - } - } -} + // post{ + // success{ + // archiveArtifacts artifacts: '*.xml', followSymlinks: false + // // build job: "Wanderlust-CD", parameters: [ + // // string(name: 'FRONTEND_DOCKER_TAG', value: "$BUILD_NUMBER"), + // // string(name: 'BACKEND_DOCKER_TAG', value: "$BUILD_NUMBER") + // // ] + // } + // } + } \ No newline at end of file diff --git a/backend/.env.docker b/backend/.env.docker index 7c60b83da..4c1f16cde 100644 --- a/backend/.env.docker +++ b/backend/.env.docker @@ -1,10 +1,10 @@ -MONGODB_URI="mongodb://mongo-service/wanderlust" +MONGODB_URI="mongodb://mongo-service:27017/wanderlust" REDIS_URL="redis://redis-service:6379" PORT=8080 -FRONTEND_URL="http://34.213.249.66:5173" +FRONTEND_URL="http://34.213.249.66:31000" ACCESS_COOKIE_MAXAGE=120000 ACCESS_TOKEN_EXPIRES_IN='120s' REFRESH_COOKIE_MAXAGE=120000 REFRESH_TOKEN_EXPIRES_IN='120s' JWT_SECRET=70dd8b38486eee723ce2505f6db06f1ee503fde5eb06fc04687191a0ed665f3f98776902d2c89f6b993b1c579a87fedaf584c693a106f7cbf16e8b4e67e9d6df -NODE_ENV=Development +NODE_ENV=Development \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index 1776484b4..15e8f98aa 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -28,4 +28,4 @@ COPY .env.docker .env EXPOSE 8080 # App -CMD ["npm", "start"] +CMD ["npm", "start"] \ No newline at end of file diff --git a/database/Dockerfile b/database/Dockerfile deleted file mode 100644 index 0246714a9..000000000 --- a/database/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM mongo - -WORKDIR mongo - -COPY . . - -ENTRYPOINT ["mongod"] diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 50b6e9709..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,39 +0,0 @@ -version: "3.8" -services: - mongodb: - container_name: mongo - image: mongo:latest - volumes: - - ./backend/data:/data - ports: - - "27017:27017" - - backend: - container_name: backend - build: ./backend - env_file: - - ./backend/.env.docker - ports: - - "5000:5000" - depends_on: - - mongodb - - frontend: - container_name: frontend - build: ./frontend - env_file: - - ./frontend/.env.docker - ports: - - "5173:5173" - - redis: - container_name: redis - restart: unless-stopped - image: redis:7.0.5-alpine - expose: - - 6379 - depends_on: - - mongodb - -volumes: - data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index c512f46a2..fdf781021 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,32 +1,58 @@ -# ------------------- Stage 1: Build Stage ------------------------------ -FROM node:21 AS frontend-builder +# # ------------------- Stage 1: Build Stage ------------------------------ +# FROM node:21 AS frontend-builder + +# # Set the working directory to /app +# WORKDIR /app + +# # Copy the package.json and package-lock.json for dependency installation +# COPY package*.json ./ + +# # Install dependencies +# RUN npm install + +# # Copy the rest of the application code +# COPY . . + +# # ------------------- Stage 2: Final Stage ------------------------------ +# FROM node:21-slim + +# # Set the working directory to /app +# WORKDIR /app + +# # Copy built assets and dependencies from frontend-builder stage +# COPY --from=frontend-builder /app . + +# # Copy the .env.sample file to .env.local +# COPY .env.docker .env.local + +# # Expose port 5173 for the Node.js application +# EXPOSE 5173 + +# # Define the default command to run the application in development mode +# CMD ["npm", "run", "dev", "--", "--host"] + +#--------------------------------------------------------------------------------------- + +# -------- Stage 1: Build -------- +FROM node:21-slim AS builder -# Set the working directory to /app WORKDIR /app -# Copy the package.json and package-lock.json for dependency installation COPY package*.json ./ -# Install dependencies RUN npm install -# Copy the rest of the application code COPY . . -# ------------------- Stage 2: Final Stage ------------------------------ -FROM node:21-slim +RUN cp .env.docker .env -# Set the working directory to /app -WORKDIR /app +RUN npm run build # 🔥 IMPORTANT -# Copy built assets and dependencies from frontend-builder stage -COPY --from=frontend-builder /app . +# -------- Stage 2: Serve -------- +FROM nginx:alpine -# Copy the .env.sample file to .env.local -COPY .env.docker .env.local +COPY --from=builder /app/dist /usr/share/nginx/html -# Expose port 5173 for the Node.js application -EXPOSE 5173 +EXPOSE 80 -# Define the default command to run the application in development mode -CMD ["npm", "run", "dev", "--", "--host"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/kubernetes/README.md b/kubernetes/README.md deleted file mode 100644 index 414b5c24d..000000000 --- a/kubernetes/README.md +++ /dev/null @@ -1,192 +0,0 @@ -# Wanderlust Deployment on Kubernetes - -### In this project, we will learn about how to deploy wanderlust application on Kubernetes. - -### Pre-requisites to implement this project: -- Create 2 AWS EC2 instance (Ubuntu) with instance type t2.medium and root volume 29GB. -- Setup Kubeadm - -# -## Steps for Kubernetes deployment: - -1) Become root user : -```bash -sudo su -``` - -# -2) Clone code from remote repository (GitHub) : -```bash -git clone -b devops https://github.com/DevMadhup/wanderlust.git -``` - -# -3) Verify nodes are in ready state or not : -```bash -kubectl get nodes -``` -![Alt text](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/nodes.png) - -# -4) Create kubernetes namespace : -```bash -kubectl create namespace wanderlust -``` -![Namespace](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/namespace%20create.png) - -# -5) Update kubernetes config context : -```bash -kubectl config set-context --current --namespace wanderlust -``` -![Update context](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/context%20wanderlust.png) - -# -6) Enable DNS resolution on kubernetes cluster : - -- Check coredns pod in kube-system namespace and you will find Both coredns pods are running on master node - -```bash -kubectl get pods -n kube-system -o wide | grep -i core -``` -![Alt text](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/get-coredns.png) - -- Above step will run coredns pod on worker node as well for DNS resolution - -```bash -kubectl edit deploy coredns -n kube-system -o yaml -``` - Make replica count from 2 to 4 - -![replica 4](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/edit-coredns.png) - -# -7) Navigate to frontend directory : -```bash -cd frontend -``` - -# -8) Edit .env.docker file and change the public IP Address with your worker node public IP : -```bash -vi .env.docker -``` -![IP](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/frontend.env.docker.png) - -# -9) Build frontend docker image : -```bash -docker build -t madhupdevops/frontend-wanderlust:v2.1.8 . -``` -![Dockerfile frontend](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/docker%20frontend%20build.png) - -# -10) Navigate to backend directory : -```bash -cd ../backend/ -``` - -# -11) Open .env.docker file and edit below variables : - - - MONGODB_URI: \ - - REDIS_URL: \ - - FRONTEND_URL: \ - -> Note: To get service names, check mongodb.yaml, redis.yaml - -![Backend env file](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/backend.env.docker.png) - -# -12) Build backend docker image : -```bash -docker build -t madhupdevops/backend-wanderlust:v2.1.8 . -``` -![Backend dockerfile](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/docker%20backend%20build.png) - -# -13) Check docker images: -```bash -docker images -``` -![docker images](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/docker%20images.png) - -# -14) Login to DockerHub and push image to DockerHub -```bash -docker login -``` -![docker login](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/docker%20login.png) - -```bash -docker push madhupdevops/frontend-wanderlust:v2.1.8 -docker push madhupdevops/backend-wanderlust:v2.1.8 -``` - -# -15) Once, Image is pushed to DockerHub, navigate to kubernetes directory -```bash -cd ../kubernetes -``` - -# -16) Apply manifests file the below order: - - - Create persistent volume : - ```bash - kubectl apply -f persistentVolume.yaml - ``` - ![Peristent volume](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/pv.png) - - - Create persistent volume Claim : - ```bash - kubectl apply -f persistentVolumeClaim.yaml - ``` - ![Peristent volume Claim](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/pvc.png) - - - Create MongoDB deployment and service : - ```bash - kubectl apply -f mongodb.yaml - ``` - ![MongoDb](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/mongo.png) - - - Create Redis deployment and service : - > Note: Wait for 3-4 mins to get mongodb, redis pods and service should be up, otherwise backend-service will not connect. - ```bash - kubectl apply -f redis.yaml - ``` - ![Redis](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/redis.png) - - - Create Backend deployment and service : - ```bash - kubectl apply -f backend.yaml - ``` - ![Backend](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/backend.png) - - - Create Frontend deployment and service : - ```bash - kubectl apply -f frontend.yaml - ``` - ![Frontend](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/frontend.png) - -# -17) Check all deployments and services : -```bash -kubectl get all -``` -![all deployments and services](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/all-deps.png) - -18) Check logs for all the pods : -> Note: This is mandatory to ensure all pods and services are connected or not, if not then recreate deployments -```bash -kubectl logs -``` - -20) Navigate to chrome and access your application at 31000 port : -```bash -http://:31000/ -``` -![App](https://github.com/DevMadhup/wanderlust/blob/devops/kubernetes/assets/app.png) - -# - diff --git a/kubernetes/assets/README.md b/kubernetes/assets/README.md deleted file mode 100644 index 8b1378917..000000000 --- a/kubernetes/assets/README.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/kubernetes/assets/all-deps.png b/kubernetes/assets/all-deps.png deleted file mode 100644 index 29940eaff..000000000 Binary files a/kubernetes/assets/all-deps.png and /dev/null differ diff --git a/kubernetes/assets/app.png b/kubernetes/assets/app.png deleted file mode 100644 index fe7b2890b..000000000 Binary files a/kubernetes/assets/app.png and /dev/null differ diff --git a/kubernetes/assets/backend.env.docker.png b/kubernetes/assets/backend.env.docker.png deleted file mode 100644 index fbb051feb..000000000 Binary files a/kubernetes/assets/backend.env.docker.png and /dev/null differ diff --git a/kubernetes/assets/backend.png b/kubernetes/assets/backend.png deleted file mode 100644 index 37d30fdf8..000000000 Binary files a/kubernetes/assets/backend.png and /dev/null differ diff --git a/kubernetes/assets/context wanderlust.png b/kubernetes/assets/context wanderlust.png deleted file mode 100644 index 89a4a024d..000000000 Binary files a/kubernetes/assets/context wanderlust.png and /dev/null differ diff --git a/kubernetes/assets/docker backend build.png b/kubernetes/assets/docker backend build.png deleted file mode 100644 index b940d4ebb..000000000 Binary files a/kubernetes/assets/docker backend build.png and /dev/null differ diff --git a/kubernetes/assets/docker frontend build.png b/kubernetes/assets/docker frontend build.png deleted file mode 100644 index d9d4157e1..000000000 Binary files a/kubernetes/assets/docker frontend build.png and /dev/null differ diff --git a/kubernetes/assets/docker images.png b/kubernetes/assets/docker images.png deleted file mode 100644 index 6c76001d3..000000000 Binary files a/kubernetes/assets/docker images.png and /dev/null differ diff --git a/kubernetes/assets/docker login.png b/kubernetes/assets/docker login.png deleted file mode 100644 index e54cd7923..000000000 Binary files a/kubernetes/assets/docker login.png and /dev/null differ diff --git a/kubernetes/assets/edit-coredns.png b/kubernetes/assets/edit-coredns.png deleted file mode 100644 index 96fd1cfeb..000000000 Binary files a/kubernetes/assets/edit-coredns.png and /dev/null differ diff --git a/kubernetes/assets/frontend.env.docker.png b/kubernetes/assets/frontend.env.docker.png deleted file mode 100644 index 591ede862..000000000 Binary files a/kubernetes/assets/frontend.env.docker.png and /dev/null differ diff --git a/kubernetes/assets/frontend.png b/kubernetes/assets/frontend.png deleted file mode 100644 index 60ddd65ee..000000000 Binary files a/kubernetes/assets/frontend.png and /dev/null differ diff --git a/kubernetes/assets/get-coredns.png b/kubernetes/assets/get-coredns.png deleted file mode 100644 index b6d60d80f..000000000 Binary files a/kubernetes/assets/get-coredns.png and /dev/null differ diff --git a/kubernetes/assets/mongo.png b/kubernetes/assets/mongo.png deleted file mode 100644 index a41404035..000000000 Binary files a/kubernetes/assets/mongo.png and /dev/null differ diff --git a/kubernetes/assets/namespace create.png b/kubernetes/assets/namespace create.png deleted file mode 100644 index 1b6b3193d..000000000 Binary files a/kubernetes/assets/namespace create.png and /dev/null differ diff --git a/kubernetes/assets/nodes.png b/kubernetes/assets/nodes.png deleted file mode 100644 index 172613405..000000000 Binary files a/kubernetes/assets/nodes.png and /dev/null differ diff --git a/kubernetes/assets/pv.png b/kubernetes/assets/pv.png deleted file mode 100644 index 5581e8027..000000000 Binary files a/kubernetes/assets/pv.png and /dev/null differ diff --git a/kubernetes/assets/pvc.png b/kubernetes/assets/pvc.png deleted file mode 100644 index ae6ffa833..000000000 Binary files a/kubernetes/assets/pvc.png and /dev/null differ diff --git a/kubernetes/assets/redis.png b/kubernetes/assets/redis.png deleted file mode 100644 index 0fd0922fc..000000000 Binary files a/kubernetes/assets/redis.png and /dev/null differ diff --git a/kubernetes/backend.yaml b/kubernetes/backend.yaml deleted file mode 100644 index c0021f39c..000000000 --- a/kubernetes/backend.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: backend-deployment - namespace: wanderlust - labels: - app: backend -spec: - replicas: 1 - selector: - matchLabels: - app: backend - template: - metadata: - name: backend - labels: - app: backend - spec: - containers: - - name: backend - image: madhupdevops/wanderlust-backend-beta:v3.0.18 - ports: - - containerPort: 8080 ---- -apiVersion: v1 -kind: Service -metadata: - name: backend-service - namespace: wanderlust -spec: - type: NodePort - selector: - app: backend - ports: - - port: 8080 - targetPort: 8080 - protocol: TCP - nodePort: 31100 diff --git a/kubernetes/backend.yml b/kubernetes/backend.yml new file mode 100644 index 000000000..9c38bb617 --- /dev/null +++ b/kubernetes/backend.yml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: wander-backend + namespace: wanderlust + labels: + app: wanderlust + tier: backend +spec: + # modify replicas according to your case + replicas: 3 + selector: + matchLabels: + tier: backend + template: + metadata: + labels: + tier: backend + spec: + containers: + - name: backend + image: dooms002/wanderlust-backend:54 + ports: + - containerPort: 8080 + + +--- + +apiVersion: v1 +kind: Service +metadata: + name: backend-svc + namespace: wanderlust +spec: + type: NodePort + selector: + tier: backend + ports: + - protocol: TCP + targetPort: 8080 + port: 8080 + nodePort: 31100 \ No newline at end of file diff --git a/kubernetes/frontend.yaml b/kubernetes/frontend.yaml deleted file mode 100644 index fb5ce6f3a..000000000 --- a/kubernetes/frontend.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: frontend-deployment - namespace: wanderlust - labels: - app: frontend -spec: - replicas: 1 - selector: - matchLabels: - app: frontend - template: - metadata: - name: frontend - labels: - app: frontend - spec: - containers: - - name: frontend - image: madhupdevops/wanderlust-frontend-beta:v3.0.18 - ports: - - containerPort: 5173 ---- -apiVersion: v1 -kind: Service -metadata: - name: frontend-service - namespace: wanderlust -spec: - type: NodePort - selector: - app: frontend - ports: - - port: 5173 - targetPort: 5173 - protocol: TCP - nodePort: 31000 diff --git a/kubernetes/frontend.yml b/kubernetes/frontend.yml new file mode 100644 index 000000000..ff042cc40 --- /dev/null +++ b/kubernetes/frontend.yml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: wander-frontend + namespace: wanderlust + labels: + app: wanderlust + tier: frontend +spec: + # modify replicas according to your case + replicas: 3 + selector: + matchLabels: + tier: frontend + template: + metadata: + labels: + tier: frontend + spec: + containers: + - name: frontend + image: dooms002/wanderlust-frontend:54 + ports: + - containerPort: 80 + +--- + +apiVersion: v1 +kind: Service +metadata: + name: frontend-svc + namespace: wanderlust +spec: + type: NodePort + selector: + tier: frontend + ports: + - protocol: TCP + targetPort: 80 + port: 80 + nodePort: 31000 \ No newline at end of file diff --git a/kubernetes/kubeadm.md b/kubernetes/kubeadm.md deleted file mode 100644 index ebfa20402..000000000 --- a/kubernetes/kubeadm.md +++ /dev/null @@ -1,101 +0,0 @@ -## Setup Kubernetes [Kubeadm] Cluster (Version: 1.29) - -### On both master & worker nodes -- Become root user -```bash -sudo su -``` - -- Updating System Packages -```bash -sudo apt-get update -``` - -- Installing Docker -```bash -sudo apt install docker.io -y -``` -```bash -sudo chmod 777 /var/run/docker.sock -``` - -- Create a shell script 1.sh and paste the below code and run it : -```bash -#!/bin/bash -# disable swap -sudo swapoff -a - -# Create the .conf file to load the modules at bootup -cat < Create a shell script 2.sh and paste the below code and run it -```bash -sudo kubeadm config images pull - -sudo kubeadm init - -mkdir -p "$HOME"/.kube -sudo cp -i /etc/kubernetes/admin.conf "$HOME"/.kube/config -sudo chown "$(id -u)":"$(id -g)" "$HOME"/.kube/config - - -# Network Plugin = calico -kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.0/manifests/calico.yaml - -kubeadm token create --print-join-command -``` - -### On Worker node -- Paste the join command you got from the master node and append --v=5 at the end - -```bash - --v=5 -``` - - diff --git a/kubernetes/mongodb.yaml b/kubernetes/mongodb.yml similarity index 97% rename from kubernetes/mongodb.yaml rename to kubernetes/mongodb.yml index c8473bbfd..6151ab64c 100644 --- a/kubernetes/mongodb.yaml +++ b/kubernetes/mongodb.yml @@ -41,4 +41,4 @@ spec: ports: - port: 27017 targetPort: 27017 - protocol: TCP + protocol: TCP \ No newline at end of file diff --git a/kubernetes/persistentVolume.yaml b/kubernetes/perstintvolum.yml similarity index 91% rename from kubernetes/persistentVolume.yaml rename to kubernetes/perstintvolum.yml index e58ed86b8..1af70ea5d 100644 --- a/kubernetes/persistentVolume.yaml +++ b/kubernetes/perstintvolum.yml @@ -10,4 +10,4 @@ spec: accessModes: - ReadWriteOnce hostPath: - path: /data/db + path: /data/db \ No newline at end of file diff --git a/kubernetes/persistentVolumeClaim.yaml b/kubernetes/perstintvolumclaim.yml similarity index 90% rename from kubernetes/persistentVolumeClaim.yaml rename to kubernetes/perstintvolumclaim.yml index ea1b97509..516740a08 100644 --- a/kubernetes/persistentVolumeClaim.yaml +++ b/kubernetes/perstintvolumclaim.yml @@ -9,4 +9,4 @@ spec: storageClassName: "" resources: requests: - storage: 5Gi + storage: 5Gi \ No newline at end of file diff --git a/kubernetes/redis.yaml b/kubernetes/redise.yml similarity index 97% rename from kubernetes/redis.yaml rename to kubernetes/redise.yml index 06d74d6a4..54d5e7c09 100644 --- a/kubernetes/redis.yaml +++ b/kubernetes/redise.yml @@ -40,4 +40,4 @@ spec: ports: - port: 6379 targetPort: 6379 - protocol: TCP + protocol: TCP \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index df45e1635..000000000 --- a/package-lock.json +++ /dev/null @@ -1,317 +0,0 @@ -{ - "name": "wanderlust", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "concurrently": "^8.2.2" - } - }, - "node_modules/@babel/runtime": { - "version": "7.23.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.2.tgz", - "integrity": "sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==", - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/concurrently": { - "version": "8.2.2", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", - "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", - "dependencies": { - "chalk": "^4.1.2", - "date-fns": "^2.30.0", - "lodash": "^4.17.21", - "rxjs": "^7.8.1", - "shell-quote": "^1.8.1", - "spawn-command": "0.0.2", - "supports-color": "^8.1.1", - "tree-kill": "^1.2.2", - "yargs": "^17.7.2" - }, - "bin": { - "conc": "dist/bin/concurrently.js", - "concurrently": "dist/bin/concurrently.js" - }, - "engines": { - "node": "^14.13.0 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" - } - }, - "node_modules/date-fns": { - "version": "2.30.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", - "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", - "dependencies": { - "@babel/runtime": "^7.21.0" - }, - "engines": { - "node": ">=0.11" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/date-fns" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "node_modules/regenerator-runtime": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", - "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==" - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/rxjs": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", - "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dependencies": { - "tslib": "^2.1.0" - } - }, - "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/spawn-command": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", - "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==" - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/tree-kill": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", - "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", - "bin": { - "tree-kill": "cli.js" - } - }, - "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "engines": { - "node": ">=12" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 64b0a98ca..000000000 --- a/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "dependencies": { - "concurrently": "^8.2.2" - }, - "scripts": { - "start-frontend": "cd frontend && npm run dev", - "start-backend": "cd backend && npm start", - "start": "concurrently -n \"FRONTEND,BACKEND\" -c \"bgBlue,bgYellow\" -p \"[{name}]\" \"npm run start-frontend\" \"npm run start-backend\"", - "install-frontend": "cd frontend && npm i", - "install-backend": "cd backend && npm i", - "installer": "npm i && npm run install-backend && npm run install-frontend" - } -}