Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#----------------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions hack/boilerplate/boilerplate.yaml.txt
Original file line number Diff line number Diff line change
@@ -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.
59 changes: 59 additions & 0 deletions hack/build-crds-yaml.sh
Original file line number Diff line number Diff line change
@@ -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}"
Loading