Skip to content

Commit

Permalink
Merge branch 'main' into service-import-followup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunzhuo authored Sep 5, 2023
2 parents 29e65db + be0ae51 commit 3d28e04
Show file tree
Hide file tree
Showing 21 changed files with 774 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/retest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
pull-requests: write
actions: write
steps:
- uses: envoyproxy/toolshed/gh-actions/[email protected].17
- uses: envoyproxy/toolshed/gh-actions/[email protected].18
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions api/config/v1alpha1/accesslogging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const (
)

// ProxyAccessLogFormat defines the format of accesslog.
// By default accesslogs are written to standard output.
// +union
type ProxyAccessLogFormat struct {
// Type defines the type of accesslog format.
// +kubebuilder:validation:Enum=Text;JSON
// +unionDiscriminator
Type ProxyAccessLogFormatType `json:"type,omitempty"`
// Text defines the text accesslog format, following Envoy accesslog formatting,
// empty value results in proxy's default access log format.
// It's required when the format type is "Text".
// Envoy [command operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators) may be used in the format.
// The [format string documentation](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-strings) provides more information.
Expand Down Expand Up @@ -79,7 +79,7 @@ type ProxyAccessLogSink struct {

type FileEnvoyProxyAccessLog struct {
// Path defines the file path used to expose envoy access log(e.g. /dev/stdout).
// Empty value disables accesslog.
// +kubebuilder:validation:MinLength=1
Path string `json:"path,omitempty"`
}

Expand Down
59 changes: 59 additions & 0 deletions api/config/v1alpha1/validation/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func validateEnvoyProxySpec(spec *egcfgv1a1.EnvoyProxySpec) error {
errs = append(errs, err)
}
}

validateProxyTelemetryErrs := validateProxyTelemetry(spec)
if len(validateProxyTelemetryErrs) != 0 {
errs = append(errs, validateProxyTelemetryErrs...)
}

return utilerrors.NewAggregate(errs)
}

Expand Down Expand Up @@ -156,3 +162,56 @@ func validateBootstrap(boostrapConfig *egcfgv1a1.ProxyBootstrap) error {

return nil
}

func validateProxyTelemetry(spec *egcfgv1a1.EnvoyProxySpec) []error {
var errs []error

if spec != nil && spec.Telemetry.AccessLog != nil {
accessLogErrs := validateProxyAccessLog(spec.Telemetry.AccessLog)
if len(accessLogErrs) > 0 {
errs = append(errs, accessLogErrs...)
}
}

return errs
}

func validateProxyAccessLog(accessLog *egcfgv1a1.ProxyAccessLog) []error {
if accessLog.Disable {
return nil
}

var errs []error

for _, setting := range accessLog.Settings {
switch setting.Format.Type {
case egcfgv1a1.ProxyAccessLogFormatTypeText:
if setting.Format.Text == nil {
err := fmt.Errorf("unable to configure access log when using Text format but \"text\" field being empty")
errs = append(errs, err)
}
case egcfgv1a1.ProxyAccessLogFormatTypeJSON:
if setting.Format.JSON == nil {
err := fmt.Errorf("unable to configure access log when using JSON format but \"json\" field being empty")
errs = append(errs, err)
}
}

for _, sink := range setting.Sinks {
switch sink.Type {
case egcfgv1a1.ProxyAccessLogSinkTypeFile:
if sink.File == nil {
err := fmt.Errorf("unable to configure access log when using File sink type but \"file\" field being empty")
errs = append(errs, err)
}
case egcfgv1a1.ProxyAccessLogSinkTypeOpenTelemetry:
if sink.OpenTelemetry == nil {
err := fmt.Errorf("unable to configure access log when using OpenTelemetry sink type but \"openTelemetry\" field being empty")
errs = append(errs, err)
}
}
}
}

return errs
}
52 changes: 52 additions & 0 deletions api/config/v1alpha1/validation/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,58 @@ func TestValidateEnvoyProxy(t *testing.T) {
},
expected: false,
},
{
name: "should invalid when accesslog enabled using Text format, but `text` field being empty",
proxy: &egcfgv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Name: "test",
},
Spec: egcfgv1a1.EnvoyProxySpec{
Telemetry: egcfgv1a1.ProxyTelemetry{
AccessLog: &egcfgv1a1.ProxyAccessLog{
Settings: []egcfgv1a1.ProxyAccessLogSetting{
{
Format: egcfgv1a1.ProxyAccessLogFormat{
Type: egcfgv1a1.ProxyAccessLogFormatTypeText,
},
},
},
},
},
},
},
expected: false,
},
{
name: "should invalid when accesslog enabled using File sink, but `file` field being empty",
proxy: &egcfgv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Name: "test",
},
Spec: egcfgv1a1.EnvoyProxySpec{
Telemetry: egcfgv1a1.ProxyTelemetry{
AccessLog: &egcfgv1a1.ProxyAccessLog{
Settings: []egcfgv1a1.ProxyAccessLogSetting{
{
Format: egcfgv1a1.ProxyAccessLogFormat{
Type: egcfgv1a1.ProxyAccessLogFormatTypeText,
Text: pointer.String("[%START_TIME%]"),
},
Sinks: []egcfgv1a1.ProxyAccessLogSink{
{
Type: egcfgv1a1.ProxyAccessLogSinkTypeFile,
},
},
},
},
},
},
},
},
expected: false,
},
}

for i := range testCases {
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ To uninstall the chart:
| deployment.envoyGateway.resources.requests.memory | string | `"64Mi"` | |
| deployment.kubeRbacProxy.image.repository | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | |
| deployment.kubeRbacProxy.image.tag | string | `"v0.11.0"` | |
| deployment.kubeRbacProxy.imagePullPolicy | string | `"IfNotPresent"` | |
| deployment.kubeRbacProxy.resources.limits.cpu | string | `"500m"` | |
| deployment.kubeRbacProxy.resources.limits.memory | string | `"128Mi"` | |
| deployment.kubeRbacProxy.resources.requests.cpu | string | `"5m"` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3864,10 +3864,9 @@ spec:
type: object
text:
description: Text defines the text accesslog format,
following Envoy accesslog formatting, empty value
results in proxy's default access log format.
It's required when the format type is "Text".
Envoy [command operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators)
following Envoy accesslog formatting, It's required
when the format type is "Text". Envoy [command
operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators)
may be used in the format. The [format string
documentation](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-strings)
provides more information.
Expand All @@ -3890,7 +3889,7 @@ spec:
path:
description: Path defines the file path used
to expose envoy access log(e.g. /dev/stdout).
Empty value disables accesslog.
minLength: 1
type: string
type: object
openTelemetry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ spec:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ .Values.kubernetesClusterDomain }}
image: {{ .Values.deployment.kubeRbacProxy.image.repository }}:{{ .Values.deployment.kubeRbacProxy.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.deployment.kubeRbacProxy.imagePullPolicy }}
name: kube-rbac-proxy
ports:
- containerPort: 8443
Expand Down
1 change: 1 addition & 0 deletions charts/gateway-helm/values.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ deployment:
image:
repository: gcr.io/kubebuilder/kube-rbac-proxy
tag: v0.14.1
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 500m
Expand Down
6 changes: 3 additions & 3 deletions docs/latest/api/config_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ _Appears in:_

| Field | Description |
| --- | --- |
| `path` _string_ | Path defines the file path used to expose envoy access log(e.g. /dev/stdout). Empty value disables accesslog. |
| `path` _string_ | Path defines the file path used to expose envoy access log(e.g. /dev/stdout). |


## Gateway
Expand Down Expand Up @@ -729,15 +729,15 @@ _Appears in:_



ProxyAccessLogFormat defines the format of accesslog.
ProxyAccessLogFormat defines the format of accesslog. By default accesslogs are written to standard output.

_Appears in:_
- [ProxyAccessLogSetting](#proxyaccesslogsetting)

| Field | Description |
| --- | --- |
| `type` _[ProxyAccessLogFormatType](#proxyaccesslogformattype)_ | Type defines the type of accesslog format. |
| `text` _string_ | Text defines the text accesslog format, following Envoy accesslog formatting, empty value results in proxy's default access log format. It's required when the format type is "Text". Envoy [command operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators) may be used in the format. The [format string documentation](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-strings) provides more information. |
| `text` _string_ | Text defines the text accesslog format, following Envoy accesslog formatting, It's required when the format type is "Text". Envoy [command operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators) may be used in the format. The [format string documentation](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-strings) provides more information. |
| `json` _object (keys:string, values:string)_ | JSON is additional attributes that describe the specific event occurrence. Structured format for the envoy access logs. Envoy [command operators](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#command-operators) can be used as values for fields within the Struct. It's required when the format type is "JSON". |


Expand Down
10 changes: 5 additions & 5 deletions docs/latest/design/accesslog.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type OpenTelemetryEnvoyProxyAccessLog struct {

### Example

1. The following is an example to disable access log.
- The following is an example to disable access log.

```yaml mdox-exec="sed '1,12d' examples/kubernetes/accesslog/disable-accesslog.yaml"
apiVersion: config.gateway.envoyproxy.io/v1alpha1
Expand All @@ -136,7 +136,7 @@ spec:
disable: true
```
2. The following is an example with text format access log.
- The following is an example with text format access log.
```yaml mdox-exec="sed '1,12d' examples/kubernetes/accesslog/text-accesslog.yaml"
apiVersion: config.gateway.envoyproxy.io/v1alpha1
Expand All @@ -158,7 +158,7 @@ spec:
path: /dev/stdout
```
1. The following is an example with json format access log.
- The following is an example with json format access log.
```yaml mdox-exec="sed '1,12d' examples/kubernetes/accesslog/json-accesslog.yaml"
apiVersion: config.gateway.envoyproxy.io/v1alpha1
Expand All @@ -181,7 +181,7 @@ spec:
path: /dev/stdout
```
1. The following is an example with OpenTelemetry format access log.
- The following is an example with OpenTelemetry format access log.
```yaml mdox-exec="sed '1,12d' examples/kubernetes/accesslog/otel-accesslog.yaml"
apiVersion: config.gateway.envoyproxy.io/v1alpha1
Expand All @@ -206,7 +206,7 @@ spec:
k8s.cluster.name: "cluster-1"
```
1. The following is an example of sending same format to different sinks.
- The following is an example of sending same format to different sinks.
```yaml mdox-exec="sed '1,12d' examples/kubernetes/accesslog/multi-sinks.yaml"
apiVersion: config.gateway.envoyproxy.io/v1alpha1
Expand Down
3 changes: 3 additions & 0 deletions docs/latest/user/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ A Kubernetes cluster.

__Note:__ Refer to the [Compatibility Matrix](../intro/compatibility.rst) for supported Kubernetes versions.

__Note:__ In case your Kubernetes cluster, does not have a LoadBalancer implementation, we recommend installing one
so the `Gateway` resource has an Address associated with it. We recommend using [MetalLB](https://metallb.universe.tf/installation/).

## Installation

Install the Gateway API CRDs and Envoy Gateway:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
k8s.io/client-go v0.28.1
k8s.io/kubectl v0.28.1
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
sigs.k8s.io/controller-runtime v0.16.0
sigs.k8s.io/controller-runtime v0.16.1
sigs.k8s.io/gateway-api v0.8.0
sigs.k8s.io/yaml v1.3.0
)
Expand Down
Loading

0 comments on commit 3d28e04

Please sign in to comment.