Skip to content

Commit

Permalink
Adding Private ACR for k8s test
Browse files Browse the repository at this point in the history
Signed-off-by: ritikaguptams <ritikagupta@microsoft.com>
  • Loading branch information
ritikaguptams committed Jul 15, 2024
1 parent b37ac11 commit 91f1e00
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 2 deletions.
2 changes: 2 additions & 0 deletions infra/azure/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ main.tf

# Prerequiste
The az-cli-prow service principal is required to be created by a tenant admin. Also to add a federated credentials for the prow ask a tenant admin or the SP admin. iam-config\param.json can be used for creating the fededrated credentials.
TODO: Add EKS federated creds

The service principal needs:
- Contributor role access to the sub.
- Creation of a custom role to give write access
Expand Down
56 changes: 54 additions & 2 deletions infra/azure/terraform/capz/container-registry/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}
Expand All @@ -10,8 +26,17 @@ resource "azurerm_container_registry" "capzci_registry" {
name = "capzcicommunity"
location = var.location
resource_group_name = var.resource_group_name
sku = "Standard"
sku = "Premium"
anonymous_pull_enabled = true

retention_policy {
days = 7
enabled = true
}

tags = {
RetentionPolicy = "7days"
}
}

resource "azurerm_management_lock" "registry_lock" {
Expand All @@ -32,7 +57,7 @@ resource "azurerm_container_registry_task" "registry_task" {
type = "Runtime"
update_trigger_payload_type = "Default"
}
encoded_step {
encoded_step {
task_content = base64encode(<<EOF
version: v1.1.0
steps:
Expand All @@ -54,4 +79,31 @@ EOF

output "container_registry_id" {
value = azurerm_container_registry.capzci_registry.id
}

resource "azurerm_container_registry" "e2eprivate_registry" {
name = "e2eprivatecommunity"
location = var.location
resource_group_name = var.resource_group_name
sku = "Premium"

retention_policy {
days = 7
enabled = true
}

tags = {
RetentionPolicy = "7days"
}
}

resource "azurerm_management_lock" "e2eregistry_lock" {
name = "DO-NOT_DELETE"
scope = azurerm_container_registry.e2eprivate_registry.id
lock_level = "CanNotDelete"
notes = "Contact Capz"
}

output "e2eprivate_registry_id" {
value = azurerm_container_registry.e2eprivate_registry.id
}
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/identities/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/key-vault/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

provider "azurerm" {
features {}
}
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/resource-group/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

# Resource group for CAPZ CI resources
resource "azurerm_resource_group" "capz_ci" {
location = var.location
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/resource-group/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "location" {
type = string
default = "eastus"
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/role-assignments/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}
Expand Down
16 changes: 16 additions & 0 deletions infra/azure/terraform/capz/storage-account/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}
Expand Down

0 comments on commit 91f1e00

Please sign in to comment.