Skip to content

Commit a71cfc8

Browse files
committed
feat(gke): add mesh samples
1 parent b48a58b commit a71cfc8

File tree

3 files changed

+86
-5
lines changed

3 files changed

+86
-5
lines changed

build/int.cloudbuild.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,28 @@ steps:
3131
git diff origin/main --name-only > _changed_files
3232
sed 's:[^/]*$::' _changed_files > _changed_folders
3333
sort -u -o _changed_folders{,}
34-
echo Folders with changes:
34+
echo "Folders with changes:"
3535
cat _changed_folders
3636
3737
# Do not prune if changing tests themselves
3838
while read d; do
39-
if [[ "build test .github" =~ "${d%/}" ]]; then
39+
if [[ "test .github" =~ "${d%/}" ]]; then
4040
echo "Infrastructure folder ${d%/} has changed; no tests will be pruned."
4141
exit 0 # do not prune
4242
fi
4343
done < _changed_folders
4444
4545
# Remove base folders without changes
4646
for d in *; do
47-
if ! grep -q "^$d$" _changed_folders && [[ "$d" != "test" ]]; then
47+
if ! (grep -q "^$d" _changed_folders || [[ "test _changed_folders" =~ "$d" ]]); then
4848
rm -rf $d;
4949
fi
5050
done
5151
5252
# Remove leaf folders without changes or non-tf resources
5353
for d in `find . -type d -name 'test' -prune -o -links 2 -printf '%P\n'`; do
5454
if ! grep -q "^$d" _changed_folders && ! [ -n "$(find $d -maxdepth 1 -not -name '*.tf' -and -not -name 'test.yaml' -type f -print -quit)" ]; then
55+
echo "Removing leaf folder: $d"
5556
rm -rf $d
5657
fi
5758
done
@@ -60,8 +61,8 @@ steps:
6061
find . -empty -type d -delete
6162
6263
# Report remaining folders
63-
echo Folders in scope for tests:
64-
find . -type d -printf '%P\n'
64+
echo -n "Folders in scope for tests:"
65+
find . -type d -name ".*" -prune -printf '%P\n'
6566
6667
- id: prepare
6768
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'

gke/autopilot/mesh/main.tf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START gke_autopilot_mesh]
18+
data "google_project" "default" {}
19+
20+
resource "google_container_cluster" "default" {
21+
name = "gke-autopilot-mesh"
22+
location = "us-central1"
23+
24+
enable_autopilot = true
25+
26+
fleet {
27+
project = data.google_project.default.project_id
28+
}
29+
30+
# Set `deletion_protection` to `true` will ensure that one cannot
31+
# accidentally delete this instance by use of Terraform.
32+
deletion_protection = false
33+
}
34+
35+
resource "google_gke_hub_feature" "default" {
36+
name = "servicemesh"
37+
location = "global"
38+
}
39+
40+
41+
resource "google_gke_hub_feature_membership" "default" {
42+
location = "global"
43+
44+
feature = google_gke_hub_feature.default.name
45+
membership = google_container_cluster.default.fleet[0].membership_id
46+
membership_location = google_container_cluster.default.fleet[0].membership_location
47+
48+
mesh {
49+
management = "MANAGEMENT_AUTOMATIC"
50+
}
51+
}
52+
# [END gke_autopilot_mesh]

gke/enterprise/mesh/main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START gke_enterprise_mesh]
18+
resource "google_gke_hub_feature" "default" {
19+
name = "servicemesh"
20+
location = "global"
21+
22+
fleet_default_member_config {
23+
mesh {
24+
management = "MANAGEMENT_AUTOMATIC"
25+
}
26+
}
27+
}
28+
# [END gke_enterprise_mesh]

0 commit comments

Comments
 (0)