Resolved

Resolving FluxCD Helm deployment issues with OCI migration and Docker production readiness

FluxCD
Kubernetes
Helm
OCI
Docker
GitHub Actions
CI/CD
DevOps
Security
Infrastructure

Addressing deployment failures caused by migration to OCI registries, GitHub Actions security scanning issues, and Docker image production readiness.

Issue

The deployment pipeline encountered three critical issues that blocked infrastructure updates:

  1. FluxCD Helm deployment failures due to unsupported OCI registry protocols, preventing the use of updated Helm charts.
  2. GitHub Actions security scanning warnings caused by missing permissions for SARIF uploads, disrupting security compliance workflows.
  3. Docker production images containing development-specific files and improper secrets management, violating security and operational best practices.

These issues collectively prevented the successful deployment of infrastructure components, such as Redis, and introduced security and compliance risks.

Culprit

OCI Registry Migration

A migration from traditional HTTP Helm repositories to OCI-based registries by the Helm chart provider (e.g., Bitnami) introduced compatibility issues with FluxCD. The existing FluxCD HelmRepository configurations were designed for HTTP-based repositories and could not directly support the new OCI protocol (oci://), causing deployment failures.

GitHub Actions Permissions

The CI/CD pipeline lacked the necessary security-events: write permission, which is required for uploading SARIF files generated by security scanning tools (e.g., Trivy). Without this permission, GitHub Actions continued to produce warnings, impacting the reliability of the security compliance process.

Docker Production Readiness

The Docker images included development-specific files (e.g., .env.example) and did not utilize the intended secrets management solution (e.g., Azure Key Vault CSI driver). This violated security best practices by embedding sensitive or non-production artifacts in the final images.

Solution

OCI Registry Migration

To resolve the OCI registry issue:

  1. Update FluxCD Configuration: Replace HelmRepository resources with OCIRepository resources to support the new OCI-based Helm charts.
  2. Reference OCI Repository: Ensure that HelmRelease configurations reference the newly created OCIRepository instead of outdated HTTP-based repositories.

This change enables FluxCD to pull and deploy Helm charts from OCI registries, resolving the deployment failures.

GitHub Actions SARIF Upload

To address the GitHub Actions security scanning issue:

  1. Modify Workflow: Update the GitHub Actions workflow to include the continue-on-error: true flag for SARIF uploads, ensuring that security scanning does not block the build pipeline.
  2. Verify Permissions: Ensure that the repository has the appropriate permissions for uploading SARIF files to GitHub Code Scanning.

This resolves the warnings and ensures that security scanning remains an integral part of the CI/CD process.

Docker Production Readiness

To improve Docker image production readiness:

  1. Remove Development Files: Exclude development-specific files (e.g., .env.example) from the Docker build process.
  2. Implement Secrets Management: Use a secure secrets management solution (e.g., CSI driver for cloud-based key vaults) to inject secrets at runtime, rather than embedding them in the image.

This ensures that production images are secure, compliant, and aligned with operational best practices.

Resource Optimization

Optimize resource usage in the Kubernetes cluster by:

  1. Disabling Unnecessary Components: Turn off non-critical components (e.g., policy enforcement tools) to free up CPU resources.
  2. Minimizing Monitoring Overhead: Reduce resource allocations for monitoring tools to ensure sufficient capacity for critical workloads.
  3. Constraining Controller Resources: Limit CPU allocations for FluxCD controllers to prevent resource exhaustion in single-node clusters.

Verification

After applying the fixes:

  • OCI Registry: Confirm that FluxCD successfully pulls and deploys Helm charts from the OCI registry.
  • GitHub Actions: Verify that SARIF uploads complete without errors, and security scanning remains active.
  • Docker Images: Ensure that production images exclude development files and use secure secrets management.
  • Resource Utilization: Monitor CPU and memory usage to confirm that the cluster operates within expected limits.

This approach ensures a secure, compliant, and efficient deployment pipeline while addressing the root causes of the issues.