Skip to content

Commit 4b1577a

Browse files
authored
Merge pull request #2069 from vmware-tanzu/dial_probes_with_proxy
Dial probes with proxy
2 parents 7a41b74 + c235239 commit 4b1577a

22 files changed

+934
-247
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ replace github.com/hashicorp/go-retryablehttp => github.com/hashicorp/go-retryab
3333

3434
require (
3535
github.com/MakeNowJust/heredoc/v2 v2.0.1
36-
github.com/chromedp/cdproto v0.0.0-20241003230502-a4a8f7c660df
37-
github.com/chromedp/chromedp v0.10.0
36+
github.com/chromedp/cdproto v0.0.0-20241014181340-cb3a7a1d51d7
37+
github.com/chromedp/chromedp v0.11.0
3838
github.com/coreos/go-oidc/v3 v3.11.0
3939
github.com/coreos/go-semver v0.3.1
4040
github.com/creack/pty v1.1.23
@@ -64,7 +64,7 @@ require (
6464
github.com/spf13/cobra v1.8.1
6565
github.com/spf13/pflag v1.0.5
6666
github.com/stretchr/testify v1.9.0
67-
github.com/tdewolff/minify/v2 v2.20.37
67+
github.com/tdewolff/minify/v2 v2.21.0
6868
go.uber.org/mock v0.4.0
6969
go.uber.org/zap v1.27.0
7070
golang.org/x/crypto v0.28.0
@@ -162,7 +162,7 @@ require (
162162
github.com/spf13/viper v1.16.0 // indirect
163163
github.com/stoewer/go-strcase v1.2.0 // indirect
164164
github.com/subosito/gotenv v1.4.2 // indirect
165-
github.com/tdewolff/parse/v2 v2.7.15 // indirect
165+
github.com/tdewolff/parse/v2 v2.7.17 // indirect
166166
github.com/x448/float16 v0.8.4 // indirect
167167
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
168168
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect

go.sum

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
6464
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
6565
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6666
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
67-
github.com/chromedp/cdproto v0.0.0-20240801214329-3f85d328b335/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
68-
github.com/chromedp/cdproto v0.0.0-20241003230502-a4a8f7c660df h1:cbtSn19AtqQha1cxmP2Qvgd3fFMz51AeAEKLJMyEUhc=
6967
github.com/chromedp/cdproto v0.0.0-20241003230502-a4a8f7c660df/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
70-
github.com/chromedp/chromedp v0.10.0 h1:bRclRYVpMm/UVD76+1HcRW9eV3l58rFfy7AdBvKab1E=
71-
github.com/chromedp/chromedp v0.10.0/go.mod h1:ei/1ncZIqXX1YnAYDkxhD4gzBgavMEUu7JCKvztdomE=
68+
github.com/chromedp/cdproto v0.0.0-20241014181340-cb3a7a1d51d7 h1:VDBgUGgdCBw9lTKwp0KPExhnqmGfGVJQTER2MehoICk=
69+
github.com/chromedp/cdproto v0.0.0-20241014181340-cb3a7a1d51d7/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
70+
github.com/chromedp/chromedp v0.11.0 h1:1PT6O4g39sBAFjlljIHTpxmCSk8meeYL6+R+oXH4bWA=
71+
github.com/chromedp/chromedp v0.11.0/go.mod h1:jsD7OHrX0Qmskqb5Y4fn4jHnqquqW22rkMFgKbECsqg=
7272
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
7373
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
7474
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@@ -560,10 +560,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
560560
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
561561
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
562562
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
563-
github.com/tdewolff/minify/v2 v2.20.37 h1:Q97cx4STXCh1dlWDlNHZniE8BJ2EBL0+2b0n92BJQhw=
564-
github.com/tdewolff/minify/v2 v2.20.37/go.mod h1:L1VYef/jwKw6Wwyk5A+T0mBjjn3mMPgmjjA688RNsxU=
565-
github.com/tdewolff/parse/v2 v2.7.15 h1:hysDXtdGZIRF5UZXwpfn3ZWRbm+ru4l53/ajBRGpCTw=
566-
github.com/tdewolff/parse/v2 v2.7.15/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
563+
github.com/tdewolff/minify/v2 v2.21.0 h1:nAPP1UVx0aK1xsQh/JiG3xyEnnqWw+agPstn+V6Pkto=
564+
github.com/tdewolff/minify/v2 v2.21.0/go.mod h1:hGcthJ6Vj51NG+9QRIfN/DpWj5loHnY3bfhThzWWq08=
565+
github.com/tdewolff/parse/v2 v2.7.17 h1:uC10p6DaQQORDy72eaIyD+AvAkaIUOouQ0nWp4uD0D0=
566+
github.com/tdewolff/parse/v2 v2.7.17/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
567567
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
568568
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
569569
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
@@ -851,7 +851,6 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
851851
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
852852
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
853853
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
854-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
855854
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
856855
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
857856
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=

hack/prepare-for-integration-tests.sh

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ clean_kind=no
3434
api_group_suffix="pinniped.dev" # same default as in the values.yaml ytt file
3535
dockerfile_path=""
3636
get_active_directory_vars="" # specify a filename for a script to get AD related env variables
37-
get_github_vars="" # specify a filename for a script to get GitHub related env variables
37+
get_github_vars="" # specify a filename for a script to get GitHub related env variables
3838
alternate_deploy="undefined"
3939
pre_install="undefined"
4040

@@ -319,6 +319,15 @@ service_https_nodeport_nodeport: $service_https_nodeport_nodeport
319319
service_https_clusterip_port: $service_https_clusterip_port
320320
EOF
321321

322+
if [[ "${FIREWALL_IDPS:-no}" == "yes" ]]; then
323+
# Configure the web proxy on the Supervisor pods. Note that .svc and .cluster.local are not included,
324+
# so requests for things like dex.tools.svc.cluster.local will go through the web proxy.
325+
cat <<EOF >>"$data_values_file"
326+
https_proxy: "http://proxy.tools.svc.cluster.local:3128"
327+
no_proxy: "\$(KUBERNETES_SERVICE_HOST),169.254.169.254,127.0.0.1,localhost"
328+
EOF
329+
fi
330+
322331
if [ "$alternate_deploy" != "undefined" ]; then
323332
log_note "The Pinniped Supervisor will be deployed with $alternate_deploy pinniped-supervisor $tag $registry_with_port $repo $data_values_file ..."
324333
$alternate_deploy pinniped-supervisor "$tag" $registry_with_port $repo $data_values_file
@@ -338,7 +347,7 @@ manifest=/tmp/pinniped-concierge.yaml
338347
data_values_file=/tmp/concierge-values.yml
339348
concierge_app_name="pinniped-concierge"
340349
concierge_namespace="concierge"
341-
webhook_url="https://local-user-authenticator.local-user-authenticator.svc/authenticate"
350+
webhook_url="https://local-user-authenticator.local-user-authenticator.svc.cluster.local/authenticate"
342351
discovery_url="$(TERM=dumb kubectl cluster-info | awk '/master|control plane/ {print $NF}')"
343352
concierge_custom_labels="{myConciergeCustomLabelName: myConciergeCustomLabelValue}"
344353
log_level="debug"
@@ -354,6 +363,16 @@ image_tag: $tag
354363
discovery_url: $discovery_url
355364
EOF
356365

366+
if [[ "${FIREWALL_IDPS:-no}" == "yes" ]]; then
367+
# Configure the web proxy on the Concierge pods. Note that .svc and .cluster.local are not included,
368+
# so requests for things like pinniped-supervisor-clusterip.supervisor.svc.cluster.local and
369+
# local-user-authenticator.local-user-authenticator.svc.cluster.local will go through the web proxy.
370+
cat <<EOF >>"$data_values_file"
371+
https_proxy: "http://proxy.tools.svc.cluster.local:3128"
372+
no_proxy: "\$(KUBERNETES_SERVICE_HOST),169.254.169.254,127.0.0.1,localhost"
373+
EOF
374+
fi
375+
357376
if [ "$alternate_deploy" != "undefined" ]; then
358377
log_note "The Pinniped Concierge will be deployed with $alternate_deploy pinniped-concierge $tag $registry_with_port $repo $data_values_file ..."
359378
$alternate_deploy pinniped-concierge "$tag" $registry_with_port $repo $data_values_file
@@ -366,6 +385,77 @@ else
366385
popd >/dev/null
367386
fi
368387

388+
#
389+
# Now that the everything is deployed, optionally firewall the Dex server, the local user authenticator server,
390+
# and the GitHub API so that the Supervisor and Concierge cannot reach them directly. However, the Squid
391+
# proxy server can reach them all, so the Supervisor and Concierge can reach them through the proxy.
392+
#
393+
if [[ "${FIREWALL_IDPS:-no}" == "yes" ]]; then
394+
log_note "Setting up firewalls for the Supervisor and Concierge's outgoing TCP/UDP network traffic..."
395+
cat <<EOF | kubectl apply --wait -f -
396+
---
397+
apiVersion: networking.k8s.io/v1
398+
kind: NetworkPolicy
399+
metadata:
400+
name: supervisor-cannot-make-external-requests
401+
namespace: ${supervisor_namespace}
402+
spec:
403+
# An empty podSelector matches all pods in this namespace.
404+
podSelector: {}
405+
policyTypes:
406+
- Egress
407+
# This is an allow list. Everything else disallowed.
408+
# Especially note that it cannot access Dex or the GitHub API directly.
409+
egress:
410+
- to:
411+
# Allowed to make requests to all pods in kube-system for DNS and Kube API.
412+
- namespaceSelector:
413+
matchLabels:
414+
kubernetes.io/metadata.name: kube-system
415+
# Allowed to make requests to the LDAP server in tools, because we cannot use
416+
# an HTTP proxy for the LDAP protocol, since LDAP is not over HTTP.
417+
- namespaceSelector:
418+
matchLabels:
419+
kubernetes.io/metadata.name: tools
420+
podSelector:
421+
matchLabels:
422+
app: ldap
423+
# Allowed to make requests to the Squid proxy server in the tools namespace.
424+
- namespaceSelector:
425+
matchLabels:
426+
kubernetes.io/metadata.name: tools
427+
podSelector:
428+
matchLabels:
429+
app: proxy
430+
---
431+
apiVersion: networking.k8s.io/v1
432+
kind: NetworkPolicy
433+
metadata:
434+
name: concierge-cannot-make-external-requests
435+
namespace: ${concierge_namespace}
436+
spec:
437+
# An empty podSelector matches all pods in this namespace.
438+
podSelector: {}
439+
policyTypes:
440+
- Egress
441+
# This is an allow list. Everything else disallowed.
442+
# Especially note that it cannot access the local user authenticator or Supervisor directly.
443+
egress:
444+
- to:
445+
# Allowed to make requests to all pods in kube-system for DNS and Kube API.
446+
- namespaceSelector:
447+
matchLabels:
448+
kubernetes.io/metadata.name: kube-system
449+
# Allowed to make requests to the Squid proxy server in the tools namespace.
450+
- namespaceSelector:
451+
matchLabels:
452+
kubernetes.io/metadata.name: tools
453+
podSelector:
454+
matchLabels:
455+
app: proxy
456+
EOF
457+
fi
458+
369459
#
370460
# Create a test user in the local-user-authenticator and get its CA bundle.
371461
#

hack/prepare-impersonator-on-kind.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
3+
# Copyright 2021-2024 the Pinniped contributors. All Rights Reserved.
44
# SPDX-License-Identifier: Apache-2.0
55

66
#
@@ -50,7 +50,7 @@ kind: WebhookAuthenticator
5050
metadata:
5151
name: local-user-authenticator
5252
spec:
53-
endpoint: https://local-user-authenticator.local-user-authenticator.svc/authenticate
53+
endpoint: https://local-user-authenticator.local-user-authenticator.svc.cluster.local/authenticate
5454
tls:
5555
certificateAuthorityData: $LOCAL_USER_AUTHENTICATOR_CA
5656
EOF

internal/controller/apicerts/certs_manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ func (c *certsManagerController) Sync(ctx controllerlib.Context) error {
119119
// Using the CA from above, create a TLS server cert if we have service name.
120120
if len(c.serviceNameForGeneratedCertCommonName) != 0 {
121121
serviceEndpoint := c.serviceNameForGeneratedCertCommonName + "." + c.namespace + ".svc"
122-
tlsCert, err := ca.IssueServerCert([]string{serviceEndpoint}, nil, c.certDuration)
122+
// Allow clients to use either service-name.namespace.svc or service-name.namespace.svc.cluster.local to verify TLS.
123+
tlsCert, err := ca.IssueServerCert([]string{serviceEndpoint, serviceEndpoint + ".cluster.local"}, nil, c.certDuration)
123124
if err != nil {
124125
return fmt.Errorf("could not issue serving certificate: %w", err)
125126
}

internal/controller/apicerts/certs_manager_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
1+
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

44
package apicerts
@@ -225,6 +225,7 @@ func TestManagerControllerSync(t *testing.T) {
225225
// Validate the created cert using the CA, and also validate the cert's hostname
226226
validCert := testutil.ValidateServerCertificate(t, actualCACert, actualCertChain)
227227
validCert.RequireDNSName("pinniped-api." + installedInNamespace + ".svc")
228+
validCert.RequireDNSName("pinniped-api." + installedInNamespace + ".svc.cluster.local")
228229
validCert.RequireLifetime(time.Now(), time.Now().Add(certDuration), 6*time.Minute)
229230
validCert.RequireMatchesPrivateKey(actualPrivateKey)
230231
})

0 commit comments

Comments
 (0)