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 mode to ProxyDefault configEntry #505

Merged
merged 3 commits into from
Apr 28, 2021
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
11 changes: 11 additions & 0 deletions api/v1alpha1/proxydefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ type ProxyDefaultsSpec struct {
// Note: This cannot be set using the CRD and should be set using annotations on the
// services that are part of the mesh.
TransparentProxy *TransparentProxy `json:"transparentProxy,omitempty"`
// Mode can be one of "direct" or "transparent". "transparent" represents that inbound and outbound
// application traffic is being captured and redirected through the proxy. This mode does not
// enable the traffic redirection itself. Instead it signals Consul to configure Envoy as if
// traffic is already being redirected. "direct" represents that the proxy's listeners must be
// dialed directly by the local application and other proxies.
// Note: This cannot be set using the CRD and should be set using annotations on the
// services that are part of the mesh.
Mode *ProxyMode `json:"mode,omitempty"`
}

func (in *ProxyDefaults) GetObjectMeta() metav1.ObjectMeta {
Expand Down Expand Up @@ -179,6 +187,9 @@ func (in *ProxyDefaults) Validate(namespacesEnabled bool) error {
if err := in.Spec.TransparentProxy.validate(path.Child("transparentProxy")); err != nil {
allErrs = append(allErrs, err)
}
if err := in.Spec.Mode.validate(path.Child("mode")); err != nil {
allErrs = append(allErrs, err)
}
if err := in.validateConfig(path.Child("config")); err != nil {
allErrs = append(allErrs, err)
}
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/proxydefaults_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ func TestValidateProxyDefault(t *testing.T) {
expAllow: false,
expErrMessage: "proxydefaults.consul.hashicorp.com \"global\" is invalid: spec.transparentProxy: Invalid value: v1alpha1.TransparentProxy{OutboundListenerPort:1000}: use the annotation `consul.hashicorp.com/transparent-proxy-outbound-listener-port` to configure the Outbound Listener Port",
},
"mode value set": {
existingResources: []runtime.Object{},
newResource: &ProxyDefaults{
ObjectMeta: metav1.ObjectMeta{
Name: "global",
},
Spec: ProxyDefaultsSpec{
Mode: proxyModeRef("transparent"),
},
},
expAllow: false,
expErrMessage: "proxydefaults.consul.hashicorp.com \"global\" is invalid: spec.mode: Invalid value: \"transparent\": use the annotation `consul.hashicorp.com/transparent-proxy` to configure the Transparent Proxy Mode",
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions config/crd/bases/consul.hashicorp.com_proxydefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
description: Mode is the mode that should be used for the upstream connection. One of none, local, or remote.
type: string
type: object
mode:
description: 'Mode can be one of "direct" or "transparent". "transparent" represents that inbound and outbound application traffic is being captured and redirected through the proxy. This mode does not enable the traffic redirection itself. Instead it signals Consul to configure Envoy as if traffic is already being redirected. "direct" represents that the proxy''s listeners must be dialed directly by the local application and other proxies. Note: This cannot be set using the CRD and should be set using annotations on the services that are part of the mesh.'
type: string
transparentProxy:
description: 'TransparentProxy controls configuration specific to proxies in transparent mode. Note: This cannot be set using the CRD and should be set using annotations on the services that are part of the mesh.'
properties:
Expand Down