Openshift changes (#241)

* set custom hostname in bootstrap and master

* make the service DNS zone visible to the shared VPC network

* remove unused vpc name attribute from service project variable
This commit is contained in:
Ludovico Magnocavallo 2021-05-17 13:43:26 +02:00 committed by GitHub
parent 0a647df4dc
commit 744143d793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 55 deletions

View File

@ -135,8 +135,6 @@ Variable configuration is best done in a `.tfvars` file, but can also be done di
<dd>The `machine` range should match addresses used for nodes.</dd>
<dt><code>post_bootstrap_config</code></dt>
<dd>Set to `null` until bootstrap completion, then refer to the post-bootstrap instructions below.</dd>
<dt><code>service_project</code></dt>
<dd>The <code>vpc_name</code> value is used for the placeholder VPC needed for the service project Cloud DNS zone used by the cluster. Set it to `null` to use an auto-generated name.</dd>
</dl>
### Generating ignition files

View File

@ -8,12 +8,12 @@ This example is a companion setup to the Python script in the parent folder, and
| name | description | type | required | default |
|---|---|:---: |:---:|:---:|
| cluster_name | Name used for the cluster and DNS zone. | <code title="">string</code> | ✓ | |
| disk_encryption_key | Optional CMEK for disk encryption. | <code title="object&#40;&#123;&#10;keyring &#61; string&#10;location &#61; string&#10;name &#61; string&#10;project_id &#61; string&#10;&#125;&#41;">object({...})</code> | ✓ | |
| domain | Domain name used to derive the DNS zone. | <code title="">string</code> | ✓ | |
| fs_paths | Filesystem paths for commands and data, supports home path expansion. | <code title="object&#40;&#123;&#10;credentials &#61; string&#10;config_dir &#61; string&#10;openshift_install &#61; string&#10;pull_secret &#61; string&#10;ssh_key &#61; string&#10;&#125;&#41;">object({...})</code> | ✓ | |
| host_project | Shared VPC project and network configuration. | <code title="object&#40;&#123;&#10;default_subnet_name &#61; string&#10;masters_subnet_name &#61; string&#10;project_id &#61; string&#10;vpc_name &#61; string&#10;workers_subnet_name &#61; string&#10;&#125;&#41;">object({...})</code> | ✓ | |
| service_project | Service project configuration. | <code title="object&#40;&#123;&#10;project_id &#61; string&#10;vpc_name &#61; string&#10;&#125;&#41;">object({...})</code> | ✓ | |
| service_project | Service project configuration. | <code title="object&#40;&#123;&#10;project_id &#61; string&#10;&#125;&#41;">object({...})</code> | ✓ | |
| *allowed_ranges* | Ranges that can SSH to the boostrap VM and API endpoint. | <code title="list&#40;any&#41;">list(any)</code> | | <code title="">["10.0.0.0/8"]</code> |
| *disk_encryption_key* | Optional CMEK for disk encryption. | <code title="object&#40;&#123;&#10;keyring &#61; string&#10;location &#61; string&#10;name &#61; string&#10;project_id &#61; string&#10;&#125;&#41;">object({...})</code> | | <code title="">null</code> |
| *install_config_params* | OpenShift cluster configuration. | <code title="object&#40;&#123;&#10;disk_size &#61; number&#10;network &#61; object&#40;&#123;&#10;cluster &#61; string&#10;host_prefix &#61; number&#10;machine &#61; string&#10;service &#61; string&#10;&#125;&#41;&#10;proxy &#61; object&#40;&#123;&#10;http &#61; string&#10;https &#61; string&#10;noproxy &#61; string&#10;&#125;&#41;&#10;&#125;&#41;">object({...})</code> | | <code title="&#123;&#10;disk_size &#61; 16&#10;network &#61; &#123;&#10;cluster &#61; &#34;10.128.0.0&#47;14&#34;&#10;host_prefix &#61; 23&#10;machine &#61; &#34;10.0.0.0&#47;16&#34;&#10;service &#61; &#34;172.30.0.0&#47;16&#34;&#10;&#125;&#10;proxy &#61; null&#10;&#125;">...</code> |
| *post_bootstrap_config* | Name of the service account for the machine operator. Removes bootstrap resources when set. | <code title="object&#40;&#123;&#10;machine_op_sa_prefix &#61; string&#10;&#125;&#41;">object({...})</code> | | <code title="">null</code> |
| *region* | Region where resources will be created. | <code title="">string</code> | | <code title="">europe-west1</code> |

View File

@ -39,6 +39,7 @@ resource "google_compute_instance" "bootstrap" {
count = local.bootstrapping ? 1 : 0
project = var.service_project.project_id
name = "${local.infra_id}-b"
hostname = "${local.infra_id}-bootstrap.${local.subdomain}"
machine_type = "n1-standard-4"
zone = "${var.region}-${element(var.zones, 0)}"
network_interface {

View File

@ -14,24 +14,6 @@
* limitations under the License.
*/
resource "google_dns_managed_zone" "peering" {
project = var.host_project.project_id
name = "${local.infra_id}-peering-zone"
description = "Openshift peering zone for ${local.infra_id}."
dns_name = "${local.subdomain}."
visibility = "private"
private_visibility_config {
networks {
network_url = data.google_compute_network.default.id
}
}
peering_config {
target_network {
network_url = local.dummy_network
}
}
}
resource "google_dns_managed_zone" "internal" {
project = var.service_project.project_id
name = "${local.infra_id}-private-zone"
@ -40,7 +22,7 @@ resource "google_dns_managed_zone" "internal" {
visibility = "private"
private_visibility_config {
networks {
network_url = local.dummy_network
network_url = data.google_compute_network.default.id
}
}
}
@ -54,15 +36,3 @@ resource "google_dns_record_set" "dns" {
ttl = 60
rrdatas = [google_compute_address.api.address]
}
/*
resource "google_dns_record_set" "apps" {
count = local.router_address == null ? 0 : 1
project = var.service_project.project_id
name = "*.apps.${var.cluster_name}.${var.domain}."
managed_zone = google_dns_managed_zone.internal.name
type = "A"
ttl = 60
rrdatas = [local.router_address]
}
*/

View File

@ -22,11 +22,6 @@ locals {
? null
: data.google_kms_crypto_key.default.0.id
)
dummy_network = (
var.service_project.vpc_name != null
? data.google_compute_network.dummy.0.id
: google_compute_network.dummy.0.id
)
fs_paths = { for k, v in var.fs_paths : k => pathexpand(v) }
infra_id = local.install_metadata["infraID"]
install_metadata = jsondecode(file(
@ -52,19 +47,6 @@ data "google_compute_subnetwork" "default" {
name = var.host_project["${each.key}_subnet_name"]
}
resource "google_compute_network" "dummy" {
count = var.service_project.vpc_name == null ? 1 : 0
project = var.service_project.project_id
name = "${local.infra_id}-dns"
auto_create_subnetworks = false
}
data "google_compute_network" "dummy" {
count = var.service_project.vpc_name == null ? 0 : 1
project = var.service_project.project_id
name = var.service_project.vpc_name
}
data "google_kms_key_ring" "default" {
count = var.disk_encryption_key == null ? 0 : 1
project = var.disk_encryption_key.project_id

View File

@ -17,7 +17,8 @@
resource "google_compute_instance" "master" {
for_each = toset(var.zones)
project = var.service_project.project_id
name = "${local.infra_id}-m-${each.key}"
name = "${local.infra_id}-master-${each.key}"
hostname = "${local.infra_id}-master-${each.key}.${local.subdomain}"
machine_type = "n1-standard-4"
zone = "${var.region}-${each.key}"
network_interface {

View File

@ -121,7 +121,6 @@ variable "service_project" {
description = "Service project configuration."
type = object({
project_id = string
vpc_name = string
})
}