Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparing with other Yandex Cloud services
  • Getting started
    • All guides
    • Connecting to a node over SSH
    • Connecting to a node via OS Login
    • Updating Kubernetes
    • Configuring masquerading in clusters with multiple ranges of pod IP addresses
    • Configuring autoscaling
    • Activating a Kubernetes Terraform provider
    • Installing applications from Yandex Cloud Marketplace using Terraform
    • Working with private Docker image registries
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Getting started
  • Synchronize masquerading after adding a range
  • Management modes
  • View the current settings
  • Enable automatic management
  • Enable manual management
  • Automatic mode selection
  • Check the result
  1. Step-by-step guides
  2. Configuring masquerading in clusters with multiple ranges of pod IP addresses

Configuring masquerading in clusters with multiple ranges of pod IP addresses

Written by
Yandex Cloud
Updated at October 29, 2026
View in Markdown
  • Getting started
  • Synchronize masquerading after adding a range
  • Management modes
  • View the current settings
  • Enable automatic management
  • Enable manual management
  • Automatic mode selection
  • Check the result

Create a cluster with multiple ranges of pod IP addresses and expand the address space of the existing cluster. Then, check the masquerading settings.

The ConfigMap object named ip-masq-agent in the kube-system namespace contains the settings for pod IP address masquerading. The data.config.nonMasqueradeCIDRs sets destination ranges, which, when accessed, do not get the pod IP address to be replaced with the node IP address.

In clusters with multiple ranges of pod IP addresses, save all the cluster's pod ranges in this list.

Getting startedGetting started

You can specify the ranges when creating a cluster or add them later when updating the cluster.

View and save the masquerading settings before adding a range to an existing cluster. If you use your own ranges or other settings, enable manual management to save them.

Synchronize masquerading after adding a rangeSynchronize masquerading after adding a range

  1. Check the management mode for ip-masq-agent ConfigMap.
  2. Based on the mode, follow these steps:
    • enforced: Wait for the next configuration update and check that the new range is in nonMasqueradeCIDRs. Do not edit data.config manually: the service will overwrite the changes.
    • disabled: Run kubectl -n kube-system edit configmap ip-masq-agent and add the new range to data.config.nonMasqueradeCIDRs. Save the previous ranges and other settings. For a configuration example, see this section.
    • No annotation: Wait for automatic mode selection and read ConfigMap again. If you need to save the custom settings, explicitly specify disabled before editing them.
  3. Check the result.

Management modesManagement modes

The mode is specified by the addon-cm-controller.mk8s.yc.io/mode annotation:

Value

Behavior

enforced

The service supports the entire data.config based on the system template. New pod ranges are added automatically. Custom values are overwritten.

disabled

The service does not change ConfigMap. The user supports system and custom ranges themselves.

No annotation

The service determines the mode based on the current contents and sets enforced or disabled.

Other value

The service does not change ConfigMap and creates an event with the InvalidMode reason.

The configuration is checked periodically: every 60 seconds by default. Changing mode does not require restarting the cluster or nodes.

View the current settingsView the current settings

First, install kubectl and configure it to work with the Managed Service for Kubernetes cluster you created.

Run this command to view the mode and ConfigMap contents:

kubectl -n kube-system get configmap ip-masq-agent -o yaml

Before editing, save the current configuration:

kubectl -n kube-system get configmap ip-masq-agent -o yaml > ip-masq-agent-backup.yaml

Enable automatic managementEnable automatic management

Use enforced mode if you have enough pod system ranges and standard ip-masq-agent settings.

Warning

When enabling enforced, the service will overwrite the entire data.config. Custom ranges, resyncInterval, masqLinkLocal values, and other settings will not be saved. Before editing, save the current configuration.

Run this command to delegate management to the service:

kubectl -n kube-system annotate configmap ip-masq-agent \
  addon-cm-controller.mk8s.yc.io/mode=enforced --overwrite

When adding a new pod range, the service will automatically add it to nonMasqueradeCIDRs.

Enable manual managementEnable manual management

If you are adding custom ranges or editing other ip-masq-agent settings:

  1. Enable disabled mode:

    kubectl -n kube-system annotate configmap ip-masq-agent \
      addon-cm-controller.mk8s.yc.io/mode=disabled --overwrite
    
  2. Open ConfigMap to edit it:

    kubectl -n kube-system edit configmap ip-masq-agent
    
  3. In nonMasqueradeCIDRs, save all the cluster's pod ranges and add custom destination ranges that do not require masquerading. Here is an example:

    data:
      config: |+
        nonMasqueradeCIDRs:
          - 10.112.0.0/16
          - 10.113.0.0/16
          - 10.200.0.0/16
        masqLinkLocal: false
        resyncInterval: 60s
    

    In the example, the first two ranges belong to pods, and the third, to the custom network. Replace them with your values. Save the other settings required for your network.

Warning

In disabled mode, manually update nonMasqueradeCIDRs after adding each pod range. The service does not combine system and custom settings.

Automatic mode selectionAutomatic mode selection

At the first run, the controller checks ConfigMap without any annotation. If the configuration only lists the expected system ranges, enforced mode is enabled. A configuration with additional, missing, or modified ranges is assigned disabled mode and saved without any changes.

Comparisons factor in the range order. IPv4 system ranges in the previous format that spanned half of the range may be recognized and replaced with full ones. A combined list of full and half ranges is considered a custom configuration.

Warning

If you only edited resyncInterval, masqLinkLocal, or other settings without changing the system CIDR list, the controller may select enforced and overwrite the settings. To save them, set disabled in advance.

Deleting the annotation triggers repeat automatic selection. To select an exact mode, explicitly specify enforced or disabled.

Check the resultCheck the result

  1. After creating new nodes, check the address blocks assigned to them:

    kubectl get nodes -o custom-columns=NAME:.metadata.name,POD_CIDR:.spec.podCIDR,POD_CIDRS:.spec.podCIDRs
    

    The new range may not be used if the previous one still has unused blocks. When adding a range, the IP addresses of existing nodes and pods do not change.

  2. Wait for the next configuration check and view the settings:

    kubectl -n kube-system get configmap ip-masq-agent -o yaml
    
  3. Check the ConfigMap events:

    kubectl -n kube-system get events \
      --field-selector involvedObject.kind=ConfigMap,involvedObject.name=ip-masq-agent \
      --sort-by=.lastTimestamp
    

    If you see an InvalidMode event, fix the annotation value.

  4. To check the node masquerading rules, connect to that node over SSH and run this command:

    sudo iptables -t nat -L IP-MASQ -v -n
    

Do not delete ConfigMap to reset the settings, as the service will recreate it using the system template. Use mode annotation to change the behavior.

Useful linksUseful links

  • Clusters with multiple ranges of pod IP addresses
  • Networking in Managed Service for Kubernetes

Was the article helpful?

Previous
Updating Kubernetes
Next
Configuring autoscaling
© 2026 Direct Cursus Technology L.L.C.