### GitHub Actions: Push OCI Artifacts Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This GitHub Actions workflow automates the process of packaging components as OCI artifacts, pushing them to GitHub Container Registry (GHCR), and signing them with cosign upon commits to the 'main' branch. It utilizes custom Flux CD actions for setup and pushing. ```yaml name: push-artifact on: workflow_dispatch: push: branches: - 'main' jobs: flux-push: strategy: fail-fast: false matrix: component: - backend - frontend runs-on: ubuntu-latest permissions: contents: read packages: write id-token: write steps: - name: Checkout uses: actions/checkout@v4 - name: Install flux uses: controlplaneio-fluxcd/distribution/actions/setup@main - name: Install cosign uses: sigstore/cosign-installer@v3 with: cosign-release: v2.6.1 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push artifact uses: controlplaneio-fluxcd/distribution/actions/push@main id: push with: repository: ghcr.io/${{ github.repository }}/${{ matrix.component }} path: "./components/${{ matrix.component }}" diff-tag: latest - name: Sign artifact if: steps.push.outputs.pushed == 'true' run: cosign sign --yes $DIGEST_URL env: DIGEST_URL: ${{ steps.push.outputs.digest-url }} ``` -------------------------------- ### Release Tagged Component Versions with OCI Artifacts (YAML) Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This workflow is triggered by Git tags in the format `component/version`. It pushes versioned OCI artifacts to a container registry with stable tags and signs them using cosign for supply chain security. It requires permissions for contents, packages, and id-token, and utilizes actions for checkout, flux setup, cosign installation, docker login, and artifact pushing. ```yaml name: release-artifact on: push: tags: - '**' jobs: flux-push-component: runs-on: ubuntu-latest permissions: contents: read packages: write id-token: write steps: - name: Checkout uses: actions/checkout@v4 - name: Install flux uses: controlplaneio-fluxcd/distribution/actions/setup@main - name: Install cosign uses: sigstore/cosign-installer@v3 with: cosign-release: v2.6.1 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Prepare tags id: prep env: REF_NAME: ${{ github.ref_name }} run: | if [[ $REF_NAME != */* ]]; then echo "Ref name is not in the format component/version" exit 1 fi COMPONENT=$(echo "$REF_NAME" | cut -d'/' -f 1) VERSION=$(echo "$REF_NAME" | cut -d'/' -f 2) echo "component=${COMPONENT}" >> $GITHUB_OUTPUT echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Push artifact uses: controlplaneio-fluxcd/distribution/actions/push@main id: push with: repository: ghcr.io/${{ github.repository }}/${{ steps.prep.outputs.component }} path: "./components/${{ steps.prep.outputs.component }}" diff-tag: ${{ steps.prep.outputs.version }} tags: latest-stable - name: Sign artifact if: steps.push.outputs.pushed == 'true' run: cosign sign --yes $DIGEST_URL env: DIGEST_URL: ${{ steps.push.outputs.digest-url }} ``` -------------------------------- ### Kustomize Base for Component Organization Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt A base Kustomization file that organizes related HelmRelease resources, such as Memcached and Redis, within a namespace. This serves as a foundation for environment-specific configurations. ```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - memcached.yaml - redis.yaml ``` -------------------------------- ### Kustomization for Staging Environment Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This Kustomization file applies base configurations and patches specific values for the 'podinfo' HelmRelease in the staging environment. It utilizes Flux CD's Kustomize controller for applying configurations. ```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../base patches: - path: podinfo-values.yaml target: kind: HelmRelease ``` -------------------------------- ### Directory Structure for Application Components Source: https://github.com/controlplaneio-fluxcd/d2-apps/blob/main/README.md Illustrates the standard directory layout for organizing application components within the d2-apps repository. This structure separates configurations by namespace and environment (base, production, staging), facilitating modular and scalable application management. ```shell cd "./components/" └── namespace ├── base │ ├── kustomization.yaml │ └── release1.yaml │ └── release2.yaml ├── production │ ├── kustomization.yaml │ ├── release1-values.yaml │ └── release2-values.yaml └── staging ├── kustomization.yaml ├── release1-values.yaml └── release2-values.yaml ``` -------------------------------- ### Flux Image Automation for Frontend Podinfo Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This configuration sets up Flux CD's image automation to monitor the OCI repository for 'frontend-podinfo' chart updates. It uses ImageRepository to specify the image source and interval, and ImagePolicy to define the semver version range for updates. ```yaml apiVersion: image.toolkit.fluxcd.io/v1 kind: ImageRepository metadata: name: frontend-podinfo spec: image: "ghcr.io/stefanprodan/charts/podinfo" interval: 10m provider: generic --- apiVersion: image.toolkit.fluxcd.io/v1 kind: ImagePolicy metadata: name: frontend-podinfo spec: imageRepositoryRef: name: frontend-podinfo policy: semver: range: ">=1.0.0" ``` -------------------------------- ### Deploy Frontend App with Flux HelmRelease Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt Defines an OCIRepository for a frontend application's Helm chart and a corresponding HelmRelease to manage its deployment. It configures service monitors and ingress with environment-specific hostnames. ```yaml apiVersion: source.toolkit.fluxcd.io/v1 kind: OCIRepository metadata: name: podinfo-chart spec: interval: 1h url: oci://ghcr.io/stefanprodan/charts/podinfo ref: semver: 6.9.3 # {"$imagepolicy": "apps:frontend-podinfo:tag"} --- apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: name: podinfo spec: releaseName: podinfo chartRef: kind: OCIRepository name: podinfo-chart interval: 50m driftDetection: mode: enabled install: timeout: 10m remediation: retries: 3 upgrade: timeout: 10m values: serviceMonitor: enabled: true interval: 60s additionalLabels: app.kubernetes.io/component: monitoring ingress: enabled: true className: nginx hosts: - host: podinfo.${CLUSTER_DOMAIN} paths: - path: / pathType: ImplementationSpecific ``` -------------------------------- ### Flux Image Automation for Backend Redis Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This configuration enables Flux CD's image automation for the 'backend-redis' chart. It defines the OCI repository to monitor and sets a semver policy to track version updates. The configuration uses ImageRepository and ImagePolicy resources. ```yaml apiVersion: image.toolkit.fluxcd.io/v1 kind: ImageRepository metadata: name: backend-redis spec: image: "registry-1.docker.io/bitnamicharts/redis" interval: 12h provider: generic --- apiVersion: image.toolkit.fluxcd.io/v1 kind: ImagePolicy metadata: name: backend-redis spec: imageRepositoryRef: name: backend-redis policy: semver: range: ">=1.0.0" ``` -------------------------------- ### Deploy Backend Redis with Flux HelmRelease Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt Defines an OCIRepository for the Redis Helm chart and a HelmRelease for deploying Redis with StatefulSet configurations and persistence settings. It includes specific image configurations for Redis and Sentinel. ```yaml apiVersion: source.toolkit.fluxcd.io/v1 kind: OCIRepository metadata: name: redis-chart spec: interval: 1h url: oci://registry-1.docker.io/bitnamicharts/redis ref: semver: 24.0.0 # {"$imagepolicy": "apps:backend-redis:tag"} --- apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: name: redis spec: releaseName: redis chartRef: kind: OCIRepository name: redis-chart interval: 50m driftDetection: mode: disabled install: timeout: 10m remediation: retries: 3 upgrade: timeout: 10m values: master: kind: StatefulSet persistence: enabled: false replica: kind: StatefulSet replicaCount: 1 persistence: enabled: false global: security: allowInsecureImages: true image: repository: bitnamilegacy/redis sentinel: image: repository: bitnamilegacy/redis-sentinel ``` -------------------------------- ### Deploy Backend Memcached with Flux HelmRelease Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt Defines an OCIRepository for the Memcached Helm chart and a HelmRelease for deploying Memcached. It includes configurations for cluster domain, security settings, and specific image repositories for Memcached and its metrics exporter. ```yaml apiVersion: source.toolkit.fluxcd.io/v1 kind: OCIRepository metadata: name: memcached-chart spec: interval: 1h url: oci://registry-1.docker.io/bitnamicharts/memcached ref: semver: 8.1.5 # {"$imagepolicy": "apps:backend-memcached:tag"} --- apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: name: memcached spec: releaseName: memcached chartRef: kind: OCIRepository name: memcached-chart interval: 50m driftDetection: mode: disabled install: timeout: 10m remediation: retries: 3 upgrade: timeout: 10m values: clusterDomain: cluster.local global: security: allowInsecureImages: true image: repository: bitnamilegacy/memcached metrics: image: repository: bitnamilegacy/memcached-exporter ``` -------------------------------- ### HelmRelease with Custom Values for Podinfo in Production Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This HelmRelease manifest defines the deployment of the 'podinfo' application in the production environment with a specified replica count. It leverages Flux CD's Helm controller to manage the release. ```yaml apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: name: podinfo spec: values: replicaCount: 2 ``` -------------------------------- ### HelmRelease with Custom Resources for Redis in Production Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This HelmRelease manifest configures the 'redis' deployment in the production environment, specifying resource limits for memory and CPU for the master instance. It uses Flux CD's Helm controller. ```yaml apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: name: redis spec: values: master: resources: limits: memory: "128Mi" cpu: "500m" ``` -------------------------------- ### Automated Image Update Pull Requests (YAML) Source: https://context7.com/controlplaneio-fluxcd/d2-apps/llms.txt This workflow automatically creates pull requests from the `image-updates` branch when Flux detects new chart versions. It is triggered by `workflow_dispatch` or `create` events, specifically targeting the `image-updates` branch for creation events. It requires permissions for contents and pull-requests, and uses the `gh` CLI to create the pull request. ```yaml name: image-updates on: workflow_dispatch: create: jobs: pull-request: if: github.event_name != 'create' || github.ref_name == 'image-updates' runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Create Pull Request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REPO: ${{ github.repository }} GITHUB_REF: ${{ github.ref }} run: | gh pr create \ --repo=${GITHUB_REPO} \ --head=image-updates \ --base=main \ --fill-first ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.