/LINUXtips-giropops-senhas

Primary LanguageCSSGNU General Public License v3.0GPL-3.0

antonioazambuja/LINUXtips-giropops-senhas

This project was created on the PICK LinuxTips and have objective allow practice my abilities in Security Practices, Resource Efficient, Monitoring and Automation.

Project tasks

BACKLOG

TODO

  • Remove spec.replicas Deployment when exist HPA;
  • Prometheus Monitoring:
    • AlertManager Alarms to giropops-senhas and Redis;
    • Add more metrics to giropops-senhas;
  • Add cert-manager;
  • EKS:
  • Remove exclude Kube-linter config;
  • Github Actions:
    • Use container Chainguard image on Github Actions;
    • Add CRDs support on kube-linter;
  • Infrastructure:
  • Application:
    • CI:
      • Migrate Public Docker Hub Repository to Private Docker Hub Registry or AWS ECR;
  • README.md:
    • Add README how to install dependencies to use Makefile;
    • How to fix spike request on application?;

WIP

  • Redis:
    • User nonRoot with StatefulSet using Chainguard image;

DONE

  • Project Fork;
  • Repository Organization;
  • Docker image:
    • Otimization with multi-stage builds and Chainguard images;
    • Security scan;
  • K8s Configuration:
    • YAML manifests;
    • Best Practices;
    • YAML Linting;
  • Github Actions:
    • Sign with Cosign;
    • Lint Kube and YAML;
  • Redis:
    • Create K8s headless service;
    • Add support to PV and Statefulset on AWS EKS;
  • Infrastructure:
    • K6 Operator Install;
  • Prometheus Monitoring:
    • Install Prometheus on K8s;
    • Instrument Prometheus on project using ServiceMonitor CRD;
    • Add more metrics to Redis;
  • Chainguard Cosign - Signing Docker images;
  • Load Test with K6 (min TP: 1000 rpm without any errors):
    • K8s resource analysis after Load Test;
    • Using K6 Operator to run load test inside K8s cluster using K8s service endpoint;
    • Using K6 local with ingress of giropops-senhas;
  • README.md:
    • What's your decisions and process used in this project;
    • How to verify signed container images using cosign?

Below have some descriptions and decisions about tools used in this project:

Fork

This project is a fork of badtuxx/giropops-senhas. I'm participating in the LinuxTips PICK and we task as a students was developing full project using more latest tools knowledged in the course and based in this fork repository application Giropops Senhas.

Developing Docker image

I used Python Chainguard image with free account available. This image base is Distroless, then my objective was built this project free vulnerabilities and with base image more lower size possible with objective increase pull on my K8s cluster.

Optimizing

I used Chainguard Distroless base image and multistage build on Python environment. More details about: Dockerfile.

Trivy - Security Scan

I used Trivy to security scan in base image developed. Below you can view latest scan performed in the image.

Performed in: November 26th, 2024.

✗ trivy image giropops-senhas:0.1
2023-11-26T21:29:04.967-0300	INFO	Need to update DB
2023-11-26T21:29:04.967-0300	INFO	DB Repository: ghcr.io/aquasecurity/trivy-db
2023-11-26T21:29:04.967-0300	INFO	Downloading DB...
40.99 MiB / 40.99 MiB [-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 16.06 MiB p/s 2.8s
2023-11-26T21:29:08.969-0300	INFO	Vulnerability scanning is enabled
2023-11-26T21:29:08.969-0300	INFO	Secret scanning is enabled
2023-11-26T21:29:08.969-0300	INFO	If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-11-26T21:29:08.969-0300	INFO	Please see also https://aquasecurity.github.io/trivy/v0.47/docs/scanner/secret/#recommendation for faster secret detection
2023-11-26T21:29:17.509-0300	INFO	Detected OS: wolfi
2023-11-26T21:29:17.509-0300	INFO	Detecting Wolfi vulnerabilities...
2023-11-26T21:29:17.510-0300	INFO	Number of language-specific files: 1
2023-11-26T21:29:17.510-0300	INFO	Detecting python-pkg vulnerabilities...

giropops-senhas:0.1 (wolfi 20230201)

Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)

Running

For running this project look steps above:

  • Choose how to run your cluster. I'm running on Kind cluster locally:
kind create cluster --config kind/cluster.yaml
git clone 

CI

I used Github Actions to create CI on this project. When new push is performed in the branches main and develop these steps are executed:

  • Docker Hub login;
  • Docker build;
  • Run Trivy scan to search any vulnerabilities;
  • Build and push to Docker Hub;
  • Sign the container image with Cosign;

How to verify the container image

You can do that by using the cosign verify command against the published container image:

cosign verify ablackout3/giropops-senhas:latest \
  --certificate-identity https://github.com/antonioazambuja/LINUXtips-giropops-senhas/.github/workflows/ci.yaml@refs/heads/develop \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com | jq

PS.: Because we are doing a public repository, this will automatically be pushed to the public instance of the Rekor transparency log. More details about Rekor you can see here.

Load Test

Objective: I used K6 to run load test on application. Using K6 my objective was ensure application receive 1000 rpm.

Reality: K6 load test on application with 4000 rpm in each endpoint GET /, GET /api/senhas and, POST /api/gerar-senha using 2 value on K6 parallelism parameter with up up 8000 rpm withot any error.