/huawei-cloud-k8s-config-tf-module

Module to configure a k8s CCE cluster receiving a kubeconfig file content as input with a list of services to expose with a dynamic ingress block.

Primary LanguageHCLCreative Commons Zero v1.0 UniversalCC0-1.0

Description

Module to configure a k8s cluster receiving a kubeconfig file content as input with a list of services to expose with a dynamic ingress block.

Special notes

An empty kubeconfig file is required to workaround the first provider load. In apply time, kubeconfig file is changed by a generated file that contains the right cluster configuration.

Well integrated with the CCE Cluster module created also by me.

Requirements

Name Version
kubernetes ~> 2.8.0

Providers

Name Version
kubernetes ~> 2.8.0
local n/a

Resources

Name Type
kubernetes_deployment.api resource
kubernetes_ingress_v1.ingress resource
kubernetes_secret_v1.secret_tls resource
kubernetes_service.api_service resource
local_file.kubeconfig resource

Inputs

Name Description Type Default Required
environment n/a string n/a yes
hostname n/a string n/a yes
kubeconfig Kubeconfig file content string n/a yes
load_balancer_id n/a string n/a yes
load_balancer_ip n/a string n/a yes
load_balancer_port Load balancer listener port string "80" no
project n/a string n/a yes
service_list n/a
list(object({
api_name = string
replicas = number
docker_image = string
container_port = number
port_name = string
url_path = string }))
n/a yes
ssl_cert SSL certificate to use with HTTPS Listener. Required if use 443 as port string "" no
ssl_key SSL key associated with ssl cert. Required if use 443 as port string "" no

Example Usage

module "k8s_config" {
  source       = "git@github.com:abejarano/huawei-cloud-k8s-config-tf-module"
  project      = var.project
  environment  = var.environment
  kubeconfig   = module.k8s_cluster.kubeconfig
  service_list = local.services
  load_balancer_id = module.k8s_cluster.load_balancer_id
  load_balancer_ip = module.k8s_cluster.load_balancer_eip
  hostname         = "test.com"
  load_balancer_port = "443"
  ssl_cert = var.ssl_cert
  ssl_key = var.ssl_key
}

locals {
  services = [
    {
      api_name       = "nginx"
      replicas       = 2
      docker_image   = "nginx:1.8"
      container_port = 80
      port_name      = "http"
      url_path       = "/"
    }
  ]
}