weaveworks / weave-gitops-enterprise

This repo provides the enterprise level features for the weave-gitops product, including CAPI cluster creation and team workspaces.
https://docs.gitops.weave.works/
Apache License 2.0
160 stars 29 forks source link

Spike: explore policy packing using OCI #3533

Closed waleedhammam closed 11 months ago

waleedhammam commented 12 months ago

Goal: explore policy packing using OCI, disribution

Samra10 commented 11 months ago

Step 1: Create a Local Directory with YAML Files

mkdir policies-pack
cd policies-pack
# Put the policies YAML files here

Step 2: Create a Dockerfile

In the same directory, create a Dockerfile that copies the YAML files into the image.

# Use a minimal base image
FROM alpine

# Set working directory
WORKDIR /app

# Copy YAML files into the image
COPY ./*.yaml /app/

Step 3: Build the Docker Image

Run the following command to build a Docker image from the directory containing your YAML files and the Dockerfile:

docker build -t ghcr.io/your-username/your-repo:your-tag .

Step 4: Push the Image to GitHub Container Registry

docker push ghcr.io/your-username/your-repo:your-tag

Step 5: Creat OCIRepository

Create an OCIRepository on your Git repo so flux can reconcile it.

apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: OCIRepository
metadata:
  name: wge-policy-pack-1
  namespace: flux-system
spec:
  interval: 5m0s
  url: oci://ghcr.io/samra10/wge-dev
  ref:
    tag: v0.0.2

Step 6: Verify Flux reconciliation and Artifact creation

After Flux reconcile, OCI repo should be added to the Sources:- Private Zenhub Image

And the Artifacts could be created successfully Private Zenhub Image

run the following command to make sure the artifacts created successfully

kubectl describe ocirepositories.source.toolkit.fluxcd.io -n flux-system wge-policy-pack-1 

Private Zenhub Image