Skip to content

Latest commit

 

History

History
228 lines (164 loc) · 6.12 KB

CONTRIBUTING.md

File metadata and controls

228 lines (164 loc) · 6.12 KB

Contributing to HyperFleet Infrastructure

Development Setup

No build/compile steps. You need the right tools to work with Terraform, Helm, and Kubernetes.

# 1. Clone the repository
git clone https://github.com/openshift-hyperfleet/hyperfleet-infra.git
cd hyperfleet-infra

# 2. Install prerequisites
#    - helm + helm-git plugin + helmfile
#    - kubectl
#    - terraform 1.17.2 via asdf (GCP only)
#    - Google Cloud SDK + gke-gcloud-auth-plugin (GCP only)

# 3. Verify prerequisites
make check-helm
make check-helmfile
make check-kubectl
make check-kind # kind only
make check-terraform   # GCP only

# 4. For GCP: set up personal Terraform config files
cp terraform/envs/gke/dev.tfvars.example terraform/envs/gke/dev-<username>.tfvars
cp terraform/envs/gke/dev.tfbackend.example terraform/envs/gke/dev-<username>.tfbackend
# Set developer_name = "<username>" in tfvars
# Set prefix = "terraform/state/dev-<username>" in tfbackend

# 5. For GCP: authenticate
gcloud auth application-default login
gcloud config set project hcm-hyperfleet

Notes:

  • Personal tfvars/tfbackend are gitignored — never commit them
  • For kind deployments, Terraform setup is not required
  • NAMESPACE controls which Kubernetes namespace is used; set it to run parallel deployments on the same cluster
  • helm-git plugin is required for helm to pull charts from sibling repos
  • diff plugin is required for helmfile to show the change on upgrade

Environment Configuration Files

The Makefile auto-sources one of two env files based on HELMFILE_ENV:

  • HELMFILE_ENV=gcp and HELMFILE_ENV=e2e-gcp → sources env.gcp
  • HELMFILE_ENV=kind and HELMFILE_ENV=e2e-kind → sources env.kind

All variables use ?=. CLI overrides always win:

Example:

HELMFILE_ENV=kind NAMESPACE=my-namespace REGISTRY=quay.io make install-hyperfleet

Configuration precedence (highest to lowest):

  1. CLI variables
  2. env.gcp or env.kind
  3. Makefile defaults

Repository Structure

See Repository Structure in the README.

Validation and Testing

Run these before opening a PR:

CI Validation

make ci-validate     # terraform fmt+validate + lint checks
make ci-dry-run      # ci-validate + GKE network policy mode tests + render checks: network policies, namespace cleaner, desire delivery, fixture entities

Individual checks:

make validate-terraform            # terraform init (no backend) + fmt check + validate
make lint-helm                     # helm lint all charts under helm/*/
make lint-shellcheck               # shellcheck all *.sh
make validate-fixture-entities     # E2E fixture entities, Sentinels, adapter matching and isolation
HELMFILE_ENV=<env> make lint-helmfile
HELMFILE_ENV=<env> make template-helmfile   # dry-run render for one env

Common Development Tasks

Kind Deployment (local development)

export HELMFILE_ENV=kind
export NAMESPACE=hyperfleet-local

# Step by step installation
make create-kind-cluster
make install-kind-cilium
make generate-rabbitmq-values
make kind-build-images
make install-hyperfleet

# One-shot installation (image builds by default - BUILD_IMAGES set in env.kind)
make local-up-kind

E2E Tests on Kind

Port-forwarding required for E2E tests:

export NAMESPACE=<e2e_namespace>
kubectl port-forward -n $NAMESPACE svc/hyperfleet-gateway 8000:8000 &
export HYPERFLEET_API_URL=http://localhost:8000

Run tests

# Run tier0 tests
cd ../hyperfleet-e2e && make generate && make build && ./bin/hyperfleet-e2e test --label-filter=tier0

GKE Deployment (GCP)

export HELMFILE_ENV=gcp
export NAMESPACE=hyperfleet

# Step by step installation
make install-terraform
make get-credentials
make install-hyperfleet

# One-shot installation
make local-up-gcp

E2E Tests on GKE

Required Variables for E2E tests:

export API_EXTERNAL_IP=$(kubectl get svc hyperfleet-gateway -n $NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export HYPERFLEET_API_URL=http://${API_EXTERNAL_IP}:8000

Run tests

# Run tier0 tests
cd ../hyperfleet-e2e && make generate && make build && ./bin/hyperfleet-e2e test --label-filter=tier0

Customization

Using custom images

  • CLI Overrides for specific variables
  • Update env.* files with custom values
# CLI Overrides
REGISTRY=quay.io/$USER API_IMAGE_TAG=v0.2.0 HELMFILE_ENV=gcp make install-hyperfleet

API_IMAGE_TAG=dev-abc123 HELMFILE_ENV=kind make install-api

Building and loading images into kind

export HELMFILE_ENV=<env> # verify that BUILD_IMAGES ?= true in env.kind
make kind-build-images

# or CLI override
BUILD_IMAGES=true make kind-build-images

# or call the script directly:
PROJECTS_DIR=~/Code/openshift-hyperfleet REGISTRY=localhost ./scripts/kind-build-images.sh

Cleanup

kind / e2e-kind

export HELMFILE_ENV=kind # or HELMFILE_ENV=e2e-kind
export NAMESPACE=<namespace>

# for individual targets
make uninstall-hyperfleet
make delete-kind-cluster

# for full teardown
make local-down-kind

gcp / e2e-gcp

export HELMFILE_ENV=gcp # or HELMFILE_ENV=e2e-gcp
export NAMESPACE=<namespace>

# for individual targets
make uninstall-hyperfleet
make destroy-terraform

# for full teardown
make local-down-gcp

Commit Standards

Format: HYPERFLEET-XXX - <type>: <subject>

Types: feat, fix, docs, refactor, chore, test

Examples:

  • HYPERFLEET-761 - docs: add CONTRIBUTING.md
  • HYPERFLEET-123 - feat: add support for custom Helm chart refs
  • HYPERFLEET-456 - fix: correct RabbitMQ URL format in generated values

Full standard: https://github.com/openshift-hyperfleet/architecture/blob/main/hyperfleet/standards/commit-standard.md

Release Process

No semantic versioning. Infrastructure changes deploy from main after review and approval via OWNERS (Prow enforced).

  • Helm charts live in component repos (hyperfleet-api, hyperfleet-sentinel, hyperfleet-adapter) and are pulled via helm-git at deploy time
  • Terraform modules are versioned through git tags
  • Image tags default to latest (GCP) or local (kind); override with API_IMAGE_TAG, SENTINEL_IMAGE_TAG, ADAPTER_IMAGE_TAG