add aliyunlinux 3 example to support cgroup v2 custom image

This commit is contained in:
bingshen.wbs
2023-01-30 15:21:10 +08:00
parent 906efb88a3
commit a3923351af
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
{
"variables": {
"region": "cn-hangzhou",
"image_name": "test_image{{timestamp}}",
"source_image": "aliyun_3_x64_20G_alibase_20221102.vhd",
"instance_type": "ecs.g6.2xlarge",
"access_key": "{{env `ALICLOUD_ACCESS_KEY`}}",
"secret_key": "{{env `ALICLOUD_SECRET_KEY`}}"
},
"builders": [
{
"type": "alicloud-ecs",
"access_key": "{{user `access_key`}}",
"secret_key": "{{user `secret_key`}}",
"region": "{{user `region`}}",
"image_name": "{{user `image_name`}}",
"source_image": "{{user `source_image`}}",
"ssh_username": "root",
"instance_type": "{{user `instance_type`}}",
"skip_image_validation": "true",
"io_optimized": "true",
"associate_public_ip_address": "true"
}
],
"provisioners": [
{
"type": "shell",
"environment_vars": [
"CGROUP_MODE={{user `cgroup_mode`}}"
],
"scripts": [
"scripts/set-cgroupv2.sh",
"scripts/updateKernel.sh",
"scripts/reboot.sh",
"scripts/cleanUpKerneles.sh",
"config/default.sh",
"scripts/disableTuned.sh",
"scripts/verify.sh"
],
"expect_disconnect": true
}
]
}

11
scripts/set-cgroupv2.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
echo $CGROUP_MODE
if [[ ! -z $CGROUP_MODE ]] && [[ $CGROUP_MODE =~ .*[v,V]2.* ]]; then
echo "set cgroup mode to $CGROUP_MODE"
if ! grep -q 'systemd.unified_cgroup_hierarchy=1' /etc/default/grub; then
grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1"
fi
fi