User data
The use of user data is not available in Managed Kubernetes clusters on dedicated servers.
User data in a Managed Kubernetes cluster on a cloud server — user parameters for configuring and personalizing the cluster. They are transmitted 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 transferred to the cloud server hosting the Managed Kubernetes cluster. On the server, the scripts are executed using the cloud-init agent. The use of user data helps to speed up and automate the process of configuring the Managed Kubernetes cluster.
Specify user data can be specified when creating a cluster or adding a new node group.
Learn more about cloud-config and bash script formats in the User data formats instructions of 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 — a script with data that are 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 size of the script 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