dockerkubernetes-podk3smacvlan

MacVlan network with kubernetes


I setup the kubernetes cluster using k3s. I have one master and two nodes. I created docker macvlan network on one of the node. I want to achieve below mentioned scenario.

  1. Assign IP to container/pod.(user defined IP, not cluster IP).

q1.Is there any alternative option for docker macvlan?

q2.Can we run command on node (not on pod/container)? (while deploying the pod/service)

q3.can we create kubernetes network with user defined IP? (I don`t think LB/NP/Ingress will help for user defined IP, correct me if I am wrong!)


Solution

  • Kubernetes has its own very specialized network implementation. It can't easily assign a unique externally accessible IP address to each process the way the Docker MacVLAN setup can. Kubernetes also can't reuse the Docker networking infrastructure. Generally the cluster takes responsibility for assigning IP addresses to pods and services, and you can't specify them yourself.

    So, in Kubernetes:

    1. You can't manually assign IP addresses to things;
    2. The cluster-internal IP addresses aren't directly accessible from outside the cluster;
    3. The Kubernetes constructs can only launch containers on arbitrarily chosen nodes (possibly with some constraints; possibly on every node), but you don't usually launch a container on a single specific node, and you can't run a non-container command on a node.

    Given what you're describing, a more general-purpose cluster automation tool like Salt Stack, Ansible, or Chef might meet your needs better. This will let you launch processes directly on managed nodes, and if those are server-type processes, they'll be accessible using the host's IP address as normal.