Skip to content

Commit

Permalink
Fix VPC cluster example and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare committed Oct 30, 2019
1 parent 7ca6a8a commit 5c3d3b9
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 64 deletions.
1 change: 1 addition & 0 deletions examples/ibm-cluster/vpc-classic-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

This example shows how to create a Kubernetes VPC Cluster under a specified resource group id, with default worker node with given zone and subnets.
To have a multizone cluster, update the zones with new zone-name and subnet-id.
It also creates a additional worker pool on different zone. After successfull creation of cluster it binds the cloud-object-storage service.
To run, configure your IBM Cloud provider

Running the example
Expand Down
85 changes: 58 additions & 27 deletions examples/ibm-cluster/vpc-classic-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -1,55 +1,86 @@
provider "ibm" {}
provider "ibm" {
generation = 1
}

resource "random_id" "name1" {
byte_length = 2
}

resource "random_id" "name2" {
byte_length = 2
}

locals {
ZONE1 = "${var.region}-1"
ZONE2 = "${var.region}-2"
}

data "ibm_org" "org" {
org = "${var.org}"
resource "ibm_is_vpc" "vpc1" {
name = "vpc-${random_id.name1.hex}"
}

data "ibm_space" "space" {
org = "${var.org}"
space = "${var.space}"
resource "ibm_is_subnet" "subnet1" {
name = "subnet-${random_id.name1.hex}"
vpc = "${ibm_is_vpc.vpc1.id}"
zone = "${local.ZONE1}"
total_ipv4_address_count = 256
}

resource "ibm_is_subnet" "subnet2" {
name = "subnet-${random_id.name2.hex}"
vpc = "${ibm_is_vpc.vpc1.id}"
zone = "${local.ZONE2}"
total_ipv4_address_count = 256
}

data "ibm_resource_group" "resource_group" {
name = "Default"
name = "${var.resource_group}"
}

resource "ibm_container_vpc_cluster" "cluster" {
name = "${var.cluster_name}${random_id.name.hex}"
vpc_id = "${var.vpc_id}"
name = "${var.cluster_name}${random_id.name1.hex}"
vpc_id = "${ibm_is_vpc.vpc1.id}"
flavor = "${var.flavor}"
worker_count = "${var.worker_count}"
resource_group_id = "${data.ibm_resource_group.resource_group.id}"

zones = [
{
subnet_id = "${var.subnet_id}"
name = "${var.zone_name}"
}
{
subnet_id = "${ibm_is_subnet.subnet1.id}"
name = "${local.ZONE1}"
},
]
}

resource "ibm_service_instance" "service" {
name = "${var.service_instance_name}${random_id.name.hex}"
space_guid = "${data.ibm_space.space.id}"
service = "${var.service_offering}"
plan = "${var.plan}"
tags = ["my-service"]
resource "ibm_container_vpc_worker_pool" "cluster_pool" {
cluster = "${ibm_container_vpc_cluster.cluster.id}"
worker_pool_name = "${var.worker_pool_name}${random_id.name1.hex}"
flavor = "${var.flavor}"
vpc_id = "${ibm_is_vpc.vpc1.id}"
worker_count = "${var.worker_count}"
resource_group_id = "${data.ibm_resource_group.resource_group.id}"
zones = [
{
name = "${local.ZONE2}"
subnet_id = "${ibm_is_subnet.subnet2.id}"
},
]
}

resource "ibm_service_key" "key" {
name = "${var.service_key}"
service_instance_guid = "${ibm_service_instance.service.id}"
resource "ibm_resource_instance" "cos_instance" {
name = "${var.service_instance_name}"
service = "cloud-object-storage"
plan = "standard"
location = "global"
}

resource "ibm_container_bind_service" "bind_service" {
cluster_name_id = "${ibm_container_vpc_cluster.cluster.id}"
service_instance_id = "${ibm_service_instance.service.id}"
service_instance_id = "${element(split(":",ibm_resource_instance.cos_instance.id),7)}"
namespace_id = "default"
role = "Writer"
}

data "ibm_container_cluster_config" "cluster_config" {
cluster_name_id = "${ibm_container_vpc_cluster.cluster.id}"
}

resource "random_id" "name" {
byte_length = 4
}
30 changes: 16 additions & 14 deletions examples/ibm-cluster/vpc-classic-cluster/variables.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
variable "org" {}

variable "space"{}

variable "subnet_id" {}

variable "vpc_id" {}
variable "flavor" {
default = "c2.2x4"
}

variable "flavor" {}
variable "worker_count" {
default = "1"
}

variable "worker_count" {}
variable "region" {
default = "us-south"
}

variable "zone_name" {}
variable "resource_group" {
default = "default"
}

variable "cluster_name" {
default = "cluster"
}

variable "service_instance_name" {
default = "myservice"
variable "worker_pool_name" {
default = "workerpool"
}

variable "service_key" {
default = "myservicekey"
variable "service_instance_name" {
default = "myservice"
}

variable "service_offering" {
Expand Down
6 changes: 2 additions & 4 deletions website/docs/d/container_vpc_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ description: |-
Import the details of a Kubernetes VPC cluster on IBM Cloud as a read-only data source.
## Example Usage
```
```hcl
data "ibm_container_vpc_cluster" "cluster" {
cluster_name_id = "no-zones-tf"
resource_group_id = "${data.ibm_resource_group.group.id}"
}
```
## Argument Reference
The following arguments are supported:

* `cluster_name_id` - (Required, string) Name of the Cluster
* `resource_group_id` - (Optional, string) The ID of the resource group. You can retrieve the value from data source `ibm_resource_group`. If not provided defaults to default resource group.
* `alb_type` - (Optional, string) ALB type of a Cluster
Expand Down
31 changes: 12 additions & 19 deletions website/docs/d/container_vpc_cluster_worker.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,36 @@ description: |-
Manages IBM VPC container cluster worker.
---
# ibm\_container_vpc_cluster
# ibm\_container_vpc_cluster_worker
Import details of a worker node of a Kubernetes VPC cluster as a read-only data source.

## Example Usage
```hcl
data "ibm_container_cluster_worker" "worker_foo" {
worker_id = "dev-mex10-pa70c4414695c041518603bfd0cd6e333a-w1"
worker_id = "dev-mex10-pa70c4414695c041518603bfd0cd6e333a-w1"
cluster_name_id = "test"
}
```

## Argument Reference
The following arguments are supported:

The following arguments are supported:

* `worker_id` - (Required, string) The name of the worker pool.
* `cluster_name_id` - (Required, string) The name or id of the cluster.
* `flavor` - (Required, string) The flavour of the worker node.
* `kube_version` - (Required, string) The Kubernetes version, including at least the major.minor version.To see available versions, run 'ibmcloud ks versions'.
* `resource_group_id` - (Optional, string) The ID of the resource group. You can retrieve the value from data source `ibm_resource_group`. If not provided defaults to default resource group.

## Attribute Reference
The following attributes are exported:

* `State` - State of worker.
* `pool_id` - Id of Worker pool.
* `pool_name`- Name of the worker pool
* `network_interfaces`- Network Interface of the cluster
* `cidr`- cidr of the network
* `ip_address`- Ip Address of the worker pool
* `subnet_id`- The worker pool subnet id to assign the cluster.
* `cidr`- cidr of the network
* `ip_address`- Ip Address of the worker pool
* `subnet_id`- The worker pool subnet id to assign the cluster.

0 comments on commit 5c3d3b9

Please sign in to comment.