Skip to main content

User data in Managed Kubernetes node groups

User data in Managed Kubernetes node groups are custom parameters for configuring and personalizing cluster nodes. They are passed as a cloud-config script (text files with YAML syntax) or as a Bash script. Scripts are automatically Base64-encoded and then transferred to the server hosting the Managed Kubernetes cluster nodes. On the server, the scripts are executed using the cloud-init agent. Using user data helps speed up and automate the configuration of Managed Kubernetes cluster nodes.

You can specify user data when creating a cluster or adding a new node group.

For more information on cloud-config and Bash script formats, see the User data formats guide in the cloud-init documentation.

In scripts, you can pass parameters for configuring worker nodes and installing additional software on nodes outside the Managed Kubernetes cluster. For example:

Specify user data

You can specify user data when creating a cluster on a cloud server and a dedicated server or when adding a new node group:

  • in the control panel — a script with data that is not Base64-encoded in the User data field. The maximum size of a script with data that is not Base64-encoded is 47 KB;

  • via Terraform — only a script with Base64-encoded data in the user_data argument. The maximum script size is 65,535 bytes. Applicable only to a cloud server cluster.

After adding user data, you cannot change the script.

User data examples

Disable IPv6

#cloud-config

runcmd:
- echo "options ipv6 disable=1" >> /etc/modprobe.d/ipv6.conf
- sysctl -a
- DisableIPv6Conf="/etc/sysctl.d/99-ipv6-disable.conf"
- cat /dev/null > $DisableIPv6Conf
- echo '# Custom sysctl Parameter for ipv6 disable' >> $DisableIPv6Conf
- echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> $DisableIPv6Conf
- echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> $DisableIPv6Conf
- sysctl --system
- sysctl -p
- sysctl -a | grep -ie "local_port" -ie "ipv6" | sort

Create a directory and download files to it over the network

#cloud-config

runcmd:
- mkdir /run/mydir
- [ wget, "http://example.com", -O, /run/mydir/index.html ]