Skip to content

Commit

Permalink
Use only latest images (#182)
Browse files Browse the repository at this point in the history
* pkg/env: Use only latest images

* pkg/models/config: Update tests to reflect image changes

Signed-off-by: Din Music <[email protected]>

* embed/presets: Update default preset distro

Signed-off-by: Din Music <[email protected]>

* docs: Update docs to reflect image changes

Signed-off-by: Din Music <[email protected]>

---------

Signed-off-by: Din Music <[email protected]>
  • Loading branch information
MusicDin authored Apr 6, 2024
1 parent e4030d3 commit b9edda1
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 71 deletions.
2 changes: 1 addition & 1 deletion docs/examples/full-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cluster:
privateKeyPath: "~/.ssh/id_rsa_test"
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
networkInterface: ens3 # (20)!
dns: # (21)!
- 1.1.1.1
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/ha-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ cluster:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
loadBalancer:
vip: 10.10.13.200
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/multi-master-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The load balancer is then configured to distribute traffic received on port 6443
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
loadBalancer:
instances:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/multi-worker-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cluster:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
instances:
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/rook-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ However, this behavior can be restricted using node selectors, which are explain
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
instances:
Expand Down Expand Up @@ -238,7 +238,7 @@ addons:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
instances:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/single-node-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ This means that the single master node in the cluster will perform both the cont
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
default:
Expand Down
23 changes: 10 additions & 13 deletions docs/user-guide/configuration/cluster-node-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cluster:
:material-tag-arrow-up-outline: [v2.1.0][tag 2.1.0]
&ensp;
:octicons-file-symlink-file-24: Default: `ubuntu`
:octicons-file-symlink-file-24: Default: `ubuntu22`

The operating system for virtual machines can be specified in the node template.
By default, the Ubuntu distribution is installed on all virtual machines.
Expand All @@ -48,23 +48,20 @@ You can select a desired distribution by setting the `os.distro` property.
cluster:
nodeTemplate:
os:
distro: debian # (1)!
distro: debian12 # (1)!
```

1. By default, `ubuntu` is used.
1. By default, `ubuntu22` is used.


The available operating system distribution presets are:

+ **`ubuntu`** - Latest Ubuntu 22.04 release. (default)
+ `ubuntu22` - Ubuntu 22.04 release as of *2023-10-26*.
+ `ubuntu20` - Ubuntu 20.04 release as of *2023-10-11*.
+ **`debian`** - Latest Debian 11 release.
+ `debian11` - Debian 11 release as of *2023-10-13*.
+ **`rocky`** - Latest Rocky 9 release.
+ `rocky9` - Rocky 9.2 release as of *2023-05-13*.
+ **`centos`** - Latest CentOS Stream 9 release.
+ `centos9` - CentOS Stream 9 release as of *2023-10-23*.
+ **`ubuntu20`** - Latest Ubuntu 20.04 (Focal) release.
+ **`ubuntu22`** - Latest Ubuntu 22.04 (Jammy) release. (default)
+ **`debian11`** - Latest Debian 11 (Bullseye) release.
+ **`debian12`** - Latest Debian 12 (Bookworm) release.
+ **`centos9`** - Latest CentOS Stream 9 release.
+ **`rocky9`** - Latest Rocky 9 release.

!!! warning "Important"

Expand Down Expand Up @@ -98,7 +95,7 @@ The source of an image can be either a local path on your system or a URL pointi
cluster:
nodeTemplate:
os:
distro: ubuntu
distro: ubuntu20
source: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
```

Expand Down
11 changes: 4 additions & 7 deletions docs/user-guide/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,20 +642,17 @@ Each configuration property is documented with 5 columns: Property name, descrip
<tr>
<td><code>cluster.nodeTemplate.os.distro</code></td>
<td>string</td>
<td>ubuntu</td>
<td>ubuntu22</td>
<td></td>
<td>
Set OS distribution. Possible values are:
<ul>
<li><code>ubuntu</code></li>
<li><code>ubuntu22</code></li>
<li><code>ubuntu20</code></li>
<li><code>debian</code></li>
<li><code>ubuntu22</code></li>
<li><code>debian11</code></li>
<li><code>rocky</code></li>
<li><code>rocky9</code></li>
<li><code>centos</code></li>
<li><code>debian12</code></li>
<li><code>centos9</code></li>
<li><code>rocky9</code></li>
</ul>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion embed/presets/example-multi-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cluster:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
loadBalancer:
instances:
Expand Down
2 changes: 1 addition & 1 deletion embed/presets/example-multi-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cluster:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
instances:
Expand Down
2 changes: 1 addition & 1 deletion embed/presets/example-single-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cluster:
ssh:
addToKnownHosts: true
os:
distro: ubuntu
distro: ubuntu22
nodes:
master:
default:
Expand Down
30 changes: 9 additions & 21 deletions pkg/env/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,28 @@ var ProjectOsPresets = map[string]struct {
Source string
NetworkInterface string
}{
"ubuntu": {
Source: "https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64.img",
NetworkInterface: "ens3",
},
"ubuntu22": {
Source: "https://cloud-images.ubuntu.com/releases/jammy/release-20231026/ubuntu-22.04-server-cloudimg-amd64.img",
NetworkInterface: "ens3",
},
"ubuntu20": {
Source: "https://cloud-images.ubuntu.com/releases/focal/release-20231011/ubuntu-20.04-server-cloudimg-amd64.img",
Source: "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img",
NetworkInterface: "ens3",
},
"debian": {
Source: "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2",
"ubuntu22": {
Source: "https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64.img",
NetworkInterface: "ens3",
},
"debian11": {
Source: "https://cloud.debian.org/images/cloud/bullseye/20231013-1532/debian-11-genericcloud-amd64-20230601-1398.qcow2",
Source: "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2",
NetworkInterface: "ens3",
},
"centos": {
Source: "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2",
NetworkInterface: "eth0",
"debian12": {
Source: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2",
NetworkInterface: "ens3",
},
"centos9": {
Source: "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-20231023.1.x86_64.qcow2",
NetworkInterface: "eth0",
},
"rocky": {
Source: "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2",
Source: "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2",
NetworkInterface: "eth0",
},
"rocky9": {
Source: "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base-9.2-20230513.0.x86_64.qcow2",
Source: "https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2",
NetworkInterface: "eth0",
},
}
11 changes: 4 additions & 7 deletions pkg/models/config/cluster_node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s OS) Validate() error {
}

func (s *OS) SetDefaults() {
s.Distro = defaults.Default(s.Distro, UBUNTU)
s.Distro = defaults.Default(s.Distro, UBUNTU22)

preset := env.ProjectOsPresets[string(s.Distro)]
s.NetworkInterface = defaults.Default(s.NetworkInterface, OSNetworkInterface(preset.NetworkInterface))
Expand All @@ -58,19 +58,16 @@ func (s *OS) SetDefaults() {
type OSDistro string

const (
UBUNTU OSDistro = "ubuntu"
UBUNTU20 OSDistro = "ubuntu20"
UBUNTU22 OSDistro = "ubuntu22"
DEBIAN OSDistro = "debian"
UBUNTU20 OSDistro = "ubuntu20"
DEBIAN11 OSDistro = "debian11"
CENTOS OSDistro = "centos"
DEBIAN12 OSDistro = "debian12"
CENTOS9 OSDistro = "centos9"
ROCKY OSDistro = "rocky"
ROCKY9 OSDistro = "rocky9"
)

func (d OSDistro) Validate() error {
return v.Var(d, v.OneOf(UBUNTU, UBUNTU20, UBUNTU22, DEBIAN, DEBIAN11, CENTOS, CENTOS9, ROCKY, ROCKY9))
return v.Var(d, v.OneOf(UBUNTU20, UBUNTU22, DEBIAN11, DEBIAN12, CENTOS9, ROCKY9))
}

type OSNetworkInterface string
Expand Down
26 changes: 13 additions & 13 deletions pkg/models/config/cluster_node_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
)

func TestOSDistro(t *testing.T) {
assert.NoError(t, OSDistro(UBUNTU).Validate())
assert.NoError(t, OSDistro("ubuntu").Validate())
assert.NoError(t, OSDistro("debian").Validate())
assert.Error(t, OSDistro("wrong").Validate())
assert.NoError(t, OSDistro(UBUNTU20).Validate())
assert.NoError(t, OSDistro("ubuntu22").Validate())
assert.NoError(t, OSDistro("debian12").Validate())
assert.Error(t, OSDistro("invalid").Validate())
}

func TestOSDistro_Presets(t *testing.T) {
Expand All @@ -30,28 +30,28 @@ func TestOSNetworkInterface(t *testing.T) {
}

func TestOS_Empty(t *testing.T) {
assert.ErrorContains(t, OS{}.Validate(), "Field 'distro' must be one of the following values: [ubuntu|")
assert.ErrorContains(t, OS{}.Validate(), "Field 'distro' must be one of the following values: [ubuntu20|")
assert.ErrorContains(t, OS{}.Validate(), "Field 'networkInterface' can contain only alphanumeric characters.")
}

func TestOS_Defaults(t *testing.T) {
os1 := OS{Distro: UBUNTU}
os2 := OS{Distro: ROCKY}
os1 := OS{Distro: CENTOS9}
os2 := OS{Distro: ROCKY9}
os3 := OS{Source: OSSource("./cluster_node_template_test.go")}

assert.NoError(t, defaults.Assign(&OS{}).Validate())
assert.NoError(t, defaults.Assign(&os1).Validate())
assert.NoError(t, defaults.Assign(&os2).Validate())
assert.NoError(t, defaults.Assign(&os3).Validate())

assert.Equal(t, UBUNTU, os1.Distro)
assert.Equal(t, ROCKY, os2.Distro)
assert.Equal(t, UBUNTU, os3.Distro)
assert.Equal(t, "ens3", string(os1.NetworkInterface))
assert.Equal(t, CENTOS9, os1.Distro)
assert.Equal(t, ROCKY9, os2.Distro)
assert.Equal(t, UBUNTU22, os3.Distro)
assert.Equal(t, "eth0", string(os1.NetworkInterface))
assert.Equal(t, "eth0", string(os2.NetworkInterface))
assert.Equal(t, "ens3", string(os3.NetworkInterface))
assert.Equal(t, env.ProjectOsPresets["ubuntu"].Source, string(os1.Source))
assert.Equal(t, env.ProjectOsPresets["rocky"].Source, string(os2.Source))
assert.Equal(t, env.ProjectOsPresets["centos9"].Source, string(os1.Source))
assert.Equal(t, env.ProjectOsPresets["rocky9"].Source, string(os2.Source))
assert.Equal(t, "./cluster_node_template_test.go", string(os3.Source))
}

Expand Down

0 comments on commit b9edda1

Please sign in to comment.