Skip to content

Commit 140e11a

Browse files
authored
Support enableK8sTokensViaDns in ContainerCluster (#6406)
### BRIEF Change description <!-- Describe what this pull request does. * If your pull request is to address an open issue, indicate it by specifying the issue number: * If your pull request fixes an issue which has not been filed, please file the issue and put the number here. For example: "Fixes #858" --> Fixes #6200 Supported `spec.controlPlaneEndpointsConfig.dnsEndpointConfig.enableK8sTokensViaDns` field in ContainerCluster resource via TF patch. Note that I didn't capitalize all characters in acronym `Dns` in the field name due to the complexity of creating exemptions for naming and conversion logic in TF-based resources. #### WHY do we need this change? #### Special notes for your reviewer: #### Does this PR add something which needs to be 'release noted'? <!-- If no, just write "NONE" in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". --> ```release-note Supported `spec.controlPlaneEndpointsConfig.dnsEndpointConfig.enableK8sTokensViaDns` field in ContainerCluster. ``` - [ ] Reviewer reviewed release note. #### Additional documentation e.g., references, usage docs, etc.: <!-- This section can be blank if this pull request does not require any additional documentation. When adding links which point to resources within git repositories, like usage documentation, please reference a specific commit and avoid linking directly to the master branch. This ensures that links reference a specific point in time, rather than a document that may change over time. See here for guidance on getting permanent links to files: https://help.github.com/en/articles/getting-permanent-links-to-files Please use the following format for linking documentation: - [Usage]: <link> - [Other doc]: <link> --> ```docs ``` #### Intended Milestone Please indicate the intended milestone. - [ ] Reviewer tagged PR with the actual milestone. ### Tests you have done <!-- Make sure you have run "make ready-pr" to run required tests and ensure this PR is ready to review. Also if possible, share a bit more on the tests you have done. For example if you have updated the pubsubtopic sample, you can share the test logs from running the test case locally. go test -v -tags=integration ./config/tests/samples/create -test.run TestAll -run-tests pubsubtopic --> - [X] Run `make ready-pr` to ensure this PR is ready for review. - [X] Perform necessary E2E testing for changed resources.
2 parents 9f4bd29 + 33eae13 commit 140e11a

File tree

48 files changed

+5443
-1067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5443
-1067
lines changed

config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_containerclusters.container.cnrm.cloud.google.com.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tasks/update-containercluster-golden-files

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ WRITE_GOLDEN_OUTPUT=1"
3030

3131
export $MOCK_TEST_ENV_VARS
3232

33-
go test ./mockgcptests -run TestScripts/mockpubsub/testdata/topic/crud 2>&1
33+
# Mock container cluster has more than just crud testdata.
34+
go test ./mockgcp/mockgcptests -run TestScripts/mockcontainer/testdata/clusters 2>&1
3435

3536
go test -test.count=1 -timeout 3600s -v ./tests/e2e -run TestAllInSeries/fixtures/containercluster 2>&1
3637
go test -test.count=1 -timeout 3600s -v ./tests/e2e -run TestAllInSeries/fixtures/containernodepool 2>&1

mockgcp/apply-proto-patches.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,13 @@ go run . --file ${REPO_ROOT}/mockgcp/third_party/googleapis/google/cloud/alloydb
9696
9797
EOF
9898

99+
# Container/GKE patches
100+
101+
go run . --file ${REPO_ROOT}/mockgcp/third_party/googleapis/google/container/v1beta1/cluster_service.proto --message DNSEndpointConfig --mode append <<EOF
102+
103+
// Controls whether the k8s token auth is allowed via DNS.
104+
105+
optional bool enable_k8s_tokens_via_dns = 5;
106+
107+
EOF
108+

mockgcp/generated/mockgcp/container/v1beta1/cluster_service.pb.go

Lines changed: 989 additions & 976 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mockgcp/mockcontainer/cluster.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,9 @@ func (s *ClusterManagerV1) populateClusterDefaults(project *projects.ProjectData
893893
if dnsEndpointConfig.AllowExternalTraffic == nil {
894894
dnsEndpointConfig.AllowExternalTraffic = PtrTo(false)
895895
}
896-
// "enableK8sCertsViaDns": false,
896+
if dnsEndpointConfig.EnableK8STokensViaDns == nil {
897+
dnsEndpointConfig.EnableK8STokensViaDns = PtrTo(false)
898+
}
897899
dnsEndpointConfig.Endpoint = fmt.Sprintf("gke-12345trewq-${projectNumber}.%s.gke.goog", obj.Location)
898900
}
899901

mockgcp/mockcontainer/testdata/clusters/crud/_http.log

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ X-Xss-Protection: 0
191191
"controlPlaneEndpointsConfig": {
192192
"dnsEndpointConfig": {
193193
"allowExternalTraffic": false,
194+
"enableK8sTokensViaDns": false,
194195
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
195196
},
196197
"ipEndpointsConfig": {
@@ -564,6 +565,7 @@ X-Xss-Protection: 0
564565
"controlPlaneEndpointsConfig": {
565566
"dnsEndpointConfig": {
566567
"allowExternalTraffic": true,
568+
"enableK8sTokensViaDns": false,
567569
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
568570
},
569571
"ipEndpointsConfig": {

mockgcp/mockcontainer/testdata/clusters/dataplanev2/_http.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ X-Xss-Protection: 0
201201
"controlPlaneEndpointsConfig": {
202202
"dnsEndpointConfig": {
203203
"allowExternalTraffic": false,
204+
"enableK8sTokensViaDns": false,
204205
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
205206
},
206207
"ipEndpointsConfig": {

pkg/clients/generated/apis/container/v1beta1/containercluster_types.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/clients/generated/apis/container/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/test/resourcefixture/testdata/basic/container/v1beta1/containercluster/containercluster-addon/_http.log

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ User-Agent: google-api-go-client/0.5 kcc/${kccVersion} (+https://github.com/Goog
8484
},
8585
"controlPlaneEndpointsConfig": {
8686
"dnsEndpointConfig": {
87-
"allowExternalTraffic": false
87+
"allowExternalTraffic": false,
88+
"enableK8sTokensViaDns": false
8889
},
8990
"ipEndpointsConfig": {
9091
"authorizedNetworksConfig": {},
@@ -290,6 +291,7 @@ X-Xss-Protection: 0
290291
"controlPlaneEndpointsConfig": {
291292
"dnsEndpointConfig": {
292293
"allowExternalTraffic": false,
294+
"enableK8sTokensViaDns": false,
293295
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
294296
},
295297
"ipEndpointsConfig": {
@@ -657,6 +659,7 @@ X-Xss-Protection: 0
657659
"controlPlaneEndpointsConfig": {
658660
"dnsEndpointConfig": {
659661
"allowExternalTraffic": false,
662+
"enableK8sTokensViaDns": false,
660663
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
661664
},
662665
"ipEndpointsConfig": {
@@ -1024,6 +1027,7 @@ X-Xss-Protection: 0
10241027
"controlPlaneEndpointsConfig": {
10251028
"dnsEndpointConfig": {
10261029
"allowExternalTraffic": false,
1030+
"enableK8sTokensViaDns": false,
10271031
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
10281032
},
10291033
"ipEndpointsConfig": {
@@ -1458,6 +1462,7 @@ X-Xss-Protection: 0
14581462
"controlPlaneEndpointsConfig": {
14591463
"dnsEndpointConfig": {
14601464
"allowExternalTraffic": false,
1465+
"enableK8sTokensViaDns": false,
14611466
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
14621467
},
14631468
"ipEndpointsConfig": {
@@ -1825,6 +1830,7 @@ X-Xss-Protection: 0
18251830
"controlPlaneEndpointsConfig": {
18261831
"dnsEndpointConfig": {
18271832
"allowExternalTraffic": false,
1833+
"enableK8sTokensViaDns": false,
18281834
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
18291835
},
18301836
"ipEndpointsConfig": {
@@ -2192,6 +2198,7 @@ X-Xss-Protection: 0
21922198
"controlPlaneEndpointsConfig": {
21932199
"dnsEndpointConfig": {
21942200
"allowExternalTraffic": false,
2201+
"enableK8sTokensViaDns": false,
21952202
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
21962203
},
21972204
"ipEndpointsConfig": {
@@ -2630,6 +2637,7 @@ X-Xss-Protection: 0
26302637
"controlPlaneEndpointsConfig": {
26312638
"dnsEndpointConfig": {
26322639
"allowExternalTraffic": false,
2640+
"enableK8sTokensViaDns": false,
26332641
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
26342642
},
26352643
"ipEndpointsConfig": {
@@ -3000,6 +3008,7 @@ X-Xss-Protection: 0
30003008
"controlPlaneEndpointsConfig": {
30013009
"dnsEndpointConfig": {
30023010
"allowExternalTraffic": false,
3011+
"enableK8sTokensViaDns": false,
30033012
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
30043013
},
30053014
"ipEndpointsConfig": {
@@ -3370,6 +3379,7 @@ X-Xss-Protection: 0
33703379
"controlPlaneEndpointsConfig": {
33713380
"dnsEndpointConfig": {
33723381
"allowExternalTraffic": false,
3382+
"enableK8sTokensViaDns": false,
33733383
"endpoint": "gke-12345trewq-${projectNumber}.us-central1-a.gke.goog"
33743384
},
33753385
"ipEndpointsConfig": {

0 commit comments

Comments
 (0)