forked from David-VTUK/RancherNSXTTerraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rancher_core.tf
86 lines (79 loc) · 2.22 KB
/
rancher_core.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
provider "rancher2" {
api_url = "https://rancher.virtualthoughts.co.uk"
access_key = var.rancher2_access_key
secret_key = var.rancher2_secret_key
insecure = "true"
}
# Create a new rancher2 Cloud Credential
resource "rancher2_cloud_credential" "vsphere-terraform" {
name = "vsphere-terraform"
description = "Terraform Credentials"
vsphere_credential_config {
username = "Terraform@vsphere.local"
password = "Terraform123!"
vcenter = "svr-vcs-01.virtualthoughts.co.uk"
}
}
resource "rancher2_node_template" "vSphere-NSXT-Template" {
name = "vSphere-NSXT-Template"
description = "Created by Terraform"
cloud_credential_id = rancher2_cloud_credential.vsphere-terraform.id
vsphere_config {
cfgparam = ["disk.enableUUID=TRUE"]
clone_from = var.template_name
cpu_count = var.template_num_cpu
creation_type = "template"
disk_size = var.template_disk_size
memory_size = var.node_mem_size
datastore = var.node_datastore
datacenter = var.node_datacenter
pool = var.node_resourcepool
network = [nsxt_logical_switch.k8s-mgmt.display_name ,nsxt_logical_switch.k8s-overlay.display_name]
}
depends_on = [
nsxt_logical_switch.k8s-overlay,
nsxt_logical_switch.k8s-mgmt
]
provisioner "local-exec" {
command = "sleep 10"
}
}
# Create a new rancher2 Node Pool
resource "rancher2_node_pool" "nodepool" {
cluster_id = rancher2_cluster.vsphere-test-nsxt.id
name = "all-in-one"
hostname_prefix = "vsphere-nsxt-cluster-"
node_template_id = rancher2_node_template.vSphere-NSXT-Template.id
quantity = 1
control_plane = true
etcd = true
worker = true
provisioner "local-exec" {
command = "sleep 60"
}
}
# Create a new rancher2 RKE Cluster
resource "rancher2_cluster" "vsphere-test-nsxt" {
name = "vsphere-test-nsxt"
description = "Terraform created vSphere Cluster"
rke_config {
kubernetes_version = "v1.16.6-rancher1-2"
network {
plugin = "none"
}
services {
kubelet {
extra_binds = [
"/var/cache/:/var/cache/",
"/sbin/apparmor_parser:/sbin/apparmor_parser",
]
}
kube_api {
extra_args = {
"allow-privileged" = true
}
}
}
addons = template_file.policy.rendered
}
}