Skip to content

Commit

Permalink
Refactor ingress configuration to remove SSL redirect and force SSL r…
Browse files Browse the repository at this point in the history
…edirect annotations, and change backend protocol to HTTP for monitoring-ingress resource
  • Loading branch information
adamlahbib committed Nov 18, 2024
1 parent 9c5ce4b commit 282e679
Show file tree
Hide file tree
Showing 18 changed files with 3,051 additions and 25 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
readme.md
4 changes: 4 additions & 0 deletions .github/actions/terraform-apply/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ inputs:
TAILSCALE_CLIENT_SECRET:
description: 'Tailscale Client Secret'
required: true
CROWDSEC_ENROLL_KEY:
description: 'CrowdSec Enroll Key'
required: true

runs:
using: 'composite'
Expand All @@ -65,6 +68,7 @@ runs:
TF_VAR_SLACK_WEBHOOK: ${{ inputs.SLACK_WEBHOOK }}
TF_VAR_TAILSCALE_CLIENT_ID: ${{ inputs.TAILSCALE_CLIENT_ID }}
TF_VAR_TAILSCALE_CLIENT_SECRET: ${{ inputs.TAILSCALE_CLIENT_SECRET }}
TF_VAR_CROWDSEC_ENROLL_KEY: ${{ inputs.CROWDSEC_ENROLL_KEY }}
uses: dflook/terraform-apply@v1
with:
path: ./terraform
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/terraform-destroy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ inputs:
TAILSCALE_CLIENT_SECRET:
description: 'Tailscale Client Secret'
required: true
CROWDSEC_ENROLL_KEY:
description: 'CrowdSec Enroll Key'
required: true

runs:
using: 'composite'
Expand All @@ -65,6 +68,7 @@ runs:
TF_VAR_SLACK_WEBHOOK: ${{ inputs.SLACK_WEBHOOK }}
TF_VAR_TAILSCALE_CLIENT_ID: ${{ inputs.TAILSCALE_CLIENT_ID }}
TF_VAR_TAILSCALE_CLIENT_SECRET: ${{ inputs.TAILSCALE_CLIENT_SECRET }}
TF_VAR_CROWDSEC_ENROLL_KEY: ${{ inputs.CROWDSEC_ENROLL_KEY }}
uses: dflook/terraform-destroy@v1
with:
path: ./terraform
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/terraform-plan/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ inputs:
TAILSCALE_CLIENT_SECRET:
description: 'Tailscale Client Secret'
required: true
CROWDSEC_ENROLL_KEY:
description: 'CrowdSec Enroll Key'
required: true

runs:
using: 'composite'
Expand All @@ -72,6 +75,7 @@ runs:
TF_VAR_SLACK_WEBHOOK: ${{ inputs.SLACK_WEBHOOK }}
TF_VAR_TAILSCALE_CLIENT_ID: ${{ inputs.TAILSCALE_CLIENT_ID }}
TF_VAR_TAILSCALE_CLIENT_SECRET: ${{ inputs.TAILSCALE_CLIENT_SECRET }}
TF_VAR_CROWDSEC_ENROLL_KEY: ${{ inputs.CROWDSEC_ENROLL_KEY }}
uses: dflook/terraform-plan@v1
with:
path: ./terraform
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/destroy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ secrets.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ secrets.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ secrets.CROWDSEC_ENROLL_KEY }}

jobs:
terraform-destroy:
Expand Down Expand Up @@ -55,4 +56,5 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ env.CLOUDFLARE_API_TOKEN }}
SLACK_WEBHOOK: ${{ env.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ env.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ env.TAILSCALE_CLIENT_SECRET }}
TAILSCALE_CLIENT_SECRET: ${{ env.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ env.CROWDSEC_ENROLL_KEY }}
4 changes: 3 additions & 1 deletion .github/workflows/plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ secrets.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ secrets.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ secrets.CROWDSEC_ENROLL_KEY }}

jobs:
terraform-plan:
Expand Down Expand Up @@ -64,4 +65,5 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ env.CLOUDFLARE_API_TOKEN }}
SLACK_WEBHOOK: ${{ env.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ env.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ env.TAILSCALE_CLIENT_SECRET }}
TAILSCALE_CLIENT_SECRET: ${{ env.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ env.CROWDSEC_ENROLL_KEY }}
2 changes: 2 additions & 0 deletions .github/workflows/sync-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ secrets.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ secrets.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ secrets.CROWDSEC_ENROLL_KEY }}

jobs:
terraform-apply:
Expand Down Expand Up @@ -63,6 +64,7 @@ jobs:
SLACK_WEBHOOK: ${{ env.SLACK_WEBHOOK }}
TAILSCALE_CLIENT_ID: ${{ env.TAILSCALE_CLIENT_ID }}
TAILSCALE_CLIENT_SECRET: ${{ env.TAILSCALE_CLIENT_SECRET }}
CROWDSEC_ENROLL_KEY: ${{ env.CROWDSEC_ENROLL_KEY }}

- name: Prepare Slack Notification
if: always()
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# The pipeline can have failed steps marked as successful by using continue-on-error: true.
# If needed, I just went with the default setting for the sake of simplicity and used the always() condition to ensure that any step runs regardless of the outcome of the previous steps.

name: Test Pipeline

on:
Expand All @@ -11,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
name: Test Application
outputs:
message: "Bandit Security Linting: ${{ steps.bandit.outcome }}\nTrufflehog Leaked Secret Scanning: ${{ steps.trufflehog.outcome }}\nGrype Container Vulnerability Scanning: ${{ steps.grype.outcome }}\nApplication Tests: ${{ steps.tests.outcome }}"
message: "Bandit Security Linting: ${{ steps.bandit.outcome }}\nTrufflehog Leaked Secret Scanning: ${{ steps.trufflehog.outcome }}\nGrype Container Vulnerability Scanning: ${{ steps.grype.outcome }}\nApplication Tests: ${{ steps.tests.outcome }}\nFlake8 Linting: ${{ steps.lint.outcome }}"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -62,6 +65,11 @@ jobs:
if: always()
run: make run

- name: Flake8 Linting # I had linting running inside the container as the application uses uvicorn, a server that won't exit if any errors are found and thus the container would not stop running
id: lint
if: always()
run: make lint

- name: Run-Tests
id: tests
if: always()
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DOCKER_COMPOSE = docker compose

.PHONY: run build test clean
.PHONY: run build test clean lint

build:
@$(DOCKER_COMPOSE) build
Expand All @@ -11,5 +11,11 @@ run:
test:
@$(DOCKER_COMPOSE) run --rm app pytest --cov=app --cov-report=term-missing

lint:
@echo "Running flake8 for syntax errors and undefined names..."
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
@echo "Running flake8 with relaxed rules (warnings only)..."
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

clean:
@$(DOCKER_COMPOSE) down --volumes --remove-orphans
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ uvicorn==0.30.5
pydantic==1.10.10
pytest==7.4.2
pytest-cov==4.1.0
httpx==0.23.0
httpx==0.23.0
flake8==7.1.1
Loading

0 comments on commit 282e679

Please sign in to comment.