Skip to content

Commit

Permalink
Add categories to GG CRDs (#5006)
Browse files Browse the repository at this point in the history
Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Jenny Shu <28537278+jenshu@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 3f99c52 commit 22e6f2c
Show file tree
Hide file tree
Showing 28 changed files with 171 additions and 14 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/pr-kubernetes-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,36 @@ jobs:
# NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture

test:
# Oct 3, 2024: 24 minutes
# Nov 14, 2024: 22 minutes
- cluster-name: 'cluster-one'
go-test-args: '-v -timeout=25m'
go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestK8sGateway$$/^Services$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$'
go-test-run-regex: '^TestK8sGateway$$/^RouteDelegation$$|^TestGlooctlGlooGatewayEdgeGateway$$|^TestGlooctlK8sGateway$$'

# Oct 10, 2024: 24 minutes
# Nov 14, 2024: 22 minutes
- cluster-name: 'cluster-two'
go-test-args: '-v -timeout=25m'
go-test-run-regex: '^TestK8sGatewayIstioRevision$$|^TestRevisionIstioRegression$$|^TestK8sGateway$$/^Deployer$$|^TestK8sGateway$$/^RouteOptions$$|^TestK8sGateway$$/^VirtualHostOptions$$|^TestK8sGateway$$/^Upstreams$$|^TestK8sGateway$$/^HeadlessSvc$$|^TestK8sGateway$$/^PortRouting$$|^TestK8sGatewayMinimalDefaultGatewayParameters$$|^TestK8sGateway$$/^DirectResponse$$|^TestK8sGateway$$/^HttpListenerOptions$$|^TestK8sGateway$$/^ListenerOptions$$|^TestK8sGateway$$/^GlooAdminServer$$'

# Oct 3, 2024: 25 minutes
# Nov 14, 2024: 23 minutes
- cluster-name: 'cluster-three'
go-test-args: '-v -timeout=30m'
go-test-run-regex: '(^TestK8sGatewayIstioAutoMtls$$|^TestAutomtlsIstioEdgeApisGateway$$|^TestIstioEdgeApiGateway$$|^TestIstioRegression$$)'

# Oct 10, 2024: 20 minutes
# Nov 14, 2024: 21 minutes
- cluster-name: 'cluster-four'
go-test-args: '-v -timeout=30m'
go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)'

# October 10, 2024: 22 minutes
# Nov 14, 2024: 30 minutes
# TODO (sheidkamp) rebalance tests
- cluster-name: 'cluster-five'
go-test-args: '-v -timeout=35m'
go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$'

# October 10, 2024: 12 minutes
# Nov 14, 2024: 23 minutes
- cluster-name: 'cluster-six'
go-test-args: '-v -timeout=25m'
go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$'
go-test-run-regex: '^TestDiscoveryWatchlabels$$|^TestK8sGatewayNoValidation$$|^TestHelm$$|^TestHelmSettings$$|^TestK8sGatewayAws$$|^TestK8sGateway$$/^CRDCategories$$|^TestK8sGateway$$/^HTTPRouteServices$$|^TestK8sGateway$$/^TCPRouteServices$$'

# In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support
# The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/
Expand Down
5 changes: 5 additions & 0 deletions changelog/v1.18.0-beta35/GG-CRD-categories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: NEW_FEATURE
description: Adds a common category to all Gloo Gateway CRDs. `kubectl get gloo-gateway -A` can now be used to list all GG CRs on your cluster. Also adds the "solo-io" category to GG enterprise CRDs.
issueLink: https://github.com/solo-io/solo-projects/issues/6605
resolvesIssue: false
4 changes: 3 additions & 1 deletion devel/testing/kube-e2e-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ These tests are run by a [GitHub action](/.github/workflows/regression-tests.yam
If a test fails, you can retry it from a [browser window](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#reviewing-previous-workflow-runs). If you do this, please make sure to comment on the Pull Request with a link to the failed logs for debugging purposes.

## Local Development
See the [kube2e test README](/test/kube2e/README.md) for more details about running these tests.
See the [kubernetes e2e test README](/test/kubernetes/e2e/README.md) and [debugging guide](/test/kubernetes/e2e/debugging.md) for more details about running these tests.

See the [kube2e test README](/test/kube2e/README.md) for more details about running the legacy tests.
3 changes: 3 additions & 0 deletions install/helm/gloo/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
# generator files
*.go
generate/

# READMEs
README.md
10 changes: 10 additions & 0 deletions install/helm/gloo/crds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The CRDs in this directory are partially generated by solo-kit.
That implementation is explained [here](https://github.com/solo-io/solo-kit/tree/main/pkg/code-generator/schemagen#implementation).

It is worth noting that solo-kit only generates the schemas for these CRDs.
Other spec fields such as the `categories` can be updated manually.

Gloo Gateway CRD `categories`:
- All Gloo Gateway CRDs should include the "gloo-gateway" category.
- Any Gloo Gateway CRDs which are only used by enterprise customers should additionally include the "solo-io" category.
- Currently, these are the AuthConfig, RateLimitConfig, and GraphQLApi CRDs.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
spec:
group: enterprise.gloo.solo.io
names:
categories:
- solo-io
- gloo-gateway
kind: AuthConfig
listKind: AuthConfigList
plural: authconfigs
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_Gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: Gateway
listKind: GatewayList
plural: gateways
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: HttpListenerOption
listKind: HttpListenerOptionList
plural: httplisteneroptions
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_ListenerOption.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: ListenerOption
listKind: ListenerOptionList
plural: listeneroptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: MatchableHttpGateway
listKind: MatchableHttpGatewayList
plural: httpgateways
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: MatchableTcpGateway
listKind: MatchableTcpGatewayList
plural: tcpgateways
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_RouteOption.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: RouteOption
listKind: RouteOptionList
plural: routeoptions
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_RouteTable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: RouteTable
listKind: RouteTableList
plural: routetables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: VirtualHostOption
listKind: VirtualHostOptionList
plural: virtualhostoptions
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_VirtualService.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gateway.solo.io
names:
categories:
- gloo-gateway
kind: VirtualService
listKind: VirtualServiceList
plural: virtualservices
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gloo.solo.io_v1_Proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gloo.solo.io
names:
categories:
- gloo-gateway
kind: Proxy
listKind: ProxyList
plural: proxies
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gloo.solo.io_v1_Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ metadata:
spec:
group: gloo.solo.io
names:
categories:
- gloo-gateway
kind: Settings
listKind: SettingsList
plural: settings
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gloo.solo.io_v1_Upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gloo.solo.io
names:
categories:
- gloo-gateway
kind: Upstream
listKind: UpstreamList
plural: upstreams
Expand Down
2 changes: 2 additions & 0 deletions install/helm/gloo/crds/gloo.solo.io_v1_UpstreamGroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
spec:
group: gloo.solo.io
names:
categories:
- gloo-gateway
kind: UpstreamGroup
listKind: UpstreamGroupList
plural: upstreamgroups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
spec:
group: graphql.gloo.solo.io
names:
categories:
- solo-io
- gloo-gateway
kind: GraphQLApi
listKind: GraphQLApiList
plural: graphqlapis
Expand Down
3 changes: 3 additions & 0 deletions install/helm/gloo/crds/ratelimit_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
spec:
group: ratelimit.solo.io
names:
categories:
- solo-io
- gloo-gateway
kind: RateLimitConfig
listKind: RateLimitConfigList
plural: ratelimitconfigs
Expand Down
3 changes: 3 additions & 0 deletions test/kube2e/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> [!NOTE]
> This directory houses legacy tests. All new tests should instead be added to the `test/kubernetes/e2e` directory.
# Kubernetes End-to-End tests
See the [developer kube-e2e testing guide](/devel/testing/kube-e2e-tests.md) for more information about the philosophy of these tests.

Expand Down
54 changes: 54 additions & 0 deletions test/kubernetes/e2e/features/crd_categories/suite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package crd_categories

import (
"bytes"
"context"
"io"
"strings"

"github.com/solo-io/gloo/test/kubernetes/e2e"
"github.com/solo-io/gloo/test/kubernetes/e2e/features/helm"
"github.com/stretchr/testify/suite"
)

var _ e2e.NewSuiteFunc = NewTestingSuite

type testingSuite struct {
suite.Suite
ctx context.Context
ti *e2e.TestInstallation
}

func NewTestingSuite(
ctx context.Context,
testInst *e2e.TestInstallation,
) suite.TestingSuite {
return &testingSuite{
ctx: ctx,
ti: testInst,
}
}

func (s *testingSuite) SetupSuite() {
err := s.ti.Actions.Kubectl().ApplyFile(s.ctx, emptyVsManifest)
s.NoError(err, "can apply manifest "+emptyVsManifest)
}

func (s *testingSuite) TearDownSuite() {
output, err := s.ti.Actions.Kubectl().DeleteFileWithOutput(s.ctx, emptyVsManifest)
s.ti.Assertions.ExpectObjectDeleted(emptyVsManifest, err, output)
}

// See TestApplyCRDs() helm test for a future-proofed common category test,
// which ensures all CRDs in our helm chart include the gloo-gateway category.
// This test uses one of those CRs to assert that the resulting end user experience is as desired.
func (s *testingSuite) TestCommonCategory() {
cmd := s.ti.Actions.Kubectl().Command(s.ctx, "get", helm.CommonCRDCategory, "-o", "name")

var out bytes.Buffer
err := cmd.WithStdout(io.Writer(&out)).Run().Cause()
s.NoError(err)

// output should match the installed VS
s.Equal(strings.TrimSpace(out.String()), installedVs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: empty-virtualservice
spec: {}
13 changes: 13 additions & 0 deletions test/kubernetes/e2e/features/crd_categories/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package crd_categories

import (
"path/filepath"

"github.com/solo-io/skv2/codegen/util"
)

var (
emptyVsManifest = filepath.Join(util.MustGetThisDir(), "testdata/manifests", "empty-virtualservice.yaml")

installedVs = "virtualservice.gateway.solo.io/empty-virtualservice"
)
26 changes: 21 additions & 5 deletions test/kubernetes/e2e/features/helm/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package helm
import (
"bytes"
"context"
"encoding/json"
"io"
"os"
"path/filepath"
"strings"
"slices"
"time"

"github.com/rotisserie/eris"
"github.com/stretchr/testify/suite"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

Expand Down Expand Up @@ -51,7 +53,7 @@ func (s *testingSuite) TestChangedConfigMapTriggersRollout() {
err = adminCli.ConfigDumpCmd(s.Ctx, nil).WithStdout(dump).Run().Cause()
s.NoError(err)

strings.Contains(b.String(), str)
s.Contains(b.String(), str)
}

getChecksum := func() string {
Expand Down Expand Up @@ -81,14 +83,14 @@ func (s *testingSuite) TestApplyCRDs() {
if err != nil {
return err
}
if info.IsDir() {
if info.IsDir() || info.Name() == "README.md" {
return nil
}

// Parse the file, and extract the CRD
// Parse the file, and extract the CRD- will fail for any non-yaml files or files not containing a CRD
crd, err := schemagen.GetCRDFromFile(crdFile)
if err != nil {
return err
return eris.Wrap(err, "error getting CRD from "+crdFile)
}
crdsByFileName[crdFile] = crd

Expand All @@ -106,6 +108,20 @@ func (s *testingSuite) TestApplyCRDs() {
out, _, err := s.TestHelper.Execute(s.Ctx, "get", "crd", crd.GetName())
s.NoError(err)
s.Contains(out, crd.GetName())

// Ensure the CRD has the gloo-gateway category
out, _, err = s.TestHelper.Execute(s.Ctx, "get", "crd", crd.GetName(), "-o", "json")
s.NoError(err)

var crdJson v1.CustomResourceDefinition
s.NoError(json.Unmarshal([]byte(out), &crdJson))
s.Contains(crdJson.Spec.Names.Categories, CommonCRDCategory)

// Ensure the CRD has the solo-io category iff it's an enterprise CRD
s.Equal(
slices.Contains(enterpriseCRDs, crd.GetName()),
slices.Contains(crdJson.Spec.Names.Categories, enterpriseCRDCategory),
)
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/kubernetes/e2e/features/helm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ var (
},
},
}

enterpriseCRDCategory = "solo-io"
CommonCRDCategory = "gloo-gateway"

enterpriseCRDs = []string{
"authconfigs.enterprise.gloo.solo.io",
"ratelimitconfigs.ratelimit.solo.io",
"graphqlapis.graphql.gloo.solo.io",
}
)
Loading

0 comments on commit 22e6f2c

Please sign in to comment.