---
title: "User data in Managed Kubernetes node groups"
sidebar_label: "User data"
description: "How to specify user parameters for cluster configuration, examples of scripts with user data"
sidebar_position: 11
toc_max_heading_level: 3
---

import Formbricks from '@theme/MDXComponents/Formbricks'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from 'docs-kit/components'

# 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](https://cloud-init.io/) agent. Using user data helps speed up and automate the node configuration process for Managed Kubernetes clusters.

[You can specify user data](#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](https://cloudinit.readthedocs.io/en/latest/topics/format.html) 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:

* [disable IPv6](#disable-ipv6);
* [create a directory and download files to it over the network](#create-directory-download-file).

## Specify user data \{#specify-user-data}

You can specify user data when creating a cluster on a [cloud server](/managed-kubernetes/create/create-cloud-cluster.mdx) and a [dedicated server](/managed-kubernetes/create/create-dedicated-cluster.mdx) or when [adding a new node group](/managed-kubernetes/node-groups/create-node-group.mdx):

* 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 \{#user-data-script-examples}

### Disable IPv6 \{#disable-ipv6}

<Tabs queryString="disable-ipv6">
  <TabItem value="cloud-config" default>
    <TabItemLabel>
      Cloud-config
    </TabItemLabel>

    ```yaml
    #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
    ```
  </TabItem>

  <TabItem value="bash-script">
    <TabItemLabel>
      Bash script
    </TabItemLabel>

    ```bash
    #!/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
    ```
  </TabItem>
</Tabs>

### Create a directory and download files to it over the network \{#create-directory-download-file}

<Tabs queryString="create-directory-download-file">
  <TabItem value="cloud-config" default>
    <TabItemLabel>
      Cloud-config
    </TabItemLabel>

    ```yaml
    #cloud-config

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

  <TabItem value="bash-script">
    <TabItemLabel>
      Bash script
    </TabItemLabel>

    ```bash
    #!/bin/bash
    mkdir /run/mydir
    wget http://example.com -O /run/mydir/index.html
    ```
  </TabItem>
</Tabs>

<Formbricks />
