Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][DoNotReview] infra: add k8s-infra-vsphere for vSphere based CI #6851

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions groups/restrictions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ restrictions:
- "^[email protected]$"
- "^[email protected]$"
- "^[email protected]$"
- "^[email protected]$"
- "^[email protected]$"
- "^[email protected]$"
- "^[email protected]$"
Expand Down
14 changes: 14 additions & 0 deletions groups/sig-k8s-infra/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,17 @@ groups:
- [email protected]
- [email protected]
- [email protected]

# Owners of the GCP project k8s-infra-vsphere:
- email-id: [email protected]
name: k8s-infra-vsphere
description: |-
ACL for vSphere project on GCP
settings:
WhoCanPostMessage: "ANYONE_CAN_POST"
ReconcileMembers: "true"
members:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
1 change: 1 addition & 0 deletions infra/gcp/bash/ensure-main-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ readonly TERRAFORM_STATE_BUCKET_ENTRIES=(
k8s-infra-tf-public-pii:"${CLUSTER_ADMINS_GROUP}"
k8s-infra-tf-sandbox-capg:[email protected]
k8s-infra-tf-sandbox-ii:[email protected]
k8s-infra-tf-vsphere:[email protected]
)

# The services we explicitly want enabled for the main project
Expand Down
6 changes: 6 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See the OWNERS docs at https://go.k8s.io/owners

reviewers:
- chrischdi
- sbueringer
- fabriziopandini
53 changes: 53 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
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.
*/

locals {
project_id = "k8s-infra-vsphere"
}


data "google_billing_account" "account" {
billing_account = "TODO"
}

data "google_organization" "org" {
domain = "kubernetes.io"
}

resource "google_project" "project" {
name = local.project_id
project_id = local.project_id
org_id = data.google_organization.org.org_id
billing_account = data.google_billing_account.account.id
}


resource "google_project_service" "project" {
project = google_project.project.id

for_each = toset([
"vmwareengine.googleapis.com"
])

service = each.key
}

// Ensure [email protected] has owner access to this project
resource "google_project_iam_member" "k8s_infra_vsphere" {
project = google_project.project.id
role = "roles/owner"
member = "group:[email protected]"
}
41 changes: 41 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
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.
*/

/*
This file defines:
- Required provider versions
- Storage backend details
*/

terraform {

backend "gcs" {
bucket = "k8s-infra-tf-vsphere"
prefix = "k8s-infra-vsphere"
}


required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.90.1"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 3.90.1"
}
}
}
24 changes: 24 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
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.
*/

/*
This file defines:
- Required Terraform version
*/

terraform {
required_version = "~> 1.5.0"
}
44 changes: 44 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/vmware-engine.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
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 "google_vmwareengine_private_cloud" "vsphere-cluster" {
# location = "us-central1"
# name = "sample-pc"
# description = "vSphere Cluster for CI."
# # TODO: type TIME_LIMITED is for the timely limitted 1 node_count. Change to `STANDARD`.
# type = "TIME_LIMITED"
# network_config {
# management_cidr = "192.168.30.0/24"
# vmware_engine_network = google_vmwareengine_network.cluster-nw.id
# }

# management_cluster {
# cluster_id = "vsphere-ci-cluster"
# node_type_configs {
# node_type_id = "standard-72"
# # TODO: node_count 1 is for the TIME_LIMITED version. Change to `3`.
# node_count = 1
# }
# }
# }

# resource "google_vmwareengine_network" "vsphere-network" {
# name = "vsphere-network"
# type = "STANDARD"
# # TODO: check if this needs to be set to `global` (it should according tf docs).
# location = "us-central1"
# description = "network for vSphere CI."
# }
6 changes: 6 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/vsphere/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See the OWNERS docs at https://go.k8s.io/owners

approvers:
- chrischdi
- sbueringer
- fabriziopandini
21 changes: 21 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/vsphere/content-library.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
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 "vsphere_content_library" "capv" {
name = "capv"
description = "Content Library for CAPV."
storage_backing = [data.vsphere_datastore.datastore.id]
}
42 changes: 42 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/vsphere/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
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.
*/

data "vsphere_datacenter" "datacenter" {
name = var.vsphere_datacenter
}

data "vsphere_compute_cluster" "compute_cluster" {
name = var.vsphere_cluster
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_datastore" "datastore" {
name = var.vsphere_datastorename
datacenter_id = data.vsphere_datacenter.datacenter.id
}

data "vsphere_role" "read-only" {
label = "Read-only"
}

data "vsphere_role" "no-access" {
label = "No access"
}

data "vsphere_network" "network" {
name = var.vsphere_network_name
datacenter_id = data.vsphere_datacenter.datacenter.id
}
27 changes: 27 additions & 0 deletions infra/gcp/terraform/k8s-infra-vsphere/vsphere/folders.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
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 "vsphere_folder" "prow" {
path = "prow"
type = "vm"
datacenter_id = data.vsphere_datacenter.datacenter.id
}

resource "vsphere_folder" "templates" {
path = "${vsphere_folder.prow.path}/templates"
type = "vm"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
Loading