-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Kubernetes
Application
resource manifests for microservices …
…| Disabling `dorny paths filter` in Github Actions | Update Readme.md
- Loading branch information
1 parent
e9d1acc
commit 5516c30
Showing
17 changed files
with
396 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,6 @@ name: Main | |
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [dev, main] | ||
types: [opened, edited] | ||
|
||
## Adding this allows us to trigger this workflow manually (Just for debugging purposes). | ||
workflow_dispatch: {} | ||
|
@@ -131,8 +128,8 @@ jobs: | |
- go.work.sum | ||
- name: application-controller | ||
path: backend/gateway | ||
manifest: kubernetes/base/microservices/application-controller.application.yaml | ||
path: kubernetes/operators/application | ||
manifest: kubernetes/base/application-controller/deployment.yaml | ||
path_filters: | | ||
changed: | ||
- kubernetes/operators/application/** | ||
|
@@ -144,31 +141,31 @@ jobs: | |
|
||
## If sourcecode of the microservice has changed, only then we will rebuild, push, sign | ||
## and scan the container image. | ||
- name: Detect sourcecode change | ||
uses: dorny/paths-filter@v2 | ||
id: path-filter | ||
with: | ||
base: ${{ github.ref }} | ||
filters: ${{ matrix.microservice.path_filters }} | ||
## - name: Detect sourcecode change | ||
## uses: dorny/paths-filter@v2 | ||
## id: path-filter | ||
## with: | ||
## base: ${{ github.ref }} | ||
## filters: ${{ matrix.microservice.path_filters }} | ||
|
||
- name: Set up QEMU | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: archisman-mridha | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Restore cached Cargo dependencies (if exists) | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
|
@@ -177,7 +174,7 @@ jobs: | |
key: ${{ runner.os }}-cargo-${{ matrix.microservice.name }}-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Build and push AMD64 container image | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
|
@@ -194,7 +191,7 @@ jobs: | |
cache-to: type=gha,mode=max | ||
|
||
- name: Cache Cargo dependencies | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
|
@@ -203,20 +200,20 @@ jobs: | |
key: ${{ runner.os }}-cargo-${{ matrix.microservice.name }}-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Remove cached folders from local machine | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
run: | | ||
rm -rf /usr/local/cargo/registry/ target/ | ||
## Cosign is a command line utility that can sign and verify software artifact, such as | ||
## container images and blobs. | ||
- name: Install Cosign | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: v2.2.1 | ||
|
||
- name: Sign the published container image | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
env: | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | ||
run: | | ||
|
@@ -228,11 +225,11 @@ jobs: | |
ghcr.io/archisman-mridha/instagram-clone-${{ matrix.microservice.name }}:${{ github.sha }} -y | ||
- name: Create outputs directory | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
run: mkdir -p ./outputs/trivy | ||
|
||
- name: Scan container image for vulnerabilities | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: ghcr.io/archisman-mridha/instagram-clone-${{ matrix.microservice.name }}:${{ github.sha }} | ||
|
@@ -243,23 +240,23 @@ jobs: | |
output: ./outputs/trivy/${{ matrix.microservice.name }}.container-image-scan-result.sarif | ||
|
||
- name: Upload the scan result as Github artifact | ||
if: steps.path-filter.outputs.changed == 'true' | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: trivy.${{ matrix.microservice.name }}-microservice.container-image-scan-result.sarif | ||
path: ./outputs/trivy/${{ matrix.microservice.name }}.container-image-scan-result.sarif | ||
|
||
## - name: Update container image tag in Kubernetes manifests | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
## run: | | ||
## git config --global user.name "Archisman-Mridha" | ||
## git config --global user.email "[email protected]" | ||
## git config --global pull.rebase false | ||
- name: Update container image tag in Kubernetes manifests | ||
## if: steps.path-filter.outputs.changed == 'true' | ||
run: | | ||
git config --global user.name "Archisman-Mridha" | ||
git config --global user.email "[email protected]" | ||
git config --global pull.rebase false | ||
## git pull origin main | ||
git pull origin main -f | ||
## sed -i 's/instagram-clone-\(.*\):[[:alnum:]]\+/instagram-clone-\1:${{ github.sha }}/g' ${{ matrix.microservice.manifest }} | ||
sed -i 's/instagram-clone-\(.*\):[[:alnum:]]\+/instagram-clone-\1:${{ github.sha }}/g' ${{ matrix.microservice.manifest }} | ||
## git add . | ||
## git commit -m "🤖 Update container image tag for ${{ matrix.microservice.name }} to ${{ github.sha }}" | ||
## git push --set-upstream origin main | ||
git add . | ||
git commit -m "🤖 Update container image tag for ${{ matrix.microservice.name }} to ${{ github.sha }}" | ||
git push --set-upstream origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
kubernetes/base/microservices/feeds-microservice.application.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: instagramclone.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: feeds-microservice | ||
namespace: microservices | ||
|
||
spec: | ||
image: ghcr.io/archisman-mridha/instagram-clone-feeds-microservice:9574f877a5a231dbab94fa621fac97734ad5227e | ||
replicas: | ||
min: 2 | ||
max: 3 | ||
resources: | ||
cpu: 100m | ||
memory: 100Mi | ||
secretName: feeds-microservice | ||
port: 4000 |
16 changes: 16 additions & 0 deletions
16
kubernetes/base/microservices/followships-microservice.application.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: instagramclone.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: followships-microservice | ||
namespace: microservices | ||
|
||
spec: | ||
image: ghcr.io/archisman-mridha/instagram-clone-followships-microservice:9574f877a5a231dbab94fa621fac97734ad5227e | ||
replicas: | ||
min: 2 | ||
max: 3 | ||
resources: | ||
cpu: 100m | ||
memory: 100Mi | ||
secretName: followships-microservice | ||
port: 4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: instagramclone.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: gateway | ||
namespace: microservices | ||
|
||
spec: | ||
image: ghcr.io/archisman-mridha/instagram-clone-gateway:9574f877a5a231dbab94fa621fac97734ad5227e | ||
replicas: | ||
min: 2 | ||
max: 3 | ||
resources: | ||
cpu: 100m | ||
memory: 100Mi | ||
secretName: gateway | ||
port: 4000 |
Oops, something went wrong.