Custom Resource Definitions (CRDs) for Enterprise Contract Policies in Kubernetes environments.
The Enterprise Contract Policy CRD (EnterpriseContractPolicy) defines and configures Enterprise Contract policies for validating software supply chain security and compliance. This repository provides the CRD definitions, validation schemas, and tooling needed to work with Enterprise Contract policies in Kubernetes.
├── api/v1alpha1/ # CRD type definitions and generated code
├── config/ # Kubernetes manifests and examples
│ ├── crd/ # CRD installation manifests
│ └── samples/ # Example policy instances
├── schema/ # JSON schema generation
├── tools/ # Build dependencies
├── docs/ # Documentation generation
├── .github/workflows/ # CI/CD automation
└── Makefile # Build commands
Install the CRDs to your Kubernetes cluster:
make installOr manually apply the manifests:
kubectl apply -f config/crd/bases/appstudio.redhat.com_enterprisecontractpolicies.yamlCreate an Enterprise Contract Policy:
apiVersion: appstudio.redhat.com/v1alpha1
kind: EnterpriseContractPolicy
metadata:
name: my-policy
namespace: default
spec:
description: "My Enterprise Contract Policy"
sources:
- name: "default-policies"
policy:
- "git::https://github.com/enterprise-contract/ec-policies//policy/lib"
- "git::https://github.com/enterprise-contract/ec-policies//policy/release"
data:
- "git::https://github.com/enterprise-contract/ec-policies//data"
configuration:
exclude:
- "step_image_registries"
include:
- "attestation_type.slsa_provenance_02"- Go 1.23 or later
- Make
- kubectl (for cluster operations)
# Generate code and manifests
make generate
# Build (validate) CRDs
make build
# Run tests
make test
# Generate documentation
make docs
# Export JSON schema
make export-schema- Edit the CRD types in
api/v1alpha1/enterprisecontractpolicy_types.go - Run
make generateto update generated code and manifests - Run
make testto validate changes - Update documentation if needed
The repository uses separate Go modules for different components:
api/: Contains the CRD type definitions and core APIschema/: JSON schema generation utilitiestools/: Build tool dependencies (controller-gen, etc.)docs/: Documentation and example generation
Each module can be imported and developed independently.
The main CRD type in the appstudio.redhat.com/v1alpha1 API group.
spec.sources: Array of policy and data sources with configuration optionsspec.configuration: Global policy inclusions and exclusionsspec.identity: Keyless verification settings for Sigstorespec.publicKey: Public key for signature validationspec.rekorUrl: Rekor transparency log URL
Each source in spec.sources can specify:
policy: List of policy bundle URLs (required)data: List of data bundle URLsconfig: Source-specific include/exclude rulesruleData: Arbitrary data passed to policy rulesvolatileConfig: Time-based or image-specific rule configurations
sources:
- name: "release-policies"
policy:
- "git::https://github.com/enterprise-contract/ec-policies//policy/release?ref=v0.1.0"
data:
- "git::https://github.com/enterprise-contract/ec-policies//data?ref=v0.1.0"
config:
include:
- "attestation_type.slsa_provenance_02"
exclude:
- "step_image_registries"
ruleData:
allowed_registries:
- "registry.redhat.io"
- "quay.io/redhat-prod"The repository generates a JSON schema for the EnterpriseContractPolicySpec that can be used by external tools for validation and IDE support.
Export the schema:
make export-schemaThe schema will be available in dist/policy_spec.json.
The repository includes Kustomize configuration for easy deployment:
# Install CRDs
kustomize build config/crd | kubectl apply -f -
# Uninstall CRDs
kustomize build config/crd | kubectl delete -f -The repository includes ClusterRole definitions for managing Enterprise Contract Policies:
- Editor Role: Full read/write access to EnterpriseContractPolicy resources
- Viewer Role: Read-only access to EnterpriseContractPolicy resources
Apply the RBAC configurations as needed for your environment.
See the config/samples/ directory for example EnterpriseContractPolicy resources.
For OpenShift environments, see config/crd/openshift_console_example.yaml for console integration examples.
The repository includes GitHub Actions workflows:
- Checks: Runs tests, builds, and validates CRDs on pull requests
- Schema Publishing: Publishes the JSON schema to GitHub Pages
- Fork the repository
- Create a feature branch
- Make your changes
- Run
make testto ensure everything works - Submit a pull request
This repository uses Kubernetes code generation tools. After modifying CRD types:
- Run
make generateto update generated code - Run
make manifeststo update CRD manifests - Commit both the source changes and generated files
Licensed under the Apache License, Version 2.0. See LICENSE file for details.