From d854b02dcb7679a80ccd44a3fa15cda94ae0b101 Mon Sep 17 00:00:00 2001 From: "David L. Chandler" Date: Fri, 5 Dec 2025 01:40:33 -0500 Subject: [PATCH] releases: Adds `make build-crds-yaml` This paves the way for supporting not just helm for CRD installation but `kubectl apply --server-side -f`. The single YAML file created by the new `make` target would have to be uploaded as an artifact on each Github Release. This was inspired by the release process used by https://github.com/kubernetes-sigs/gateway-api. Verified against the current helm chart by `diff <(go tool helm template install/helm/kgateway-crds) /Users/davidchandler/k_release-has-yaml-artifacts-for-crds/_output/release/kgateway-crds.yaml` Signed-off-by: David L. Chandler --- Makefile | 4 ++ hack/boilerplate/boilerplate.yaml.txt | 13 ++++++ hack/build-crds-yaml.sh | 59 +++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 hack/boilerplate/boilerplate.yaml.txt create mode 100755 hack/build-crds-yaml.sh diff --git a/Makefile b/Makefile index c0a6ed1fdbc..d9c097b4acd 100644 --- a/Makefile +++ b/Makefile @@ -645,6 +645,10 @@ lint-kgateway-charts: ## Lint the kgateway charts $(HELM) lint $(HELM_CHART_DIR) $(HELM) lint $(HELM_CHART_DIR_CRD) +.PHONY: build-crds-yaml +build-crds-yaml: $(STAMP_DIR)/go-generate-apis ## Generate a single YAML file containing all kgateway CRDs suitable for use as a release artifact + ./hack/build-crds-yaml.sh + #---------------------------------------------------------------------------------- # Release #---------------------------------------------------------------------------------- diff --git a/hack/boilerplate/boilerplate.yaml.txt b/hack/boilerplate/boilerplate.yaml.txt new file mode 100644 index 00000000000..e26de0b84de --- /dev/null +++ b/hack/boilerplate/boilerplate.yaml.txt @@ -0,0 +1,13 @@ +# Copyright YEAR The Kgateway Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/hack/build-crds-yaml.sh b/hack/build-crds-yaml.sh new file mode 100755 index 00000000000..f971bc15980 --- /dev/null +++ b/hack/build-crds-yaml.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# This script generates a single YAML file containing all kgateway CRDs for +# easy installation without Helm. +# +# Helm has a 1MiB size limitation on its HELM_DRIVER Secret that makes it +# suboptimal for CRDs even if they are in their own chart in the templates/ +# directory. + +set -o errexit +set -o nounset +set -o pipefail + +readonly SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)" +readonly CRD_DIR="${SCRIPT_ROOT}/install/helm/kgateway-crds/templates" +readonly OUTPUT_DIR="${SCRIPT_ROOT}/_output/release" +readonly OUTPUT_FILE="${OUTPUT_DIR}/kgateway-crds.yaml" +readonly YEAR=$(date +"%Y") + +mkdir -p "${OUTPUT_DIR}" + +# Start with the boilerplate +cat "${SCRIPT_ROOT}/hack/boilerplate/boilerplate.yaml.txt" > "${OUTPUT_FILE}" + +# Replace YEAR placeholder with actual year +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sed -i "s/YEAR/${YEAR}/g" "${OUTPUT_FILE}" +elif [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s/YEAR/${YEAR}/g" "${OUTPUT_FILE}" +else + echo "Unsupported OS: $OSTYPE" + exit 1 +fi + +# Add header comment +cat << EOF >> "${OUTPUT_FILE}" +# +# kgateway CRDs install +# +# This file contains all CustomResourceDefinitions for kgateway. +# To install: kubectl apply --server-side -f kgateway-crds.yaml +# +EOF + +# Append each CRD file +for file in "${CRD_DIR}"/*.yaml; do + # Skip non-CRD files like NOTES.txt (though it's .txt so won't match) + if [[ ! -f "$file" ]]; then + continue + fi + + echo "---" >> "${OUTPUT_FILE}" + echo "#" >> "${OUTPUT_FILE}" + echo "# Source: ${file#${SCRIPT_ROOT}/}" >> "${OUTPUT_FILE}" + echo "#" >> "${OUTPUT_FILE}" + cat "$file" >> "${OUTPUT_FILE}" +done + +echo "Generated: ${OUTPUT_FILE}"