k0sproject / k0sproject/bootloose

`portMappings.hostPort` does not reset on multiple machine specs

Open
#108 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
70
Forks
10
PR merge metrics
No merged PRs in 30d

Description

According to [specification](https://pkg.go.dev/github.com/k0sproject/bootloose/pkg/config?#PortMapping) and common sense, when `bootloose.yaml` defines several machine sets (e.g. workers and controllers), you'd expect `portMappings.hostPort` to be the base for port numbers only in a given machine set, not globally. However, the counter continues through all machine replicas in all specifications that include `hostPort` - contrary to `name` field, which expands `%d` as replica counter in given set.

Bootloose version: `v0.8.0`

---

Example `bootloose.yaml`:

```yaml
cluster:
name: foo
privateKey: cluster-key
machines:
- count: 3
spec:
image: quay.io/k0sproject/bootloose-ubuntu22.04
name: a%d
portMappings:
- containerPort: 22
hostPort: 13000
- count: 3
spec:
image: quay.io/k0sproject/bootloose-ubuntu22.04
name: b%d
portMappings:
- containerPort: 22
hostPort: 14000
- count: 3
spec:
image: quay.io/k0sproject/bootloose-ubuntu22.04
name: c%d
portMappings:
- containerPort: 22
hostPort: 15000
```

Expected mapping for port 22 in each container created:

- a0 - 13000, a1 - 13001, a2 - 13002
- b0 - 14000, b1 - 14001, b2 - 14002
- c0 - 15000, c1 - 15001, c2 - 15002

Actual behaviour - `bootloose show`:

```
NAME HOSTNAME PORTS IP IMAGE CMD STATE
foo-a0 a0 0->{22 13000} 172.17.0.2 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-a1 a1 0->{22 13001} 172.17.0.3 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-a2 a2 0->{22 13002} 172.17.0.4 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-b0 b0 0->{22 14003} 172.17.0.5 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-b1 b1 0->{22 14004} 172.17.0.6 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-b2 b2 0->{22 14005} 172.17.0.7 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-c0 c0 0->{22 15006} 172.17.0.8 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-c1 c1 0->{22 15007} 172.17.0.9 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
foo-c2 c2 0->{22 15008} 172.17.0.10 quay.io/k0sproject/bootloose-ubuntu22.04 /sbin/init Running
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.