Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Add dedicated CRD helm chart #10828

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ runs:
run: |
if [[ -z "${{ matrix.version }}" ]]; then
# If matrix.version is empty, use the local chart path specified in the Makefile.
helm upgrade -i -n kgateway-system kgateway-crds ./install/helm/kgateway-crds/ \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there advantages of doing it as a separate chart (where we need to issue 2 separate install/upgrade/uninstall commands) vs. having the crd chart being a subchart of kgateway? if it's a subchart, we can guarantee the versions wouldn't get out of sync

--create-namespace
helm upgrade -i -n kgateway-system kgateway ./install/helm/kgateway/ \
--create-namespace \
--set image.tag=${VERSION} --set image.registry=ghcr.io/kgateway-dev
else
# TODO(tim): this will require changes once the new helm chart is integrated
# and published with the release pipeline.
# Else, use the provided version to install Gloo from the helm repository.
helm upgrade -i -n kgateway-system kgateway kgateway/kgateway --version ${VERSION} \
helm upgrade -i -n kgateway-system kgateway-crds oci://${{ env.IMAGE_REGISTRY }}/charts/kgateway-crds \
--version ${VERSION} \
--create-namespace
helm upgrade -i -n kgateway-system kgateway oci://${{ env.IMAGE_REGISTRY }}/charts/kgateway \
--version ${VERSION} \
--create-namespace \
--set image.tag=${VERSION}
fi
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin

- name: Lint kgateway chart on PRs
- name: Lint kgateway charts on PRs
if: ${{ github.event_name == 'pull_request' }}
run: helm lint install/helm/kgateway
run: make lint-kgateway-charts

- name: Package kgateway chart
run: make package-kgateway-chart
run: make package-kgateway-charts
env:
VERSION: ${{ needs.setup.outputs.version }}

- name: Push kgateway chart to registry
if: ${{ github.event_name != 'pull_request' }}
run: |
helm push _test/kgateway-${{ needs.setup.outputs.version }}.tgz oci://${{ env.IMAGE_REGISTRY }}/charts

helm push _test/kgateway-crds-${{ needs.setup.outputs.version }}.tgz oci://${{ env.IMAGE_REGISTRY }}/charts
goreleaser:
name: goreleaser
needs: [setup, helm]
Expand Down Expand Up @@ -167,6 +167,12 @@ jobs:

- name: Install the released chart
run: |
# install the crds first
helm install kgateway-crds oci://${{ env.IMAGE_REGISTRY }}/charts/kgateway-crds \
--version ${{ needs.setup.outputs.version }} \
--wait --timeout 5m

# install the main chart
helm install --create-namespace --namespace kgateway-system kgateway \
oci://${{ env.IMAGE_REGISTRY }}/charts/kgateway \
--set image.registry=${{ env.IMAGE_REGISTRY }} \
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ release:

Try installing this release:
```
helm install --create-namespace --namespace kgateway-system kgateway \
oci://{{ .Env.VANITY_REGISTRY }}/charts/kgateway --version {{ .Env.VERSION }}
helm install kgateway-crds oci://{{ .Env.VANITY_REGISTRY }}/charts/kgateway-crds --version {{ .Env.VERSION }} --namespace kgateway-system --create-namespace
helm install kgateway oci://{{ .Env.VANITY_REGISTRY }}/charts/kgateway --version {{ .Env.VERSION }} --namespace kgateway-system --create-namespace
```

For detailed installation instructions and next steps, please visit our [quickstart guide](https://kgateway.dev/docs/quickstart/).
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,31 @@ envoy-wrapper-distroless-docker: $(ENVOYINIT_OUTPUT_DIR)/envoyinit-linux-$(GOARC
# Helm
#----------------------------------------------------------------------------------

.PHONY: package-kgateway-chart
HELM ?= helm
HELM_PACKAGE_ARGS ?= --version $(VERSION)
package-kgateway-chart: ## Package the new kgateway helm chart for testing
HELM_CHART_DIR=install/helm/kgateway
HELM_CHART_DIR_CRD=install/helm/kgateway-crds

.PHONY: package-kgateway-charts
package-kgateway-charts: package-kgateway-chart package-kgateway-crd-chart

.PHONY: package-kgateway-chart
package-kgateway-chart: ## Package the kgateway chart for testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is this comment accurate w.r.t. "for testing"?
Looks like this is the target used in the release workflow as well

mkdir -p $(TEST_ASSET_DIR); \
$(HELM) package $(HELM_PACKAGE_ARGS) --destination $(TEST_ASSET_DIR) install/helm/kgateway; \
$(HELM) package $(HELM_PACKAGE_ARGS) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR); \
$(HELM) repo index $(TEST_ASSET_DIR);

.PHONY: package-kgateway-crd-chart
package-kgateway-crd-chart: ## Package the kgateway crd chart for testing
mkdir -p $(TEST_ASSET_DIR); \
$(HELM) package $(HELM_PACKAGE_ARGS) --destination $(TEST_ASSET_DIR) $(HELM_CHART_DIR_CRD); \
$(HELM) repo index $(TEST_ASSET_DIR);

.PHONY: lint-kgateway-charts
lint-kgateway-charts: ## Lint the kgateway charts
$(HELM) lint $(HELM_CHART_DIR)
$(HELM) lint $(HELM_CHART_DIR_CRD)

#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion hack/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ readonly VERSIONS=( v1alpha1 )
readonly OPENAPI_GEN_DIR=pkg/generated/openapi
readonly APPLY_CFG_DIR=api/applyconfiguration
readonly CLIENT_GEN_DIR=pkg/client
readonly CRD_DIR=install/helm/kgateway/crds
readonly CRD_DIR=install/helm/kgateway-crds/templates
# manifests dir only used for outputting rbac artifacts and existing file will be overwritten so no need to clean
readonly MANIFESTS_DIR=install/helm/kgateway/templates

Expand Down
2 changes: 1 addition & 1 deletion hack/kind/setup-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ else
VERSION=$VERSION CLUSTER_NAME=$CLUSTER_NAME IMAGE_VARIANT=$IMAGE_VARIANT make kind-build-and-load

# 3. Build the test helm chart, ensuring we have a chart in the `_test` folder
VERSION=$VERSION make package-kgateway-chart
VERSION=$VERSION make package-kgateway-charts
fi

# 4. Build the gloo command line tool, ensuring we have one in the `_output` folder
Expand Down
23 changes: 23 additions & 0 deletions install/helm/kgateway-crds/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions install/helm/kgateway-crds/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: kgateway-crds
description: A Helm chart for the kgateway project CRDs

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm missing something, but is this version relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's relevant, but we always provide a --version flag when publishing helm charts, so the chart version field is always set properly. CI either installs the locally packaged chart or the published version from the remote registry.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the value of this to be consistent with the kgateway chart.yaml. Just pushed that change in the most recent commit.


# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
1 change: 1 addition & 0 deletions install/helm/kgateway-crds/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default values for kgateway-crds.
2 changes: 1 addition & 1 deletion install/helm/kgateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: kgateway
description: A Helm chart for Kubernetes
description: A Helm chart for the kgateway project

# A chart can be either an 'application' or a 'library' chart.
#
Expand Down
2 changes: 1 addition & 1 deletion internal/kgateway/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = BeforeSuite(func() {
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("..", "crds"),
filepath.Join("..", "..", "..", "install", "helm", "kgateway", "crds"),
filepath.Join("..", "..", "..", "install", "helm", "kgateway-crds", "templates"),
},
ErrorIfCRDPathMissing: true,
// set assets dir so we can run without the makefile
Expand Down
2 changes: 1 addition & 1 deletion internal/kgateway/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func runScenario(t *testing.T, scenarioDir string, globalSettings *settings.Sett
testEnv := &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("..", "crds"),
filepath.Join("..", "..", "..", "install", "helm", "kgateway", "crds"),
filepath.Join("..", "..", "..", "install", "helm", "kgateway-crds", "templates"),
filepath.Join("testdata", "istiocrds"),
},
ErrorIfCRDPathMissing: true,
Expand Down
6 changes: 4 additions & 2 deletions pkg/utils/helmutils/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package helmutils

const (
ChartName = "kgateway"
ChartName = "kgateway"
CRDChartName = "kgateway-crds"

DefaultChartUri = "oci://ghcr.io/kgateway-dev/charts/kgateway"
DefaultChartUri = "oci://ghcr.io/kgateway-dev/charts/kgateway"
DefaultCRDChartUri = "oci://ghcr.io/kgateway-dev/charts/kgateway-crds"
)
33 changes: 30 additions & 3 deletions test/kubernetes/e2e/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,23 @@ func (i *TestInstallation) InstallKgatewayFromLocalChart(ctx context.Context) {
return
}

chartUri, err := helper.GetLocalChartPath(helmutils.ChartName)
// install the CRD chart first
crdChartURI, err := helper.GetLocalChartPath(helmutils.CRDChartName)
i.Assertions.Require.NoError(err)
err = i.Actions.Helm().WithReceiver(os.Stdout).Install(
ctx,
helmutils.InstallOpts{
CreateNamespace: true,
ReleaseName: helmutils.CRDChartName,
Namespace: i.Metadata.InstallNamespace,
ChartUri: crdChartURI,
})
i.Assertions.Require.NoError(err)

err = i.Actions.Helm().Install(
// and then install the main chart
chartUri, err := helper.GetLocalChartPath(helmutils.ChartName)
i.Assertions.Require.NoError(err)
err = i.Actions.Helm().WithReceiver(os.Stdout).Install(
ctx,
helmutils.InstallOpts{
Namespace: i.Metadata.InstallNamespace,
Expand All @@ -175,15 +188,29 @@ func (i *TestInstallation) UninstallKgateway(ctx context.Context) {
if testutils.ShouldSkipInstall() {
return
}

// uninstall the main chart first
err := i.Actions.Helm().Uninstall(
ctx,
helmutils.UninstallOpts{
Namespace: i.Metadata.InstallNamespace,
ReleaseName: helmutils.ChartName,
},
)
i.Assertions.Require.NoError(err)
i.Assertions.Require.NoError(err, "failed to uninstall main chart")
i.Assertions.EventuallyKgatewayUninstallSucceeded(ctx)

// uninstall the CRD chart
err = i.Actions.Helm().Uninstall(
ctx,
helmutils.UninstallOpts{
Namespace: i.Metadata.InstallNamespace,
ReleaseName: helmutils.CRDChartName,
},
)
i.Assertions.Require.NoError(err, "failed to uninstall CRD chart")

// TODO: Remove the namespace.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

}

// PreFailHandler is the function that is invoked if a test in the given TestInstallation fails
Expand Down