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

Make spec.envoyResources[*].name optional #152

Merged
merged 2 commits into from
Oct 24, 2022
Merged
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
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,27 @@ spec:
# Endpoints is a list of the Envoy ClusterLoadAssignment resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/endpoint/v3/endpoint.proto
endpoints:
- name: endpoint1
value: {"clusterName":"cluster1","endpoints":[{"lbEndpoints":[{"endpoint":{"address":{"socketAddress":{"address":"127.0.0.1","portValue":8080}}}}]}]}
- value: {"clusterName":"cluster1","endpoints":[{"lbEndpoints":[{"endpoint":{"address":{"socketAddress":{"address":"127.0.0.1","portValue":8080}}}}]}]}
# Clusters is a list of the Envoy Cluster resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto
clusters:
- name: cluster1
value: {"name":"cluster1","type":"STRICT_DNS","connectTimeout":"2s","loadAssignment":{"clusterName":"cluster1","endpoints":[]}}
- value: {"name":"cluster1","type":"STRICT_DNS","connectTimeout":"2s","loadAssignment":{"clusterName":"cluster1","endpoints":[]}}
# Routes is a list of the Envoy Route resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route.proto
routes:
- name: route1
value: {"name":"route1","virtual_hosts":[{"name":"vhost","domains":["*"],"routes":[{"match":{"prefix":"/"},"direct_response":{"status":200}}]}]}
- value: {"name":"route1","virtual_hosts":[{"name":"vhost","domains":["*"],"routes":[{"match":{"prefix":"/"},"direct_response":{"status":200}}]}]}
# ScopedRoutes is a list of the Envoy Scoped Route resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/scoped_route.proto
scopedRoutes:
- name: scoped_route1
value: {"name":"scoped_route1","route_configuration_name":"route1","key":{"fragments":[{"string_key":"test"}]}}
- value: {"name":"scoped_route1","route_configuration_name":"route1","key":{"fragments":[{"string_key":"test"}]}}
# Listeners is a list of the Envoy Listener resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener.proto
listeners:
- name: listener1
value: {"name":"listener1","address":{"socketAddress":{"address":"0.0.0.0","portValue":8443}}}
- value: {"name":"listener1","address":{"socketAddress":{"address":"0.0.0.0","portValue":8443}}}
# Runtimes is a list of the Envoy Runtime resource type.
# API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/runtime/v3/rtds.proto
runtimes:
- name: runtime1
value: {"name":"runtime1","layer":{"static_layer_0":"value"}}
- value: {"name":"runtime1","layer":{"static_layer_0":"value"}}
```

### **Secrets**
Expand Down
9 changes: 7 additions & 2 deletions apis/marin3r/v1alpha1/envoyconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ type EnvoyResources struct {
// EnvoyResource holds serialized representation of an envoy
// resource
type EnvoyResource struct {
// Name of the envoy resource
// Name of the envoy resource.
// DEPRECATED: this field has no effect and will be removed in an
// upcoming release. The name of the resources for discovery purposes
// is included in the resource itself. Refer to the envoy API reference
// to check how the name is specified for each resource type.
// +operator-sdk:csv:customresourcedefinitions:type=spec
Name string `json:"name"`
// +optional
Name *string `json:"name"`
// Value is the serialized representation of the envoy resource
// +operator-sdk:csv:customresourcedefinitions:type=spec
Value string `json:"value"`
Expand Down
4 changes: 2 additions & 2 deletions apis/marin3r/v1alpha1/envoyconfig_webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var _ = Describe("EnvoyConfig webhook", func() {
EnvoyAPI: pointer.StringPtr("v3"),
EnvoyResources: &EnvoyResources{
Clusters: []EnvoyResource{{
Name: "cluster",
Name: pointer.String("cluster"),
// the connect_timeout value unit is wrong
Value: `{"name":"cluster1","type":"STRICT_DNS","connect_timeout":"2xs","load_assignment":{"cluster_name":"cluster1"}}`,
}},
Expand All @@ -103,7 +103,7 @@ var _ = Describe("EnvoyConfig webhook", func() {
EnvoyAPI: pointer.StringPtr("v3"),
EnvoyResources: &EnvoyResources{
Listeners: []EnvoyResource{{
Name: "test",
Name: pointer.String("test"),
// the "port" property should be "port_value"
Value: `
name: listener1
Expand Down
33 changes: 26 additions & 7 deletions apis/marin3r/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions config/crd/bases/marin3r.3scale.net_envoyconfigrevisions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -108,7 +107,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -127,7 +125,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -146,7 +143,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -165,7 +161,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -184,7 +179,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -203,7 +197,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand Down
7 changes: 0 additions & 7 deletions config/crd/bases/marin3r.3scale.net_envoyconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -100,7 +99,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -119,7 +117,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -138,7 +135,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -157,7 +153,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -176,7 +171,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand All @@ -195,7 +189,6 @@ spec:
envoy resource
type: string
required:
- name
- value
type: object
type: array
Expand Down
9 changes: 3 additions & 6 deletions config/samples/marin3r_v1alpha1_envoyconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ spec:
secrets:
- name: example.default.svc
clusters:
- name: example
value: |
- value: |
name: example
connect_timeout: 10ms
type: STRICT_DNS
Expand All @@ -28,8 +27,7 @@ spec:
address: example
port_value: 8080
routes:
- name: local
value: |
- value: |
name: local
virtual_hosts:
- name: all
Expand All @@ -40,8 +38,7 @@ spec:
route:
cluster: example
listeners:
- name: https
value: |
- value: |
name: https
address:
socket_address:
Expand Down
10 changes: 5 additions & 5 deletions controllers/marin3r/envoyconfig_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("EnvoyConfig controller", func() {
NodeID: nodeID,
EnvoyResources: &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"endpoint\"}"},
}}},
}
err := k8sClient.Create(context.Background(), ec)
Expand Down Expand Up @@ -146,7 +146,7 @@ var _ = Describe("EnvoyConfig controller", func() {
NodeID: nodeID,
EnvoyResources: &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"endpoint\"}"},
}}},
}
err := k8sClient.Create(context.Background(), ec)
Expand All @@ -172,7 +172,7 @@ var _ = Describe("EnvoyConfig controller", func() {
patch := client.MergeFrom(ec.DeepCopy())
ec.Spec.EnvoyResources = &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"wrong_key\": \"wrong_value\"}"},
{Name: pointer.String("endpoint"), Value: "{\"wrong_key\": \"wrong_value\"}"},
}}
err := k8sClient.Patch(context.Background(), ec, patch)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -201,7 +201,7 @@ var _ = Describe("EnvoyConfig controller", func() {
patch := client.MergeFrom(ec.DeepCopy())
ec.Spec.EnvoyResources = &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"correct_endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"correct_endpoint\"}"},
}}
err := k8sClient.Patch(context.Background(), ec, patch)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -270,7 +270,7 @@ var _ = Describe("EnvoyConfig controller", func() {
patch := client.MergeFrom(ec.DeepCopy())
ec.Spec.EnvoyResources = &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"correct_endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"correct_endpoint\"}"},
}}
err := k8sClient.Patch(context.Background(), ec, patch)
Expect(err).ToNot(HaveOccurred())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("EnvoyConfigRevision controller", func() {
EnvoyAPI: pointer.StringPtr(string(envoy.APIv3)),
EnvoyResources: &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"endpoint\"}"},
}}},
}
err := k8sClient.Create(context.Background(), ecr)
Expand Down Expand Up @@ -265,7 +265,7 @@ var _ = Describe("EnvoyConfigRevision controller", func() {
Version: "xxxx",
EnvoyResources: &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"endpoint\"}"},
}}},
}
err := k8sClient.Create(context.Background(), ecr)
Expand Down Expand Up @@ -328,7 +328,7 @@ var _ = Describe("EnvoyConfigRevision controller", func() {
Version: "xxxx",
EnvoyResources: &marin3rv1alpha1.EnvoyResources{
Endpoints: []marin3rv1alpha1.EnvoyResource{
{Name: "endpoint", Value: "{\"cluster_name\": \"endpoint\"}"},
{Name: pointer.String("endpoint"), Value: "{\"cluster_name\": \"endpoint\"}"},
}}},
}
err := k8sClient.Create(context.Background(), ecr)
Expand Down Expand Up @@ -390,7 +390,7 @@ var _ = Describe("EnvoyConfigRevision controller", func() {
Expect(err).ToNot(HaveOccurred())
patch := client.MergeFrom(ecr.DeepCopy())
ecr.Spec.EnvoyResources.Clusters = []marin3rv1alpha1.EnvoyResource{
{Name: "cluster", Value: "{\"wrong_key\": \"wrong_value\"}"},
{Name: pointer.String("cluster"), Value: "{\"wrong_key\": \"wrong_value\"}"},
}
err = k8sClient.Patch(context.Background(), ecr, patch)
Expect(err).ToNot(HaveOccurred())
Expand Down
4 changes: 3 additions & 1 deletion docs/api-reference/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ EnvoyResource holds serialized representation of an envoy resource
[cols="25a,75a", options="header"]
|===
| Field | Description
| *`name`* __string__ | Name of the envoy resource
| *`name`* __string__ | Name of the envoy resource. DEPRECATED: this field has no effect and will be removed in an upcoming release. The name of the resources for discovery purposes is included in the resource itself. Refer to the envoy API reference to check how the name is specified for each resource type.
| *`value`* __string__ | Value is the serialized representation of the envoy resource
|===

Expand All @@ -242,6 +242,7 @@ EnvoyResources holds each envoy api resource type
| *`listeners`* __xref:{anchor_prefix}-github-com-3scale-ops-marin3r-apis-marin3r-v1alpha1-envoyresource[$$EnvoyResource$$] array__ | Listeners is a list of the envoy Listener resource type. API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener.proto
| *`runtimes`* __xref:{anchor_prefix}-github-com-3scale-ops-marin3r-apis-marin3r-v1alpha1-envoyresource[$$EnvoyResource$$] array__ | Runtimes is a list of the envoy Runtime resource type. API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/runtime/v3/rtds.proto
| *`secrets`* __xref:{anchor_prefix}-github-com-3scale-ops-marin3r-apis-marin3r-v1alpha1-envoysecretresource[$$EnvoySecretResource$$] array__ | Secrets is a list of references to Kubernetes Secret objects.
| *`extensionConfigs`* __xref:{anchor_prefix}-github-com-3scale-ops-marin3r-apis-marin3r-v1alpha1-envoyresource[$$EnvoyResource$$] array__ | ExtensionConfigs is a list of the envoy ExtensionConfig resource type API V3 reference: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/extension.proto
|===


Expand Down Expand Up @@ -287,6 +288,7 @@ VersionTracker tracks the versions of the resources that this revision publishes
| *`listeners`* __string__ |
| *`secrets`* __string__ |
| *`runtimes`* __string__ |
| *`extensionConfigs`* __string__ |
|===


Expand Down
Loading