In order to distribute network boot images, sabakan provides an image management system as follows.
-
Operators need to upload a boot image only to one sabakan server.
Rest of sabakan servers will automatically pull the image from the server.
-
Sabakan keeps some versions of boot images.
In case a new image had fatal defects, the change can be rolled back by simply removing the new image or by uploading the previous stable image. Note that once you remove the image, you cannot upload it with the same ID.
sabakan saves uploaded images under /var/lib/sabakan/images/OS
directory.
OS
can be an arbitrary identifier such as "coreos".
sabakan keeps an index of available images per OS in etcd. The structure of the index is a JSON like this:
[
{
"id": "1688.5.3",
"date": "2017-12-02T15:04:05Z",
"size": 10000000,
"urls": [
"http://10.1.2.3:10080/api/v1/images/coreos/1688.5.3",
"http://10.98.76.54:10080/api/v1/images/coreos/1688.5.3"
],
"exists": true
},
{
"id": "1745.4.0",
"date": "2018-05-29T01:23:45Z",
"size": 10000000,
"urls": [
"http://10.1.2.3:10080/api/v1/images/coreos/1745.4.0"
],
"exists": false
}
]
urls
is a list of URLs where the image archive can be downloaded.
Details are described in the next section.
exists
is only meaningful when this JSON is returned from a REST API.
It becomes true
if the server has a local copy of the image.
Firstly, only one sabakan server in the cluster has a new image. Other sabakan servers need to pull the image from the first server.
To distribute new images, the first server update the index in etcd and
stores a download URL from the server in urls
field.
Each sabakan server watches the index in etcd, and finds new images.
When a server finds a new image in the index, it downloads the image through
a URL in urls
. After the server pulled the image, it may optionally add
a URL to download the image from itself for load-balancing.
When an image is removed from the index, the ID of the index is added
to a list saved in <prefix>/images/coreos/deleted
key in etcd.
Each sabakan server watches the key to remove local copy of the deleted images.
iPXE downloads a kernel and initial root filesystem image from sabakan.
Sabakan handles these requests from iPXE as follows:
- Retrieve an image index from etcd.
- Choose the most-recently-uploaded image in the index.
- Look for the image in the local directory.
- If the image is found, then return it in the response.
- If not, choose the next recently-uploaded image in the index. Go to 3.