Skip to content

Commit

Permalink
Merge pull request #498 from Prajyot-Parab/cis_test
Browse files Browse the repository at this point in the history
Support adding DNS entries for CIS service based cluster domain
  • Loading branch information
ppc64le-cloud-bot authored Nov 21, 2023
2 parents 70d6e4c + febfb96 commit 226d605
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ Once the deployment is completed successfully, you can safely delete the bootstr

Please skip this section if your `cluster_domain` is one of the online wildcard DNS domains: nip.io, xip.io and sslip.io. Also, not required when using `use_ibm_cloud_services = true`.

>**Note**: If you just need to add the DNS entries in the CIS domain zone without using IBM Cloud Services eg: VPC Load Balancer, then set `ibm_cloud_cis_crn` with the CIS domain CRN and keep `use_ibm_cloud_services = false`.
For all other domains, you can use one of the following options.

1. **Add entries to your DNS server**
Expand Down
48 changes: 48 additions & 0 deletions modules/8_custom/cis.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
################################################################
#
# 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
#
# Licensed Materials - Property of IBM
#
# ©Copyright IBM Corp. 2023
#
# 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.
#
################################################################

#####################################
##### DNS
#####################################

data "ibm_cis_domain" "domain" {
cis_id = var.ibm_cloud_cis_crn
domain = var.cluster_domain
}

#####################################
##### Kubernetes
#####################################
resource "ibm_cis_dns_record" "api" {
cis_id = var.ibm_cloud_cis_crn
content = var.bastion_public_ip
domain_id = data.ibm_cis_domain.domain.id
name = "api.${var.cluster_id}.${var.cluster_domain}"
ttl = 900
type = "A"
}
resource "ibm_cis_dns_record" "apps" {
cis_id = var.ibm_cloud_cis_crn
content = var.bastion_public_ip
domain_id = data.ibm_cis_domain.domain.id
name = "*.apps.${var.cluster_id}.${var.cluster_domain}"
ttl = 900
type = "A"
}
30 changes: 30 additions & 0 deletions modules/8_custom/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
################################################################
#
# 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
#
# Licensed Materials - Property of IBM
#
# ©Copyright IBM Corp. 2023
#
# 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 "cluster_domain" {
default = "example.com"
}
variable "cluster_id" {
default = "test-ocp"
}

variable "ibm_cloud_cis_crn" {}

variable "bastion_public_ip" {}
29 changes: 29 additions & 0 deletions modules/8_custom/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
################################################################
#
# 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
#
# Licensed Materials - Property of IBM
#
# ©Copyright IBM Corp. 2023
#
# 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.
#
################################################################

terraform {
required_providers {
ibm = {
source = "ibm-cloud/ibm"
version = "~> 1.54.0"
}
}
required_version = ">= 1.2.0"
}
11 changes: 11 additions & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,14 @@ module "ibmcloud" {
vpc_subnet_id = var.use_ibm_cloud_services ? data.ibm_is_subnet.vpc_subnet[0].id : ""
ibm_cloud_cis_crn = var.ibm_cloud_cis_crn
}

module "custom" {
count = var.ibm_cloud_cis_crn != "" && !var.use_ibm_cloud_services ? 1 : 0
source = "./modules/8_custom"
depends_on = [module.install]

cluster_domain = module.nodes.cluster_domain
cluster_id = local.cluster_id
bastion_public_ip = lookup(var.bastion, "count", 1) > 1 ? module.prepare.bastion_external_vip : module.prepare.bastion_public_ip[0]
ibm_cloud_cis_crn = var.ibm_cloud_cis_crn
}

0 comments on commit 226d605

Please sign in to comment.