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

Remove providers setup from module and docs enhacement #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This module will automatically deploy Logging and Mornitoring agents onto your Kubernetes on VPC Cluster. You can either bring your own logging and monitoring instances or provision them with this architecture. This can be run on [IBM Schematics](https://cloud.ibm.com/schematics) or in your local environment.

![Logging Monitoring](../.docs/logging-monitoring-basic.png)

---

### Table of Contents
Expand Down Expand Up @@ -39,7 +37,10 @@ Variable | Type | Description | Default
`ibmcloud_api_key` | String | The IBM Cloud platform API key needed to deploy IAM enabled resources |
`generation` | String | Generation of VPC. Can be 1 or 2 | `2`
`ibm_region` | String | IBM Cloud region where all resources will be deployed |
`resource_group` | String | Name for IBM Cloud Resource Group where resources will be deployed |
`cluster_resource_group` | String | Name for IBM Cloud Resource Group where the cluster was deployed |
`logging_resource_group` | String | Name for IBM Cloud Resource Group where logging resources was or will be deployed |
`monitoring_resource_group` | String | Name for IBM Cloud Resource Group where monitoring resources was or will be deployed |
`provision_activity_tracker` | String | Provision activity tracker. Only one instance of Activity Tracker can be created in a region. Can be `true` or `false` | `false`
`cluster_name` | String | Name of the cluster where resources will be deployed |
`bring_your_own_logging` | String | True or false. A logging instance will be created if `false` | `false`
`logging_instance_name` | String | Name of logging instance. Name of the instance to be created if not bringing your own instance, otherwise use the name of your existing instance | `cluster-logging`
Expand Down
53 changes: 8 additions & 45 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,55 +1,18 @@
##############################################################################
# Provider
##############################################################################

provider ibm {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.ibm_region
ibmcloud_timeout = 60
generation = var.generation
}

##############################################################################


##############################################################################
# Resource Group
##############################################################################

data ibm_resource_group group {
name = var.resource_group
data ibm_resource_group logging_resource_group {
name = var.logging_resource_group
}

##############################################################################


##############################################################################
# Cluster Data
##############################################################################

data ibm_container_cluster_config cluster {
cluster_name_id = var.cluster_name
resource_group_id = data.ibm_resource_group.group.id
admin = true
data ibm_resource_group monitoring_resource_group {
name = var.monitoring_resource_group
}

##############################################################################


##############################################################################
# Kubernetes Provider
##############################################################################

provider kubernetes {
load_config_file = false
host = data.ibm_container_cluster_config.cluster.host
client_certificate = data.ibm_container_cluster_config.cluster.admin_certificate
client_key = data.ibm_container_cluster_config.cluster.admin_key
cluster_ca_certificate = data.ibm_container_cluster_config.cluster.ca_certificate
}

##############################################################################

##############################################################################
# Activity Tracker
##############################################################################
Expand All @@ -62,7 +25,7 @@ resource ibm_resource_instance activity_tracker {
service = "logdnaat"
plan = var.logging_plan
location = var.ibm_region
resource_group_id = data.ibm_resource_group.group.id
resource_group_id = data.ibm_resource_group.logging_resource_group.id

parameters = {
service-endpoints = var.logging_endpoint
Expand All @@ -79,7 +42,7 @@ resource ibm_resource_instance activity_tracker {

module logging {
source = "./logging"
resource_group_id = data.ibm_resource_group.group.id
resource_group_id = data.ibm_resource_group.logging_resource_group.id
use_data = var.bring_your_own_logging
ibm_region = var.ibm_region
name = var.logging_instance_name
Expand All @@ -99,7 +62,7 @@ module logging {

module monitor {
source = "./monitoring"
resource_group_id = data.ibm_resource_group.group.id
resource_group_id = data.ibm_resource_group.monitoring_resource_group.id
use_data = var.bring_your_own_monitor
ibm_region = var.ibm_region
name = var.monitor_name
Expand All @@ -111,4 +74,4 @@ module monitor {
end_points = var.service_end_points
}

##############################################################################
##############################################################################
2 changes: 1 addition & 1 deletion monitoring/namespace.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource kubernetes_namespace ibm_observe {
data kubernetes_secret image_pull_secret {
count = length(local.image_pull_secrets)
metadata {
name = "default-${element(local.image_pull_secrets, count.index)}"
name = element(local.image_pull_secrets, count.index)
}
}

Expand Down
14 changes: 12 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ variable generation {
default = 2
}

variable resource_group {
description = "Name for IBM Cloud Resource Group where resources will be deployed"
variable cluster_resource_group {
description = "Name for IBM Cloud Resource Group where the cluster was deployed"
type = string
}

variable logging_resource_group {
description = "Name for IBM Cloud Resource Group where logging resources was or will be deployed"
type = string
}

variable monitoring_resource_group {
description = "Name for IBM Cloud Resource Group where monitoring resources was or will be deployed"
type = string
}

Expand Down
3 changes: 3 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">=0.12"
}