User data
User data in a Managed Kubernetes cluster — user parameters to configure and personalize the cluster. Passed as a script in cloud-config format (text files with YAML syntax) or as a bash script. The scripts are automatically Base64 encoded and then sent to the cloud server hosting the Managed Kubernetes cluster. On the server, scripts are executed using the cloud-init agent. Using user data helps to speed up and automate the process of configuring a Managed Kubernetes cluster.
Specify user data is available when creating a cluster or adding a new node group.
For more information about cloud-config and bash script formats, see the User data formats instructions 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 or adding a new node group:
- in the control panel — script with data that is not Base64 encoded in the User Data field. The maximum size of the script is 47 KB;
- via Terraform — only script with data encoded in Base64 to the user_data argument. The maximum script size is 65,535 bytes.
Once user data has been added, the script cannot be changed.
Examples of user data
Disable IPv6
- Cloud-config
- Bash script
#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
#!/bin/bash -v
# Disable IPv6 Kernel Module
echo 'options ipv6 disable=1' >> /etc/modprobe.d/ipv6.conf
# Disable IPv6 Kernel Parameter
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 upload files to it over the network
- Cloud-config
- Bash script
#cloud-config
runcmd:
- mkdir /run/mydir
- [ wget, "http://example.com", -O, /run/mydir/index.html ]
#!/bin/bash
mkdir /run/mydir
wget http://example.com -O /run/mydir/index.html