0

I am trying to understand a problem that currently arises with buildx, its Kubernetes driver, GitLab CI/CD, and parallel jobs. What is the suffix 0 that appears in builder instances's pod names?

It looks like an index, but seems unrelated to replicas. For instance I tried this (notice the suffix 0 behind test and before the first hyphen):

$ docker buildx create --name test --driver kubernetes --driver-opt namespace=ci,replicas=2 --use
$ echo "FROM scratch" | docker buildx build -
$ kubectl get pod -n ci
NAME                   READY   STATUS    RESTARTS   AGE
test0-xxxxxxxxxx-xxxxx 1/1     Running   0          xxxxx
test0-yyyyyyyyyy-yyyyy 1/1     Running   0          yyyyy
rookie099
  • 2,201
  • 2
  • 26
  • 52

1 Answers1

0

It's related to nodes. By default, docker buildx create creates a single node. After creating a new builder, you can also append new nodes to it.

The relevant code is in store/nodegroup.go:

func (ng *NodeGroup) nextNodeName() string {
    i := 0
    for {
        name := fmt.Sprintf("%s%d", ng.Name, i)
        if ii := ng.findNode(name); ii != -1 {
            i++
            continue
        }
        return name
    }
}

docker buildx ls lists all builders with their respective node(s).

Riwen
  • 4,734
  • 2
  • 19
  • 31