diff --git a/.github/workflows/apply-k8s.yml b/.github/workflows/apply-k8s.yml new file mode 100644 index 0000000..dd091e4 --- /dev/null +++ b/.github/workflows/apply-k8s.yml @@ -0,0 +1,24 @@ +name: Apply Kubernetes + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'infrastructure/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v3 + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Apply Kubernetes manifests + run: kubectl apply -f infrastructure/K8S && kubectl apply -f infrastructure/prod-k8s \ No newline at end of file diff --git a/.github/workflows/deploy-auction.yml b/.github/workflows/deploy-auction.yml index bf6f6da..0f2ad14 100644 --- a/.github/workflows/deploy-auction.yml +++ b/.github/workflows/deploy-auction.yml @@ -11,6 +11,7 @@ on: env: REGISTRY_IMAGE: knphilip/bidwheels-auction-svc DOCKERFILE: src/AuctionService/Dockerfile + DEPLOYMENT_NAME: auction-svc jobs: build: @@ -23,4 +24,12 @@ jobs: tags: ${{ env.REGISTRY_IMAGE }}:latest file: ${{ env.DOCKERFILE }} username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} \ No newline at end of file + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.github/workflows/deploy-bid.yml b/.github/workflows/deploy-bid.yml new file mode 100644 index 0000000..e823b0b --- /dev/null +++ b/.github/workflows/deploy-bid.yml @@ -0,0 +1,35 @@ +name: Deploy Bidding Service + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'src/BiddingService/**' + +env: + REGISTRY_IMAGE: knphilip/bidwheels-bid-svc + DOCKERFILE: src/BiddingService/Dockerfile + DEPLOYMENT_NAME: bid-svc + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build and push the Docker image + uses: knphilip/actions/dockerfile-push@main + with: + context: "{{defaultContext}}" + tags: ${{ env.REGISTRY_IMAGE }}:latest + file: ${{ env.DOCKERFILE }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.github/workflows/deploy-gateway.yml b/.github/workflows/deploy-gateway.yml new file mode 100644 index 0000000..1f0ecbf --- /dev/null +++ b/.github/workflows/deploy-gateway.yml @@ -0,0 +1,35 @@ +name: Deploy Gateway Service + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'src/GatewayService/**' + +env: + REGISTRY_IMAGE: knphilip/bidwheels-gateway-svc + DOCKERFILE: src/GatewayService/Dockerfile + DEPLOYMENT_NAME: gateway-svc + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build and push the Docker image + uses: knphilip/actions/dockerfile-push@main + with: + context: "{{defaultContext}}" + tags: ${{ env.REGISTRY_IMAGE }}:latest + file: ${{ env.DOCKERFILE }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.github/workflows/deploy-notify.yml b/.github/workflows/deploy-notify.yml new file mode 100644 index 0000000..b3a3372 --- /dev/null +++ b/.github/workflows/deploy-notify.yml @@ -0,0 +1,35 @@ +name: Deploy Notification Service + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'src/NotificationService/**' + +env: + REGISTRY_IMAGE: knphilip/bidwheels-notify-svc + DOCKERFILE: src/NotificationService/Dockerfile + DEPLOYMENT_NAME: notify-svc + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build and push the Docker image + uses: knphilip/actions/dockerfile-push@main + with: + context: "{{defaultContext}}" + tags: ${{ env.REGISTRY_IMAGE }}:latest + file: ${{ env.DOCKERFILE }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.github/workflows/deploy-search.yml b/.github/workflows/deploy-search.yml new file mode 100644 index 0000000..116db82 --- /dev/null +++ b/.github/workflows/deploy-search.yml @@ -0,0 +1,35 @@ +name: Deploy Search Service + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'src/SearchService/**' + +env: + REGISTRY_IMAGE: knphilip/bidwheels-search-svc + DOCKERFILE: src/SearchService/Dockerfile + DEPLOYMENT_NAME: search-svc + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build and push the Docker image + uses: knphilip/actions/dockerfile-push@main + with: + context: "{{defaultContext}}" + tags: ${{ env.REGISTRY_IMAGE }}:latest + file: ${{ env.DOCKERFILE }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.github/workflows/deploy-webapp.yml b/.github/workflows/deploy-webapp.yml new file mode 100644 index 0000000..4a3cde8 --- /dev/null +++ b/.github/workflows/deploy-webapp.yml @@ -0,0 +1,35 @@ +name: Deploy Web Application + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'frontend/web-app/**' + +env: + REGISTRY_IMAGE: knphilip/bidwheels-web-app + DOCKERFILE: frontend/web-app/Dockerfile + DEPLOYMENT_NAME: webapp + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build and push the Docker image + uses: knphilip/actions/dockerfile-push@main + with: + context: "{{defaultContext}}" + tags: ${{ env.REGISTRY_IMAGE }}:latest + file: ${{ env.DOCKERFILE }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Save DigitalOcean kubeconfig + run: doctl kubernetes cluster kubeconfig save bidwheels + - name: Restart Kubernetes deployment + run: kubectl rollout restart deployment ${{ secrets.DEPLOYMENT_NAME }} \ No newline at end of file diff --git a/.idea/.idea.BidWheels/.idea/.gitignore b/.idea/.idea.BidWheels/.idea/.gitignore new file mode 100644 index 0000000..1e23dfb --- /dev/null +++ b/.idea/.idea.BidWheels/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +/.idea.BidWheels.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.BidWheels/.idea/indexLayout.xml b/.idea/.idea.BidWheels/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.BidWheels/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.BidWheels/.idea/vcs.xml b/.idea/.idea.BidWheels/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.BidWheels/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/infrastructure/K8S/mongo-depl.yaml b/infrastructure/K8S/mongo-depl.yaml index 6abd5ee..abe6fde 100644 --- a/infrastructure/K8S/mongo-depl.yaml +++ b/infrastructure/K8S/mongo-depl.yaml @@ -46,15 +46,3 @@ spec: ports: - port: 27017 targetPort: 27017 ---- -apiVersion: v1 -kind: Service -metadata: - name: mongo-lb -spec: - type: LoadBalancer - selector: - app: mongo - ports: - - port: 27017 - targetPort: 27017 diff --git a/infrastructure/K8S/postgres-depl.yml b/infrastructure/K8S/postgres-depl.yml index 8a0baf2..762a96f 100644 --- a/infrastructure/K8S/postgres-depl.yml +++ b/infrastructure/K8S/postgres-depl.yml @@ -41,15 +41,3 @@ spec: ports: - port: 5432 targetPort: 5432 ---- -apiVersion: v1 -kind: Service -metadata: - name: postgres-lb -spec: - type: LoadBalancer - selector: - app: postgres - ports: - - port: 5432 - targetPort: 5432 diff --git a/infrastructure/K8S/rabbitmq-depl.yml b/infrastructure/K8S/rabbitmq-depl.yml index 8d13476..f2d5855 100644 --- a/infrastructure/K8S/rabbitmq-depl.yml +++ b/infrastructure/K8S/rabbitmq-depl.yml @@ -49,16 +49,4 @@ spec: ports: - port: 5672 targetPort: 5672 ---- -apiVersion: v1 -kind: Service -metadata: - name: rabbitmq-lb -spec: - type: LoadBalancer - selector: - app: rabbitmq - ports: - - port: 15672 - targetPort: 15672 \ No newline at end of file diff --git a/infrastructure/K8S/webapp-depl.yml b/infrastructure/K8S/webapp-depl.yml index 7505471..d629c18 100644 --- a/infrastructure/K8S/webapp-depl.yml +++ b/infrastructure/K8S/webapp-depl.yml @@ -41,15 +41,3 @@ spec: ports: - port: 3000 targetPort: 3000 ---- -apiVersion: v1 -kind: Service -metadata: - name: webapp-lb -spec: - type: LoadBalancer - selector: - app: webapp - ports: - - port: 3000 - targetPort: 3000 diff --git a/infrastructure/K8S/ingress-svc.yml b/infrastructure/dev-k8s/ingress-svc.yml similarity index 100% rename from infrastructure/K8S/ingress-svc.yml rename to infrastructure/dev-k8s/ingress-svc.yml diff --git a/infrastructure/dev-k8s/local-lbs.yml b/infrastructure/dev-k8s/local-lbs.yml new file mode 100644 index 0000000..669c077 --- /dev/null +++ b/infrastructure/dev-k8s/local-lbs.yml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres-lb +spec: + type: LoadBalancer + selector: + app: postgres + ports: + - port: 5432 + targetPort: 5432 +--- +apiVersion: v1 +kind: Service +metadata: + name: rabbitmq-lb +spec: + type: LoadBalancer + selector: + app: rabbitmq + ports: + - port: 15672 + targetPort: 15672 +--- +apiVersion: v1 +kind: Service +metadata: + name: webapp-lb +spec: + type: LoadBalancer + selector: + app: webapp + ports: + - port: 3000 + targetPort: 3000 +--- +apiVersion: v1 +kind: Service +metadata: + name: mongo-lb +spec: + type: LoadBalancer + selector: + app: mongo + ports: + - port: 27017 + targetPort: 27017 diff --git a/infrastructure/prod-k8s/ingress-svc.yml b/infrastructure/prod-k8s/ingress-svc.yml new file mode 100644 index 0000000..d51c997 --- /dev/null +++ b/infrastructure/prod-k8s/ingress-svc.yml @@ -0,0 +1,34 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-svc + labels: + name: ingress-svc +spec: + ingressClassName: nginx + tls: + - hosts: + - app.bidwheels.com + - api.bidwheels.com + secretName: bidwheels-app-tls + rules: + - host: app.bidwheels.com + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: webapp-clusterip + port: + number: 3000 + - host: api.bidwheels.com + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: gateway-clusterip + port: + number: 80 \ No newline at end of file diff --git a/infrastructure/prod-k8s/prod-secrets.yml b/infrastructure/prod-k8s/prod-secrets.yml new file mode 100644 index 0000000..87feee5 --- /dev/null +++ b/infrastructure/prod-k8s/prod-secrets.yml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: Secret +metadata: + name: postgres-secret +type: Opaque +stringData: + password: postgresSecretPw +--- +apiVersion: v1 +kind: Secret +metadata: + name: rabbit-secret +type: Opaque +stringData: + username: rabbit + password: rabbitSecretPw +--- +apiVersion: v1 +kind: Secret +metadata: + name: mongo-secret +type: Opaque +stringData: + username: mongo + password: mongoSecretPw +--- +apiVersion: v1 +kind: Secret +metadata: + name: auction-secret +type: Opaque +stringData: + rabbitUsername: rabbit + rabbitPassword: rabbitSecretPw + connectionString: 'Server=postgres-clusterip:5432;User Id=postgres;Password=postgresSecretPw;Database=auctions' +--- +apiVersion: v1 +kind: Secret +metadata: + name: search-secret +type: Opaque +stringData: + connectionString: mongodb://mongoUsername:mongoSecretPw@mongo-clusterip + rabbitUsername: rabbit + rabbitPassword: rabbitSecretPw +--- +apiVersion: v1 +kind: Secret +metadata: + name: notify-secret +type: Opaque +stringData: + rabbitUsername: rabbit + rabbitPassword: rabbitSecretPw +--- +apiVersion: v1 +kind: Secret +metadata: + name: bid-secret +type: Opaque +stringData: + rabbitUsername: rabbit + rabbitPassword: rabbitSecretPw + connectionString: 'mongodb://mongoUsername:mongoSecretPw@mongo-clusterip' +--- +apiVersion: v1 +kind: Secret +metadata: + name: webapp-secret +type: Opaque +stringData: + authSecret: thisisevenmoresecretthanprevioussecrets