Skip to main content

User data in Managed Kubernetes node groups

User data in Managed Kubernetes node groups are user parameters for configuring and personalizing cluster nodes. They are passed as a script in cloud-config format (text files with YAML syntax) or as a bash script. The scripts are automatically encoded in Base64 and then passed 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 node configuration process for Managed Kubernetes clusters.

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

Learn more about cloud-config and bash script formats in the User data formats section of the cloud-init documentation.

In the scripts, you can pass parameters for configuring worker nodes and for 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 data that is Base64 encoded in the user_data argument. The maximum size of the script is 65535 bytes. Applicable only to a cluster on a cloud server.

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 ]