-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ibm cluster creation #5023
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
Merged
openshift-merge-robot
merged 22 commits into
openshift:master
from
BobbyRadford:ibm-cluster-creation
Jul 6, 2021
Merged
Ibm cluster creation #5023
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
15c2b8e
ibmcloud: add machinepool type and validation
BobbyRadford 5d37069
ibmcloud: Add initial Terraform module
hasueki 25ffdba
fix(terraform): Remove ingress LB components
hasueki 4b50472
ibmcloud: shim create manifests
BobbyRadford 9f994ec
ibmcloud: implement cloud creds
BobbyRadford d0c88e4
ibmcloud: add cloud-provider-config support
BobbyRadford d6a5f95
ibmcloud: Add create cluster support
hasueki 3f730a3
ibmcloud: Set bootstrap + master instance types
hasueki a6e4a0a
ibmcloud: Support bootstrap removal
hasueki a5282e1
ibmcloud: automate the rhcos image upload
BobbyRadford 0714528
ibmcloud: Attach tags on TF resources
hasueki 5dd81b5
ibmcloud: Support publish strategy modes
hasueki 5542b83
ibmcloud: populate Machine and MachineSet manifests
BobbyRadford 704c5af
ibmcloud: Add InstallConfig Metadata
BobbyRadford 9a41d75
fix: Go formatting and linting
BobbyRadford 282d428
fix: Rebase issues
hasueki 99de2a5
fix(ibmcloud): Check for nil listZonesResponse
BobbyRadford 6135d4a
chore(ibmcloud): Format terraform module
hasueki e1646dd
update go.mod
hasueki f71d18f
update vendor
hasueki 6ced83f
fix: Address PR comments
BobbyRadford 7611c0d
fix: Add TODO for future ignition support
BobbyRadford File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ############################################ | ||
| # COS bucket | ||
| ############################################ | ||
|
|
||
| resource "ibm_cos_bucket" "bootstrap_ignition" { | ||
| bucket_name = "${local.prefix}-bootstrap-ignition" | ||
| resource_instance_id = var.cos_resource_instance_id | ||
| region_location = var.cos_bucket_region | ||
| storage_class = "smart" | ||
| } | ||
|
|
||
| ############################################ | ||
| # COS object | ||
| ############################################ | ||
|
|
||
| resource "ibm_cos_bucket_object" "bootstrap_ignition" { | ||
| bucket_crn = ibm_cos_bucket.bootstrap_ignition.crn | ||
| bucket_location = ibm_cos_bucket.bootstrap_ignition.region_location | ||
| key = "bootstrap.ign" | ||
| content_file = var.ignition_file | ||
| etag = filemd5(var.ignition_file) | ||
| } | ||
|
|
||
| ############################################ | ||
| # IAM service credentials | ||
| ############################################ | ||
|
|
||
| # NOTE/TODO: Get IAM token for created Service ID, not supported in provider | ||
| data "ibm_iam_auth_token" "iam_token" {} | ||
|
|
||
| # NOTE: Not used at the moment | ||
| # resource "ibm_iam_service_id" "cos" { | ||
| # name = "${local.prefix}-cos-service-id" | ||
| # } | ||
|
|
||
| # NOTE: Not used at the moment | ||
| # resource "ibm_resource_key" "cos_reader" { | ||
| # name = "${local.prefix}-cos-reader" | ||
| # role = "Reader" | ||
| # resource_instance_id = ibm_resource_instance.cos.id | ||
| # parameters = { | ||
| # HMAC = true | ||
| # serviceid_crn = ibm_iam_service_id.cos.crn | ||
| # } | ||
| # } | ||
|
|
||
| # NOTE: Not used at the moment | ||
| # resource "ibm_resource_key" "cos_writer" { | ||
| # name = "${local.prefix}-cos-writer" | ||
| # role = "Writer" | ||
| # resource_instance_id = ibm_resource_instance.cos.id | ||
| # parameters = { | ||
| # HMAC = true | ||
| # serviceid_crn = ibm_iam_service_id.cos.crn | ||
| # } | ||
| # } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| locals { | ||
| prefix = var.cluster_id | ||
| port_kubernetes_api = 6443 | ||
| port_machine_config = 22623 | ||
| } | ||
|
|
||
| ############################################ | ||
| # Bootstrap node | ||
| ############################################ | ||
|
|
||
| resource "ibm_is_instance" "bootstrap_node" { | ||
| name = "${local.prefix}-bootstrap" | ||
| image = var.vsi_image_id | ||
| profile = var.vsi_profile | ||
| resource_group = var.resource_group_id | ||
| tags = var.tags | ||
|
|
||
| primary_network_interface { | ||
| name = "eth0" | ||
| subnet = var.subnet_id | ||
| security_groups = [var.security_group_id] | ||
| } | ||
|
|
||
| vpc = var.vpc_id | ||
| zone = var.zone | ||
| keys = [] | ||
|
|
||
| # Use custom ignition config that pulls content from COS bucket | ||
| # TODO: Once support for the httpHeaders field is added to | ||
| # terraform-provider-ignition, we should use it instead of this template. | ||
| # https://github.com/community-terraform-providers/terraform-provider-ignition/issues/16 | ||
| user_data = templatefile("${path.module}/templates/bootstrap.ign", { | ||
| HOSTNAME = ibm_cos_bucket.bootstrap_ignition.s3_endpoint_public | ||
| BUCKET_NAME = ibm_cos_bucket.bootstrap_ignition.bucket_name | ||
| OBJECT_NAME = ibm_cos_bucket_object.bootstrap_ignition.key | ||
| IAM_TOKEN = data.ibm_iam_auth_token.iam_token.iam_access_token | ||
| }) | ||
| } | ||
|
|
||
| ############################################ | ||
| # Floating IP | ||
| ############################################ | ||
|
|
||
| resource "ibm_is_floating_ip" "bootstrap_floatingip" { | ||
| count = var.public_endpoints ? 1 : 0 | ||
|
|
||
| name = "${local.prefix}-bootstrap-node-ip" | ||
| resource_group = var.resource_group_id | ||
| target = ibm_is_instance.bootstrap_node.primary_network_interface.0.id | ||
| tags = var.tags | ||
| } | ||
|
|
||
| ############################################ | ||
| # Load balancer backend pool members | ||
| ############################################ | ||
|
|
||
| resource "ibm_is_lb_pool_member" "kubernetes_api_public" { | ||
| count = var.public_endpoints ? 1 : 0 | ||
|
|
||
| lb = var.lb_kubernetes_api_public_id | ||
| pool = var.lb_pool_kubernetes_api_public_id | ||
| port = local.port_kubernetes_api | ||
| target_address = ibm_is_instance.bootstrap_node.primary_network_interface.0.primary_ipv4_address | ||
| } | ||
|
|
||
| resource "ibm_is_lb_pool_member" "kubernetes_api_private" { | ||
| lb = var.lb_kubernetes_api_private_id | ||
| pool = var.lb_pool_kubernetes_api_private_id | ||
| port = local.port_kubernetes_api | ||
| target_address = ibm_is_instance.bootstrap_node.primary_network_interface.0.primary_ipv4_address | ||
| } | ||
|
|
||
| resource "ibm_is_lb_pool_member" "machine_config" { | ||
| lb = var.lb_kubernetes_api_private_id | ||
| pool = var.lb_pool_machine_config_id | ||
| port = local.port_machine_config | ||
| target_address = ibm_is_instance.bootstrap_node.primary_network_interface.0.primary_ipv4_address | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ####################################### | ||
| # Bootstrap module outputs | ||
| ####################################### | ||
|
|
||
| output "name" { | ||
| value = ibm_is_instance.bootstrap_node.name | ||
| } | ||
|
|
||
| output "primary_ipv4_address" { | ||
| value = ibm_is_instance.bootstrap_node.primary_network_interface.0.primary_ipv4_address | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "ignition": { | ||
| "version": "3.2.0", | ||
| "config": { | ||
| "replace": { | ||
| "source": "https://${HOSTNAME}/${BUCKET_NAME}/${OBJECT_NAME}", | ||
| "httpHeaders": [ | ||
| { | ||
| "name": "Authorization", | ||
| "value": "${IAM_TOKEN}" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| ####################################### | ||
| # Bootstrap module variables | ||
| ####################################### | ||
|
|
||
| variable "cluster_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "cos_resource_instance_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "cos_bucket_region" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "ignition_file" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_kubernetes_api_public_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_kubernetes_api_private_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_pool_kubernetes_api_public_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_pool_kubernetes_api_private_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_pool_machine_config_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "public_endpoints" { | ||
| type = bool | ||
| } | ||
|
|
||
| variable "resource_group_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "security_group_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "subnet_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "tags" { | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "vpc_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "vsi_image_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "vsi_profile" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "zone" { | ||
| type = string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| ############################################ | ||
| # Datasources | ||
| ############################################ | ||
|
|
||
| data "ibm_cis_domain" "base_domain" { | ||
| cis_id = var.cis_id | ||
| domain = var.base_domain | ||
| } | ||
|
|
||
| ############################################ | ||
| # CIS DNS records (CNAME) | ||
| ############################################ | ||
|
|
||
| resource "ibm_cis_dns_record" "kubernetes_api" { | ||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "CNAME" | ||
| name = "api.${var.cluster_domain}" | ||
| content = var.lb_kubernetes_api_public_hostname != "" ? var.lb_kubernetes_api_public_hostname : var.lb_kubernetes_api_private_hostname | ||
| ttl = 60 | ||
| } | ||
|
|
||
| resource "ibm_cis_dns_record" "kubernetes_api_internal" { | ||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "CNAME" | ||
| name = "api-int.${var.cluster_domain}" | ||
| content = var.lb_kubernetes_api_private_hostname | ||
| ttl = 60 | ||
| } | ||
|
|
||
| ############################################ | ||
| # CIS DNS records (A) | ||
| ############################################ | ||
|
|
||
| resource "ibm_cis_dns_record" "bootstrap_node" { | ||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "A" | ||
| name = "${var.bootstrap_name}.${var.cluster_domain}" | ||
| content = var.bootstrap_ipv4_address | ||
| ttl = 60 | ||
| } | ||
|
|
||
| resource "ibm_cis_dns_record" "master_node" { | ||
| count = var.master_count | ||
|
|
||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "A" | ||
| name = "${var.master_name_list[count.index]}.${var.cluster_domain}" | ||
| content = var.master_ipv4_address_list[count.index] | ||
| ttl = 60 | ||
| } | ||
|
|
||
| ############################################ | ||
| # CIS DNS records (PTR) | ||
| ############################################ | ||
|
|
||
| resource "ibm_cis_dns_record" "bootstrap_node_ptr" { | ||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "PTR" | ||
| name = var.bootstrap_ipv4_address | ||
| content = "${var.bootstrap_name}.${var.cluster_domain}" | ||
| ttl = 60 | ||
| } | ||
|
|
||
| resource "ibm_cis_dns_record" "master_node_ptr" { | ||
| count = var.master_count | ||
|
|
||
| cis_id = var.cis_id | ||
| domain_id = data.ibm_cis_domain.base_domain.id | ||
| type = "PTR" | ||
| name = var.master_ipv4_address_list[count.index] | ||
| content = "${var.master_name_list[count.index]}.${var.cluster_domain}" | ||
| ttl = 60 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| ############################################ | ||
| # CIS module variables | ||
| ############################################ | ||
|
|
||
| variable "cis_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "base_domain" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "cluster_domain" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "bootstrap_name" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "bootstrap_ipv4_address" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "master_count" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "master_name_list" { | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "master_ipv4_address_list" { | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "lb_kubernetes_api_public_hostname" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "lb_kubernetes_api_private_hostname" { | ||
| type = string | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.