Skip to content

Commit 22e6f2c

Browse files
arianaw66soloio-bulldozer[bot]jenshu
authored
Add categories to GG CRDs (#5006)
Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Jenny Shu <[email protected]>
1 parent 3f99c52 commit 22e6f2c

28 files changed

+171
-14
lines changed

.github/workflows/pr-kubernetes-tests.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,36 @@ jobs:
5555
# NOTE: We use the GitHub action step time (as opposed to the `go test` time), because it is easier to capture
5656

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

63-
# Oct 10, 2024: 24 minutes
63+
# Nov 14, 2024: 22 minutes
6464
- cluster-name: 'cluster-two'
6565
go-test-args: '-v -timeout=25m'
6666
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$$'
6767

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

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

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

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

8989
# In our PR tests, we run the suite of tests using the upper ends of versions that we claim to support
9090
# The versions should mirror: https://docs.solo.io/gloo-edge/latest/reference/support/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
- type: NEW_FEATURE
3+
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.
4+
issueLink: https://github.com/solo-io/solo-projects/issues/6605
5+
resolvesIssue: false

devel/testing/kube-e2e-tests.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ These tests are run by a [GitHub action](/.github/workflows/regression-tests.yam
2222
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.
2323

2424
## Local Development
25-
See the [kube2e test README](/test/kube2e/README.md) for more details about running these tests.
25+
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.
26+
27+
See the [kube2e test README](/test/kube2e/README.md) for more details about running the legacy tests.

install/helm/gloo/.helmignore

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
# generator files
2929
*.go
3030
generate/
31+
32+
# READMEs
33+
README.md

install/helm/gloo/crds/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The CRDs in this directory are partially generated by solo-kit.
2+
That implementation is explained [here](https://github.com/solo-io/solo-kit/tree/main/pkg/code-generator/schemagen#implementation).
3+
4+
It is worth noting that solo-kit only generates the schemas for these CRDs.
5+
Other spec fields such as the `categories` can be updated manually.
6+
7+
Gloo Gateway CRD `categories`:
8+
- All Gloo Gateway CRDs should include the "gloo-gateway" category.
9+
- Any Gloo Gateway CRDs which are only used by enterprise customers should additionally include the "solo-io" category.
10+
- Currently, these are the AuthConfig, RateLimitConfig, and GraphQLApi CRDs.

install/helm/gloo/crds/enterprise.gloo.solo.io_v1_AuthConfig.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ metadata:
88
spec:
99
group: enterprise.gloo.solo.io
1010
names:
11+
categories:
12+
- solo-io
13+
- gloo-gateway
1114
kind: AuthConfig
1215
listKind: AuthConfigList
1316
plural: authconfigs

install/helm/gloo/crds/gateway.solo.io_v1_Gateway.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: Gateway
1214
listKind: GatewayList
1315
plural: gateways

install/helm/gloo/crds/gateway.solo.io_v1_HttpListenerOption.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: HttpListenerOption
1214
listKind: HttpListenerOptionList
1315
plural: httplisteneroptions

install/helm/gloo/crds/gateway.solo.io_v1_ListenerOption.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: ListenerOption
1214
listKind: ListenerOptionList
1315
plural: listeneroptions

install/helm/gloo/crds/gateway.solo.io_v1_MatchableHttpGateway.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: MatchableHttpGateway
1214
listKind: MatchableHttpGatewayList
1315
plural: httpgateways

install/helm/gloo/crds/gateway.solo.io_v1_MatchableTcpGateway.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: MatchableTcpGateway
1214
listKind: MatchableTcpGatewayList
1315
plural: tcpgateways

install/helm/gloo/crds/gateway.solo.io_v1_RouteOption.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: RouteOption
1214
listKind: RouteOptionList
1315
plural: routeoptions

install/helm/gloo/crds/gateway.solo.io_v1_RouteTable.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: RouteTable
1214
listKind: RouteTableList
1315
plural: routetables

install/helm/gloo/crds/gateway.solo.io_v1_VirtualHostOption.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: VirtualHostOption
1214
listKind: VirtualHostOptionList
1315
plural: virtualhostoptions

install/helm/gloo/crds/gateway.solo.io_v1_VirtualService.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gateway.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: VirtualService
1214
listKind: VirtualServiceList
1315
plural: virtualservices

install/helm/gloo/crds/gloo.solo.io_v1_Proxy.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gloo.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: Proxy
1214
listKind: ProxyList
1315
plural: proxies

install/helm/gloo/crds/gloo.solo.io_v1_Settings.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ metadata:
1010
spec:
1111
group: gloo.solo.io
1212
names:
13+
categories:
14+
- gloo-gateway
1315
kind: Settings
1416
listKind: SettingsList
1517
plural: settings

install/helm/gloo/crds/gloo.solo.io_v1_Upstream.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gloo.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: Upstream
1214
listKind: UpstreamList
1315
plural: upstreams

install/helm/gloo/crds/gloo.solo.io_v1_UpstreamGroup.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ metadata:
88
spec:
99
group: gloo.solo.io
1010
names:
11+
categories:
12+
- gloo-gateway
1113
kind: UpstreamGroup
1214
listKind: UpstreamGroupList
1315
plural: upstreamgroups

install/helm/gloo/crds/graphql.gloo.solo.io_v1beta1_GraphQLApi.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ metadata:
88
spec:
99
group: graphql.gloo.solo.io
1010
names:
11+
categories:
12+
- solo-io
13+
- gloo-gateway
1114
kind: GraphQLApi
1215
listKind: GraphQLApiList
1316
plural: graphqlapis

install/helm/gloo/crds/ratelimit_config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ metadata:
55
spec:
66
group: ratelimit.solo.io
77
names:
8+
categories:
9+
- solo-io
10+
- gloo-gateway
811
kind: RateLimitConfig
912
listKind: RateLimitConfigList
1013
plural: ratelimitconfigs

test/kube2e/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
> [!NOTE]
2+
> This directory houses legacy tests. All new tests should instead be added to the `test/kubernetes/e2e` directory.
3+
14
# Kubernetes End-to-End tests
25
See the [developer kube-e2e testing guide](/devel/testing/kube-e2e-tests.md) for more information about the philosophy of these tests.
36

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package crd_categories
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"io"
7+
"strings"
8+
9+
"github.com/solo-io/gloo/test/kubernetes/e2e"
10+
"github.com/solo-io/gloo/test/kubernetes/e2e/features/helm"
11+
"github.com/stretchr/testify/suite"
12+
)
13+
14+
var _ e2e.NewSuiteFunc = NewTestingSuite
15+
16+
type testingSuite struct {
17+
suite.Suite
18+
ctx context.Context
19+
ti *e2e.TestInstallation
20+
}
21+
22+
func NewTestingSuite(
23+
ctx context.Context,
24+
testInst *e2e.TestInstallation,
25+
) suite.TestingSuite {
26+
return &testingSuite{
27+
ctx: ctx,
28+
ti: testInst,
29+
}
30+
}
31+
32+
func (s *testingSuite) SetupSuite() {
33+
err := s.ti.Actions.Kubectl().ApplyFile(s.ctx, emptyVsManifest)
34+
s.NoError(err, "can apply manifest "+emptyVsManifest)
35+
}
36+
37+
func (s *testingSuite) TearDownSuite() {
38+
output, err := s.ti.Actions.Kubectl().DeleteFileWithOutput(s.ctx, emptyVsManifest)
39+
s.ti.Assertions.ExpectObjectDeleted(emptyVsManifest, err, output)
40+
}
41+
42+
// See TestApplyCRDs() helm test for a future-proofed common category test,
43+
// which ensures all CRDs in our helm chart include the gloo-gateway category.
44+
// This test uses one of those CRs to assert that the resulting end user experience is as desired.
45+
func (s *testingSuite) TestCommonCategory() {
46+
cmd := s.ti.Actions.Kubectl().Command(s.ctx, "get", helm.CommonCRDCategory, "-o", "name")
47+
48+
var out bytes.Buffer
49+
err := cmd.WithStdout(io.Writer(&out)).Run().Cause()
50+
s.NoError(err)
51+
52+
// output should match the installed VS
53+
s.Equal(strings.TrimSpace(out.String()), installedVs)
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: gateway.solo.io/v1
2+
kind: VirtualService
3+
metadata:
4+
name: empty-virtualservice
5+
spec: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package crd_categories
2+
3+
import (
4+
"path/filepath"
5+
6+
"github.com/solo-io/skv2/codegen/util"
7+
)
8+
9+
var (
10+
emptyVsManifest = filepath.Join(util.MustGetThisDir(), "testdata/manifests", "empty-virtualservice.yaml")
11+
12+
installedVs = "virtualservice.gateway.solo.io/empty-virtualservice"
13+
)

test/kubernetes/e2e/features/helm/suite.go

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ package helm
33
import (
44
"bytes"
55
"context"
6+
"encoding/json"
67
"io"
78
"os"
89
"path/filepath"
9-
"strings"
10+
"slices"
1011
"time"
1112

13+
"github.com/rotisserie/eris"
1214
"github.com/stretchr/testify/suite"
1315
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1416

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

54-
strings.Contains(b.String(), str)
56+
s.Contains(b.String(), str)
5557
}
5658

5759
getChecksum := func() string {
@@ -81,14 +83,14 @@ func (s *testingSuite) TestApplyCRDs() {
8183
if err != nil {
8284
return err
8385
}
84-
if info.IsDir() {
86+
if info.IsDir() || info.Name() == "README.md" {
8587
return nil
8688
}
8789

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

@@ -106,6 +108,20 @@ func (s *testingSuite) TestApplyCRDs() {
106108
out, _, err := s.TestHelper.Execute(s.Ctx, "get", "crd", crd.GetName())
107109
s.NoError(err)
108110
s.Contains(out, crd.GetName())
111+
112+
// Ensure the CRD has the gloo-gateway category
113+
out, _, err = s.TestHelper.Execute(s.Ctx, "get", "crd", crd.GetName(), "-o", "json")
114+
s.NoError(err)
115+
116+
var crdJson v1.CustomResourceDefinition
117+
s.NoError(json.Unmarshal([]byte(out), &crdJson))
118+
s.Contains(crdJson.Spec.Names.Categories, CommonCRDCategory)
119+
120+
// Ensure the CRD has the solo-io category iff it's an enterprise CRD
121+
s.Equal(
122+
slices.Contains(enterpriseCRDs, crd.GetName()),
123+
slices.Contains(crdJson.Spec.Names.Categories, enterpriseCRDCategory),
124+
)
109125
}
110126
}
111127

test/kubernetes/e2e/features/helm/types.go

+9
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ var (
1818
},
1919
},
2020
}
21+
22+
enterpriseCRDCategory = "solo-io"
23+
CommonCRDCategory = "gloo-gateway"
24+
25+
enterpriseCRDs = []string{
26+
"authconfigs.enterprise.gloo.solo.io",
27+
"ratelimitconfigs.ratelimit.solo.io",
28+
"graphqlapis.graphql.gloo.solo.io",
29+
}
2130
)

0 commit comments

Comments
 (0)