Search code examples
kubernetesvagrantcoreos

public and private IP address of nodes on single computer kubernetes on coreos


While I am trying to generate and assign rsa keys to worker nodes from master node, one confusion I am having is what the assigned IPs should be or how I should configure network for each node(virtual machine) of kubernetes on CoreOS in single computer.

Currently when I am trying to get the master public / private IP(s) of each node, of course they all have single private IP and public IP.

Currently relying on Vagrant for creating and deploying the cluster.


Solution

  • Vagrant uses ignition plugin for CoreOS configuration.
    You can take as a starting point coreos-vagrant repository. In this part of the Vagrantfile you can see the way IP addresses are assigned to nodes:

    CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
    IGNITION_CONFIG_PATH = File.join(File.dirname(__FILE__), "config.ign")
    CONFIG = File.join(File.dirname(__FILE__), "config.rb")
    
    # Defaults for config options defined in CONFIG
    $num_instances = 1
    
    # Attempt to apply the deprecated environment variable NUM_INSTANCES to
    # $num_instances while allowing config.rb to override it
    if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
      $num_instances = ENV["NUM_INSTANCES"].to_i
    end
    
    <skipped>
    
    (1..$num_instances).each do |i|
      <skipped>
        ip = "172.17.8.#{i+100}"
        config.vm.network :private_network, ip: ip
         # This tells Ignition what the IP for eth1 (the host-only adapter) should be
        config.ignition.ip = ip
      <skipped>
    end
    

    The following articles tell you more about CoreOS setup using Vagrant: