Skip to content

Commit b97e9d2

Browse files
authored
Merge pull request #84 from khanh-ph/release/4.0.0
Release version 4.0.0
2 parents fec9496 + 331be88 commit b97e9d2

File tree

11 files changed

+226
-122
lines changed

11 files changed

+226
-122
lines changed

.github/workflows/draft-a-release.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ jobs:
2828
run: git push origin ${{ env.BRANCH }}
2929

3030
- name: Create a Pull Request
31-
uses: thomaseizinger/[email protected]
31+
uses: actions/github-script@v6
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
with:
35-
base: master
36-
head: ${{ env.BRANCH }}
37-
title: Release version ${{ env.VERSION }}
35+
script: |
36+
const { owner, repo } = context.repo;
37+
const version = process.env.VERSION;
38+
const title = 'Release version ' + version;
39+
const body = 'Created by GitHub Actions';
40+
const base = 'master';
41+
const head = process.env.BRANCH;
42+
43+
github.rest.pulls.create({
44+
owner,
45+
repo,
46+
title,
47+
body,
48+
base,
49+
head
50+
});
Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Publish Release to GitHub
2+
23
on:
34
pull_request:
45
branches:
@@ -10,31 +11,56 @@ jobs:
1011
publish-a-release:
1112
runs-on: ubuntu-latest
1213
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
13-
1414
steps:
15-
- name: Extract version from branch name (for release branches)
16-
if: startsWith(github.event.pull_request.head.ref, 'release/')
15+
- name: Extract version from branch name
1716
run: |
18-
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
19-
VERSION=${BRANCH_NAME#release/}
20-
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
21-
22-
- name: Create Release
23-
uses: thomaseizinger/[email protected]
24-
env:
17+
set -x
18+
branchName="${{ github.event.pull_request.head.ref }}"
19+
version=${branchName#release/}
20+
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-rc\.([0-9]+))?$ ]]; then
21+
echo "TAG=$version" >> $GITHUB_ENV
22+
else
23+
echo "$version is not a supported semver." >&2
24+
exit 1
25+
fi
26+
27+
- name: Create Release to GitHub
28+
uses: actions/github-script@v6
29+
env:
2530
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2631
with:
27-
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
28-
tag_name: ${{ env.RELEASE_VERSION }}
29-
name: v${{ env.RELEASE_VERSION }}
30-
draft: false
31-
prerelease: false
32+
script: |
33+
const { owner, repo } = context.repo;
34+
const target_commitish = context.sha;
3235
33-
- name: Merge master into develop branch (Gitflow)
34-
uses: thomaseizinger/[email protected]
35-
env:
36+
github.rest.repos.createRelease({
37+
owner,
38+
repo,
39+
tag_name: process.env.TAG,
40+
target_commitish,
41+
name: `v${process.env.TAG}`,
42+
generate_release_notes: true,
43+
draft: process.env.TAG.includes('-rc'),
44+
prerelease: false
45+
});
46+
47+
- name: Create a PR to merge master back into develop branch
48+
uses: actions/github-script@v6
49+
env:
3650
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3751
with:
38-
head: master
39-
base: develop
40-
title: Merge master into develop branch (Gitflow)
52+
script: |
53+
const { owner, repo } = context.repo;
54+
const title = `Merge master into develop after publishing release ${process.env.TAG}`;
55+
const body = 'Created by GitHub Actions';
56+
const base = 'develop';
57+
const head = 'master';
58+
59+
github.rest.pulls.create({
60+
owner,
61+
repo,
62+
title,
63+
body,
64+
base,
65+
head
66+
});

README.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,40 @@ The project provides several Terraform variables that allow you to customize the
7070
| <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 |
7171
| <a name="input_pm_parallel"></a> [pm\_parallel](#input\_pm\_parallel) | The number of simultaneous Proxmox processes. E.g: creating resources. | `number` | `2` | no |
7272
| <a name="input_pm_timeout"></a> [pm\_timeout](#input\_pm\_timeout) | Timeout value (seconds) for proxmox API calls. | `number` | `600` | no |
73-
| <a name="input_env_name"></a> [env\_name](#input\_env\_name) | n/a | `string` | `"test"` | no |
74-
| <a name="input_internal_net_name"></a> [internal\_net\_name](#input\_internal\_net\_name) | Name of the internal network bridge. | `string` | `"vmbr1"` | no |
75-
| <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 |
76-
| <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 |
77-
| <a name="input_ssh_public_keys"></a> [ssh\_public\_keys](#input\_ssh\_public\_keys) | SSH public keys in base64. | `string` | n/a | yes |
78-
| <a name="input_vm_user"></a> [vm\_user](#input\_vm\_user) | n/a | `string` | `"ubuntu"` | no |
79-
| <a name="input_vm_sockets"></a> [vm\_sockets](#input\_vm\_sockets) | n/a | `number` | `1` | no |
80-
| <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 |
73+
| <a name="input_env_name"></a> [env\_name](#input\_env\_name) | The stage of the development lifecycle for the k8s cluster. Example: `prod`, `dev`, `qa`, `stage`, `test` | `string` | `"test"` | no |
74+
| <a name="input_location"></a> [location](#input\_location) | The city or region where the cluster is provisioned | `string` | `null` | no |
75+
| <a name="input_cluster_number"></a> [cluster\_number](#input\_cluster\_number) | The instance count for the k8s cluster, to differentiate it from other clusters. Example: `00`, `01` | `string` | `"01"` | no |
76+
| <a name="input_cluster_domain"></a> [cluster\_domain](#input\_cluster\_domain) | The cluster domain name | `string` | `"local"` | no |
77+
| <a name="input_internal_net_name"></a> [internal\_net\_name](#input\_internal\_net\_name) | Name of the internal network bridge | `string` | `"vmbr1"` | no |
78+
| <a name="input_internal_net_subnet_cidr"></a> [internal\_net\_subnet\_cidr](#input\_internal\_net\_subnet\_cidr) | CIDR of the internal network | `string` | `"10.0.1.0/24"` | no |
79+
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input\_ssh\_private\_key) | SSH private key in base64, will be used by Terraform client to connect to the VM after provisioning | `string` | n/a | yes |
80+
| <a name="input_ssh_public_keys"></a> [ssh\_public\_keys](#input\_ssh\_public\_keys) | SSH public keys in base64 | `string` | n/a | yes |
81+
| <a name="input_vm_user"></a> [vm\_user](#input\_vm\_user) | The default user for all VMs | `string` | `"ubuntu"` | no |
82+
| <a name="input_vm_sockets"></a> [vm\_sockets](#input\_vm\_sockets) | Number of the CPU socket to allocate to the VMs | `number` | `1` | no |
83+
| <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 |
8184
| <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 |
82-
| <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 |
83-
| <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 |
84-
| <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 |
85-
| <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 |
86-
| <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 |
87-
| <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 |
88-
| <a name="input_bastion_ssh_user"></a> [bastion\_ssh\_user](#input\_bastion\_ssh\_user) | n/a | `string` | `"ubuntu"` | no |
89-
| <a name="input_bastion_ssh_port"></a> [bastion\_ssh\_port](#input\_bastion\_ssh\_port) | n/a | `number` | `22` | no |
85+
| <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 |
86+
| <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 |
87+
| <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 |
88+
| <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 |
89+
| <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 |
90+
| <a name="input_bastion_ssh_ip"></a> [bastion\_ssh\_ip](#input\_bastion\_ssh\_ip) | IP of the bastion host, could be either public IP or local network IP of the bastion host | `string` | `""` | no |
91+
| <a name="input_bastion_ssh_user"></a> [bastion\_ssh\_user](#input\_bastion\_ssh\_user) | The user to authenticate to the bastion host | `string` | `"ubuntu"` | no |
92+
| <a name="input_bastion_ssh_port"></a> [bastion\_ssh\_port](#input\_bastion\_ssh\_port) | The SSH port number on the bastion host | `number` | `22` | no |
9093
| <a name="input_create_kubespray_host"></a> [create\_kubespray\_host](#input\_create\_kubespray\_host) | n/a | `bool` | `true` | no |
9194
| <a name="input_kubespray_image"></a> [kubespray\_image](#input\_kubespray\_image) | n/a | `string` | `"khanhphhub/kubespray:v2.22.0"` | no |
9295
| <a name="input_kube_version"></a> [kube\_version](#input\_kube\_version) | Kubernetes version | `string` | `"v1.24.6"` | no |
93-
| <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 |
94-
| <a name="input_enable_nodelocaldns"></a> [enable\_nodelocaldns](#input\_enable\_nodelocaldns) | Enable nodelocal dns cache | `bool` | `false` | no |
95-
| <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 |
96-
| <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 |
97-
| <a name="input_helm_enabled"></a> [helm\_enabled](#input\_helm\_enabled) | Helm deployment | `bool` | `false` | no |
98-
| <a name="input_ingress_nginx_enabled"></a> [ingress\_nginx\_enabled](#input\_ingress\_nginx\_enabled) | Nginx ingress controller deployment | `bool` | `false` | no |
99-
| <a name="input_argocd_enabled"></a> [argocd\_enabled](#input\_argocd\_enabled) | ArgoCD | `bool` | `false` | no |
100-
| <a name="input_argocd_version"></a> [argocd\_version](#input\_argocd\_version) | ArgoCD version | `string` | `"v2.4.12"` | no |
96+
| <a name="input_kube_network_plugin"></a> [kube\_network\_plugin](#input\_kube\_network\_plugin) | The network plugin to be installed on your cluster. Example: `cilium`, `calico`, `kube-ovn`, `weave` or `flannel` | `string` | `"calico"` | no |
97+
| <a name="input_enable_nodelocaldns"></a> [enable\_nodelocaldns](#input\_enable\_nodelocaldns) | A boolean value that indicates whether to enable nodelocal dns cache on your cluster | `bool` | `false` | no |
98+
| <a name="input_podsecuritypolicy_enabled"></a> [podsecuritypolicy\_enabled](#input\_podsecuritypolicy\_enabled) | A boolean value that indicates whether to enable pod security policy on your cluster (RBAC must be enabled either by having 'RBAC' in authorization\_modes or kubeadm enabled) | `bool` | `false` | no |
99+
| <a name="input_persistent_volumes_enabled"></a> [persistent\_volumes\_enabled](#input\_persistent\_volumes\_enabled) | A boolean value that indicates whether to 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 |
100+
| <a name="input_helm_enabled"></a> [helm\_enabled](#input\_helm\_enabled) | A boolean value that indicates whether to enable Helm on your cluster | `bool` | `false` | no |
101+
| <a name="input_ingress_nginx_enabled"></a> [ingress\_nginx\_enabled](#input\_ingress\_nginx\_enabled) | A boolean value that indicates whether to enable Nginx ingress on your cluster | `bool` | `false` | no |
102+
| <a name="input_argocd_enabled"></a> [argocd\_enabled](#input\_argocd\_enabled) | A boolean value that indicates whether to enable ArgoCD on your cluster | `bool` | `false` | no |
103+
| <a name="input_argocd_version"></a> [argocd\_version](#input\_argocd\_version) | The ArgoCD version to be installed | `string` | `"v2.4.12"` | no |
101104
| <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 |
102105
| <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 |
106+
| <a name="input_use_legacy_naming_convention"></a> [use\_legacy\_naming\_convention](#input\_use\_legacy\_naming\_convention) | A boolean value that indicates whether to use legacy naming convention for the VM and cluster name. If your cluster was provisioned using version <= 3.x, set it to `true` | `bool` | `false` | no |
103107
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
104108
105109
## Blog posts

kubespray/k8s-cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ kube_encrypt_secret_data: false
157157

158158
# DNS configuration.
159159
# Kubernetes cluster name, also will be used as DNS domain
160-
cluster_name: cluster.local
160+
cluster_name: ${cluster_name}
161161
# Subdomains of DNS domain to be resolved via /etc/resolv.conf for hostnet pods
162162
ndots: 2
163163
# dns_timeout: 2

modules/proxmox_ubuntu_vm/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resource "proxmox_vm_qemu" "ubuntu_vm" {
1414
target_node = var.pm_host
1515
clone = var.vm_ubuntu_tmpl_name
1616
qemu_os = "l26"
17-
name = "${var.vm_name_prefix}-${format("%02d", count.index)}"
17+
name = var.use_legacy_naming_convention ? "${var.vm_name_prefix}-${format("%02d", count.index)}" : "${var.vm_name_prefix}-${format("%02d", count.index + 1)}"
1818
agent = 1
1919
onboot = var.vm_onboot
2020
os_type = "cloud-init"

modules/proxmox_ubuntu_vm/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ variable "worker_node_data_disk_size" {
114114
default = 10
115115
}
116116

117+
variable "use_legacy_naming_convention" {
118+
type = bool
119+
default = false
120+
}
121+
117122
#
118123
# Local vars
119124
#

scripts/install_kubernetes.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ kubespray_data_dir=${kubespray_data_dir}
55
# Install Kubernetes
66
sudo docker run --rm \
77
--mount type=bind,source="$kubespray_data_dir/inventory.ini",dst=/inventory/sample/inventory.ini \
8-
--mount type=bind,source="$kubespray_data_dir/addons.yml",dst=/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml \
9-
--mount type=bind,source="$kubespray_data_dir/k8s-cluster.yml",dst=/inventory/sample/group_vars/k8s_cluster/addons.yml \
8+
--mount type=bind,source="$kubespray_data_dir/addons.yml",dst=/inventory/sample/group_vars/k8s_cluster/addons.yml \
9+
--mount type=bind,source="$kubespray_data_dir/k8s-cluster.yml",dst=/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml \
1010
--mount type=bind,source="$kubespray_data_dir/id_rsa",dst=/root/.ssh/id_rsa \
1111
$kubespray_image bash -c \
1212
"ansible-playbook -i /inventory/sample/inventory.ini -u ubuntu -become cluster.yml"

scripts/setup_kubespray.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,28 @@ wait_for_lock_release() {
3232

3333
wait_for_lock_release
3434

35-
# Install Docker
35+
# Verify if Docker is installed
3636
if ! command -v docker &> /dev/null; then
3737
echo "Docker not found. Installing Docker..."
38+
39+
# Download Docker installation script
40+
if ! curl -fsSL https://get.docker.com -o get-docker.sh; then
41+
echo "Error downloading Docker installation script. Exiting." >&2
42+
exit 1
43+
fi
44+
3845
# Install Docker
39-
curl -fsSL https://get.docker.com -o get-docker.sh
40-
sudo sh get-docker.sh
41-
# Add current user to the docker group
46+
if ! sudo sh get-docker.sh; then
47+
echo "Error installing Docker. Exiting." >&2
48+
exit 1
49+
fi
50+
51+
# Clean up by removing the Docker installation script
52+
rm -f get-docker.sh
53+
54+
# Add current user to the `docker` group
4255
sudo usermod -aG docker $USER
56+
4357
echo "Docker installed successfully."
4458
else
4559
echo "Docker is already installed."

0 commit comments

Comments
 (0)