Skip to content

Commit fe1d7dc

Browse files
authored
Merge pull request #6905 from borg-land/new-shared-image-repos
Deploy new k8s-staging-images project
2 parents a272354 + ba72c64 commit fe1d7dc

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
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+
module "gcb_bucket" {
18+
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
19+
version = "~> 5"
20+
21+
name = "k8s-staging-images-gcb"
22+
project_id = module.project.project_id
23+
location = "us"
24+
25+
lifecycle_rules = [{
26+
action = {
27+
type = "Delete"
28+
}
29+
condition = {
30+
age = 90 # 90d
31+
with_state = "ANY"
32+
}
33+
}]
34+
35+
iam_members = [
36+
{
37+
role = "roles/storage.admin"
38+
member = "serviceAccount:[email protected]"
39+
}
40+
]
41+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
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+
module "iam" {
18+
source = "terraform-google-modules/iam/google//modules/projects_iam"
19+
version = "~> 7"
20+
21+
projects = [module.project.project_id]
22+
23+
mode = "authoritative"
24+
25+
bindings = {
26+
"roles/cloudbuild.builds.editor" = [
27+
"serviceAccount:[email protected]",
28+
]
29+
"roles/owner" = [
30+
31+
]
32+
"roles/viewer" = [
33+
for _, group in local.registries : group
34+
]
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
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+
module "project" {
18+
source = "terraform-google-modules/project-factory/google"
19+
version = "~> 14.5"
20+
21+
name = "k8s-staging-images"
22+
project_id = "k8s-staging-images"
23+
org_id = "758905017065"
24+
billing_account = "018801-93540E-22A20E"
25+
26+
# Sane project defaults
27+
default_service_account = "keep"
28+
disable_services_on_destroy = false
29+
create_project_sa = false
30+
random_project_id = false
31+
auto_create_network = true
32+
33+
34+
activate_apis = [
35+
"artifactregistry.googleapis.com",
36+
"cloudbuild.googleapis.com"
37+
]
38+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
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+
terraform {
18+
required_version = "1.6.5"
19+
20+
backend "gcs" {
21+
bucket = "k8s-infra-tf-prow-clusters"
22+
prefix = "k8s-infra-staging"
23+
}
24+
25+
required_providers {
26+
google = {
27+
source = "hashicorp/google"
28+
version = "~> 5.34.0"
29+
}
30+
google-beta = {
31+
source = "hashicorp/google-beta"
32+
version = "~> 5.34.0"
33+
}
34+
}
35+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
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+
locals {
18+
// The groups have to be created before applying this terraform code
19+
registries = {
20+
etcd-manager = "group:[email protected]",
21+
kubernetes = "group:[email protected]",
22+
test-infra = "group:[email protected]"
23+
}
24+
}
25+
26+
module "artifact_registry" {
27+
for_each = local.registries
28+
source = "GoogleCloudPlatform/artifact-registry/google"
29+
version = "~> 0.2"
30+
31+
project_id = module.project.project_id
32+
location = "us-central1"
33+
format = "DOCKER"
34+
repository_id = each.key
35+
members = {
36+
readers = ["allUsers"],
37+
writers = [each.value],
38+
}
39+
cleanup_policies = {
40+
"delete-images-older-than-90-days" = {
41+
action = "DELETE"
42+
condition = {
43+
older_than = "7776000s" # 90d
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)