Skip to content

Commit 62c6545

Browse files
authored
Merge pull request #72 from khanh-ph/release/3.3.0
Release version 3.3.0
2 parents 8c40bbe + ab18323 commit 62c6545

File tree

10 files changed

+184
-84
lines changed

10 files changed

+184
-84
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,32 @@ jobs:
2525

2626
- name: Check Terraform format and syntax
2727
id: test
28-
run: make test
28+
run: make test
29+
tflint:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
name: Checkout source code
34+
35+
- uses: actions/cache@v3
36+
name: Cache plugin dir
37+
with:
38+
path: ~/.tflint.d/plugins
39+
key: ubuntu-latest-tflint-${{ hashFiles('.tflint.hcl') }}
40+
41+
- uses: terraform-linters/setup-tflint@v3
42+
name: Setup TFLint
43+
with:
44+
tflint_version: v0.47.0
45+
46+
- name: Show version
47+
run: tflint --version
48+
49+
- name: Init TFLint
50+
run: tflint --init
51+
env:
52+
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
53+
GITHUB_TOKEN: ${{ github.token }}
54+
55+
- name: Run TFLint
56+
run: tflint -f compact

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.81.2
4+
hooks:
5+
- id: terraform_fmt
6+
- id: terraform_validate
7+
- id: terraform_tflint
8+
args:
9+
- --args=--format=compact
10+
- id: terraform_docs
11+
args:
12+
- --args=--config=.terraform-docs-config.yaml

.terraform-docs-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
formatter: "md"
2+
3+
sections:
4+
show:
5+
- inputs
6+
7+
sort:
8+
enabled: false
9+
by: name
10+
11+
settings:
12+
anchor: true
13+
color: true
14+
default: true
15+
description: false
16+
escape: true
17+
hide-empty: false
18+
html: true
19+
indent: 3
20+
lockfile: true
21+
read-comments: true
22+
required: true
23+
sensitive: true
24+
type: true

README.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Ensure the following software versions are installed:
1313
* [Proxmox VE](https://www.proxmox.com/en/proxmox-ve/get-started/) `>=7.3.3`
1414
* [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli/) `>=1.3.3`
1515

16-
> Kubespray has been set up automatically.
16+
> Kubespray will be set up automatically.
1717
1818
### System requirements
1919

@@ -42,56 +42,63 @@ Follow these steps to use the project:
4242
$ terraform init
4343
```
4444

45-
4. Generate execution plan and review the output to ensure that the planned changes align with your expectations.
45+
4. Generate an execution plan and review the output to ensure that the planned changes align with your expectations.
4646

4747
```sh
4848
$ terraform plan -var-file="example.tfvars"
4949
```
5050

51-
5. If you're satisfy with the plan and ready to apply the changes. Run the following command:
51+
5. If you're satisfied with the plan and ready to apply the changes. Run the following command:
5252
5353
```sh
5454
$ terraform apply -var-file="example.tfvars"
5555
```
5656
57-
## Configurations
57+
## Terraform configurations
5858
5959
The project provides several Terraform variables that allow you to customize the cluster to suit your needs. Please see the following:
6060
61-
### Mandatory variables
62-
63-
Below are the mandatory variables:
64-
65-
* `env_name`
66-
* `pm_api_url`
67-
* `pm_api_token_id`
68-
* `pm_api_token_secret`
69-
* `pm_tls_insecure`
70-
* `pm_host`
71-
* `internal_net_name`
72-
* `internal_net_subnet_cidr`
73-
* `bastion_ssh_port`
74-
* `bastion_ssh_ip`
75-
* `bastion_ssh_user`
76-
* `ssh_public_keys`
77-
* `ssh_private_key`
78-
* `vm_max_vcpus`
79-
* `vm_k8s_control_plane`
80-
* `vm_k8s_worker`
81-
82-
### Kubespray variables (optional)
83-
84-
You may also configure the following optional variables specific to Kubespray:
85-
86-
* `kube_version`
87-
* `kube_network_plugin`
88-
* `enable_nodelocaldns`
89-
* `podsecuritypolicy_enabled`
90-
* `persistent_volumes_enabled`
91-
* `helm_enabled`
92-
* `ingress_nginx_enabled`
93-
* `argocd_enabled`
94-
* `argocd_version`
61+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
62+
### Inputs
63+
64+
| Name | Description | Type | Default | Required |
65+
|------|-------------|------|---------|:--------:|
66+
| <a name="input_pm_api_url"></a> [pm\_api\_url](#input\_pm\_api\_url) | The base URL for Proxmox VE API. See https://pve.proxmox.com/wiki/Proxmox_VE_API#API_URL | `string` | n/a | yes |
67+
| <a name="input_pm_api_token_id"></a> [pm\_api\_token\_id](#input\_pm\_api\_token\_id) | The token ID to access Proxmox VE API. | `string` | n/a | yes |
68+
| <a name="input_pm_api_token_secret"></a> [pm\_api\_token\_secret](#input\_pm\_api\_token\_secret) | The UUID/secret of the token defined in the variable `pm_api_token_id`. | `string` | n/a | yes |
69+
| <a name="input_pm_tls_insecure"></a> [pm\_tls\_insecure](#input\_pm\_tls\_insecure) | Disable TLS verification while connecting to the Proxmox VE API server. | `bool` | n/a | yes |
70+
| <a name="input_pm_host"></a> [pm\_host](#input\_pm\_host) | The name of Proxmox node where the VM is placed. | `string` | n/a | yes |
71+
| <a name="input_env_name"></a> [env\_name](#input\_env\_name) | n/a | `string` | `"test"` | no |
72+
| <a name="input_internal_net_name"></a> [internal\_net\_name](#input\_internal\_net\_name) | Name of the internal network bridge. | `string` | `"vmbr1"` | no |
73+
| <a name="input_internal_net_subnet_cidr"></a> [internal\_net\_subnet\_cidr](#input\_internal\_net\_subnet\_cidr) | CIDR of the internal network. For example: 10.0.1.0/24 | `string` | `""` | no |
74+
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input\_ssh\_private\_key) | SSH private key in base64. Used by Terraform client to connect to the VM after provisioning. | `string` | n/a | yes |
75+
| <a name="input_ssh_public_keys"></a> [ssh\_public\_keys](#input\_ssh\_public\_keys) | SSH public keys in base64. | `string` | n/a | yes |
76+
| <a name="input_vm_user"></a> [vm\_user](#input\_vm\_user) | n/a | `string` | `"ubuntu"` | no |
77+
| <a name="input_vm_sockets"></a> [vm\_sockets](#input\_vm\_sockets) | n/a | `number` | `1` | no |
78+
| <a name="input_vm_max_vcpus"></a> [vm\_max\_vcpus](#input\_vm\_max\_vcpus) | The maximum CPU cores available per CPU socket to allocate to the VM. | `number` | `2` | no |
79+
| <a name="input_vm_cpu_type"></a> [vm\_cpu\_type](#input\_vm\_cpu\_type) | The type of CPU to emulate in the Guest | `string` | `"host"` | no |
80+
| <a name="input_vm_os_disk_storage"></a> [vm\_os\_disk\_storage](#input\_vm\_os\_disk\_storage) | Default storage pool where OS VM disk is placed. | `string` | n/a | yes |
81+
| <a name="input_add_worker_node_data_disk"></a> [add\_worker\_node\_data\_disk](#input\_add\_worker\_node\_data\_disk) | A boolean value that indicates whether to add a data disk to each worker node of the cluster. | `bool` | `false` | no |
82+
| <a name="input_worker_node_data_disk_storage"></a> [worker\_node\_data\_disk\_storage](#input\_worker\_node\_data\_disk\_storage) | The storage pool where the data disk is placed. | `string` | `""` | no |
83+
| <a name="input_worker_node_data_disk_size"></a> [worker\_node\_data\_disk\_size](#input\_worker\_node\_data\_disk\_size) | The size of worker node data disk in Gigabyte. | `string` | `10` | no |
84+
| <a name="input_vm_ubuntu_tmpl_name"></a> [vm\_ubuntu\_tmpl\_name](#input\_vm\_ubuntu\_tmpl\_name) | Name of Cloud-init template Ubuntu VM. | `string` | `"ubuntu-2204"` | no |
85+
| <a name="input_bastion_ssh_ip"></a> [bastion\_ssh\_ip](#input\_bastion\_ssh\_ip) | IP of the bastion host. It could be either public IP or local network IP of the bastion host. | `string` | `""` | no |
86+
| <a name="input_bastion_ssh_user"></a> [bastion\_ssh\_user](#input\_bastion\_ssh\_user) | n/a | `string` | `"ubuntu"` | no |
87+
| <a name="input_bastion_ssh_port"></a> [bastion\_ssh\_port](#input\_bastion\_ssh\_port) | n/a | `number` | `22` | no |
88+
| <a name="input_create_kubespray_host"></a> [create\_kubespray\_host](#input\_create\_kubespray\_host) | n/a | `bool` | `true` | no |
89+
| <a name="input_kubespray_image"></a> [kubespray\_image](#input\_kubespray\_image) | n/a | `string` | `"khanhphhub/kubespray:v2.22.0"` | no |
90+
| <a name="input_kube_version"></a> [kube\_version](#input\_kube\_version) | Kubernetes version | `string` | `"v1.24.6"` | no |
91+
| <a name="input_kube_network_plugin"></a> [kube\_network\_plugin](#input\_kube\_network\_plugin) | Choose network plugin (cilium, calico, kube-ovn, weave or flannel. Use cni for generic cni plugin) | `string` | `"calico"` | no |
92+
| <a name="input_enable_nodelocaldns"></a> [enable\_nodelocaldns](#input\_enable\_nodelocaldns) | Enable nodelocal dns cache | `bool` | `false` | no |
93+
| <a name="input_podsecuritypolicy_enabled"></a> [podsecuritypolicy\_enabled](#input\_podsecuritypolicy\_enabled) | pod security policy (RBAC must be enabled either by having 'RBAC' in authorization\_modes or kubeadm enabled) | `bool` | `false` | no |
94+
| <a name="input_persistent_volumes_enabled"></a> [persistent\_volumes\_enabled](#input\_persistent\_volumes\_enabled) | Add Persistent Volumes Storage Class for corresponding cloud provider (supported: in-tree OpenStack, Cinder CSI, AWS EBS CSI, Azure Disk CSI, GCP Persistent Disk CSI) | `bool` | `false` | no |
95+
| <a name="input_helm_enabled"></a> [helm\_enabled](#input\_helm\_enabled) | Helm deployment | `bool` | `false` | no |
96+
| <a name="input_ingress_nginx_enabled"></a> [ingress\_nginx\_enabled](#input\_ingress\_nginx\_enabled) | Nginx ingress controller deployment | `bool` | `false` | no |
97+
| <a name="input_argocd_enabled"></a> [argocd\_enabled](#input\_argocd\_enabled) | ArgoCD | `bool` | `false` | no |
98+
| <a name="input_argocd_version"></a> [argocd\_version](#input\_argocd\_version) | ArgoCD version | `string` | `"v2.4.12"` | no |
99+
| <a name="input_vm_k8s_control_plane"></a> [vm\_k8s\_control\_plane](#input\_vm\_k8s\_control\_plane) | Control Plane VM specification | `object({ node_count = number, vcpus = number, memory = number, disk_size = number })` | <pre>{<br> "disk_size": 20,<br> "memory": 1536,<br> "node_count": 1,<br> "vcpus": 2<br>}</pre> | no |
100+
| <a name="input_vm_k8s_worker"></a> [vm\_k8s\_worker](#input\_vm\_k8s\_worker) | Worker VM specification | `object({ node_count = number, vcpus = number, memory = number, disk_size = number })` | <pre>{<br> "disk_size": 20,<br> "memory": 2048,<br> "node_count": 2,<br> "vcpus": 2<br>}</pre> | no |
101+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
95102
96103
## Blog posts
97104

modules/proxmox_ubuntu_vm/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ resource "proxmox_vm_qemu" "ubuntu_vm" {
3939
iothread = 1
4040
}
4141

42+
dynamic "disk" {
43+
for_each = var.add_worker_node_data_disk ? [var.worker_node_data_disk_size] : []
44+
45+
content {
46+
slot = 1
47+
type = "virtio"
48+
storage = var.worker_node_data_disk_storage
49+
size = "${var.worker_node_data_disk_size}G"
50+
iothread = 1
51+
}
52+
}
53+
4254
network {
4355
model = "virtio"
4456
bridge = var.vm_net_name

modules/proxmox_ubuntu_vm/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ variable "vm_host_number" {
9696
description = "The host number of the VM in the subnet"
9797
}
9898

99+
variable "add_worker_node_data_disk" {
100+
type = bool
101+
description = "A boolean value that indicates whether to add a data disk to each worker node of the cluster."
102+
default = false
103+
}
104+
105+
variable "worker_node_data_disk_storage" {
106+
type = string
107+
description = "The storage pool where the data disk is placed."
108+
default = ""
109+
}
110+
111+
variable "worker_node_data_disk_size" {
112+
type = string
113+
description = "The size of worker node data disk in Gigabyte."
114+
default = 10
115+
}
116+
99117
#
100118
# Local vars
101119
#

providers.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ terraform {
66
source = "telmate/proxmox"
77
version = "2.9.14"
88
}
9+
null = {
10+
source = "hashicorp/null"
11+
version = "3.2.1"
12+
}
913
}
1014
}
1115

variables.tf

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ variable "ssh_public_keys" {
5858
description = "SSH public keys in base64."
5959
}
6060

61-
variable "vm_onboot" {
62-
type = bool
63-
description = "VM should be brought up during host system boot."
64-
default = true
65-
}
66-
6761
variable "vm_user" {
6862
type = string
6963
default = "ubuntu"
@@ -80,29 +74,35 @@ variable "vm_max_vcpus" {
8074
default = 2
8175
}
8276

83-
variable "vm_vcpus" {
84-
type = number
85-
description = "The number of CPU cores to allocate to the VM. This should be less or equal to vm_max_vcpus."
86-
default = 2
87-
}
88-
8977
variable "vm_cpu_type" {
9078
type = string
9179
description = "The type of CPU to emulate in the Guest"
9280
default = "host"
9381
}
9482

95-
variable "vm_os_disk_size_gb" {
96-
type = number
97-
description = "The size of VM OS disk in Gigabyte"
98-
default = 20
99-
}
100-
10183
variable "vm_os_disk_storage" {
10284
type = string
10385
description = "Default storage pool where OS VM disk is placed."
10486
}
10587

88+
variable "add_worker_node_data_disk" {
89+
type = bool
90+
description = "A boolean value that indicates whether to add a data disk to each worker node of the cluster."
91+
default = false
92+
}
93+
94+
variable "worker_node_data_disk_storage" {
95+
type = string
96+
description = "The storage pool where the data disk is placed."
97+
default = ""
98+
}
99+
100+
variable "worker_node_data_disk_size" {
101+
type = string
102+
description = "The size of worker node data disk in Gigabyte."
103+
default = 10
104+
}
105+
106106
variable "vm_ubuntu_tmpl_name" {
107107
type = string
108108
description = "Name of Cloud-init template Ubuntu VM."
@@ -189,14 +189,6 @@ variable "argocd_version" {
189189
default = "v2.4.12"
190190
}
191191

192-
#
193-
# Local vars
194-
#
195-
locals {
196-
internal_net_subnet_mask = "/${split("/", var.internal_net_subnet_cidr)[1]}"
197-
internal_net_default_gw = cidrhost(var.internal_net_subnet_cidr, 1)
198-
}
199-
200192
#
201193
# VM specifications for Kubernetes nodes
202194
#

vm-k8s-nodes.tf

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,26 @@ module "k8s_control_plane_nodes" {
2323
module "k8s_worker_nodes" {
2424
source = "./modules/proxmox_ubuntu_vm"
2525

26-
node_count = var.vm_k8s_worker["node_count"]
27-
pm_host = var.pm_host
28-
vm_ubuntu_tmpl_name = var.vm_ubuntu_tmpl_name
29-
vm_name_prefix = "${var.env_name}-k8s-worker"
30-
vm_max_vcpus = var.vm_max_vcpus
31-
vm_vcpus = var.vm_k8s_worker["vcpus"]
32-
vm_sockets = var.vm_sockets
33-
vm_cpu_type = var.vm_cpu_type
34-
vm_memory_mb = var.vm_k8s_worker["memory"]
35-
vm_os_disk_storage = var.vm_os_disk_storage
36-
vm_os_disk_size_gb = var.vm_k8s_worker["disk_size"]
37-
vm_net_name = var.internal_net_name
38-
vm_net_subnet_cidr = var.internal_net_subnet_cidr
39-
vm_host_number = 20
40-
vm_user = var.vm_user
41-
vm_tags = "${var.env_name};terraform;k8s-worker"
42-
ssh_public_keys = var.ssh_public_keys
26+
node_count = var.vm_k8s_worker["node_count"]
27+
pm_host = var.pm_host
28+
vm_ubuntu_tmpl_name = var.vm_ubuntu_tmpl_name
29+
vm_name_prefix = "${var.env_name}-k8s-worker"
30+
vm_max_vcpus = var.vm_max_vcpus
31+
vm_vcpus = var.vm_k8s_worker["vcpus"]
32+
vm_sockets = var.vm_sockets
33+
vm_cpu_type = var.vm_cpu_type
34+
vm_memory_mb = var.vm_k8s_worker["memory"]
35+
vm_os_disk_storage = var.vm_os_disk_storage
36+
vm_os_disk_size_gb = var.vm_k8s_worker["disk_size"]
37+
vm_net_name = var.internal_net_name
38+
vm_net_subnet_cidr = var.internal_net_subnet_cidr
39+
vm_host_number = 20
40+
vm_user = var.vm_user
41+
vm_tags = "${var.env_name};terraform;k8s-worker"
42+
ssh_public_keys = var.ssh_public_keys
43+
add_worker_node_data_disk = var.add_worker_node_data_disk
44+
worker_node_data_disk_storage = var.worker_node_data_disk_storage
45+
worker_node_data_disk_size = var.worker_node_data_disk_size
4346
}
4447

4548
output "k8s_control_plane" {

vm-kubespray-host.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ locals {
1919
kubespray_inventory_content = templatefile(
2020
"${path.module}/kubespray/inventory.ini",
2121
{
22-
cp_nodes = "${join("\n", [for host in module.k8s_control_plane_nodes.vm_list : join("", [host.name, " ansible_ssh_host=${host.ip0}", " ansible_connection=ssh"])])}"
23-
worker_nodes = "${join("\n", [for host in module.k8s_worker_nodes.vm_list : join("", [host.name, " ansible_ssh_host=${host.ip0}", " ansible_connection=ssh"])])}"
22+
cp_nodes = join("\n", [for host in module.k8s_control_plane_nodes.vm_list : join("", [host.name, " ansible_ssh_host=${host.ip0}", " ansible_connection=ssh"])])
23+
worker_nodes = join("\n", [for host in module.k8s_worker_nodes.vm_list : join("", [host.name, " ansible_ssh_host=${host.ip0}", " ansible_connection=ssh"])])
2424
bastion = "" # var.bastion_ssh_ip != "" ? "[bastion]\nbastion ansible_host=${var.bastion_ssh_ip} ansible_port=${var.bastion_ssh_port} ansible_user=${var.bastion_ssh_user}" : ""
2525
}
2626
)

0 commit comments

Comments
 (0)