Skip to content

Add Scaleway packer provider #1771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [OpenStack remote image building](./capi/providers/openstack-remote.md)
- [OCI](./capi/providers/oci.md)
- [raw](./capi/providers/raw.md)
- [Scaleway](./capi/providers/scaleway.md)
- [vSphere](./capi/providers/vsphere.md)
- [Proxmox](./capi/providers/proxmox.md)
- [Windows](./capi/windows/windows.md)
Expand Down
1 change: 1 addition & 0 deletions docs/book/src/capi/capi.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If any needed binaries are not present, they can be installed to `images/capi/.b
* [OpenStack](./providers/openstack.md)
* [OpenStack remote image building](./providers/openstack-remote.md)
* [Raw](./providers/raw.md)
* [Scaleway](./providers/scaleway.md)
* [VirtualBox](./providers/virtualbox.md)
* [vSphere](./providers/vsphere.md)
* [Proxmox](./providers/proxmox.md)
Expand Down
29 changes: 29 additions & 0 deletions docs/book/src/capi/providers/scaleway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Building Images for Scaleway

## Prerequisites for Scaleway

- A Scaleway account
- Export environment variable for `SCW_PROJECT_ID`, `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`

## Building Images

The build [prerequisites](../capi.md#prerequisites) for using `image-builder` for
building Scaleway images are managed by running:

```bash
make deps-scaleway
```

From the `images/capi` directory, run `make build-scaleway-<OS>` where `<OS>` is the desired operating system. The available choices are listed via `make help`.

### Configuration

In addition to the configuration found in `images/capi/packer/config`, the `scaleway`
directory includes the JSON files that define the default configuration for
the different operating systems.

| File | Description |
| ------------------- | ---------------------------------------- |
| `rockylinux-9.json` | The settings for the Rocky Linux 9 image |
| `ubuntu-2204.json` | The settings for the Ubuntu 22.04 image |
| `ubuntu-2404.json` | The settings for the Ubuntu 24.04 image |
30 changes: 29 additions & 1 deletion images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ deps-vultr: deps-common
$(PACKER) init packer/config.pkr.hcl
$(PACKER) init packer/vultr/config.pkr.hcl

.PHONY: deps-scaleway
deps-scaleway: ## Installs/checks dependencies for Scaleway builds
deps-scaleway: deps-common
$(PACKER) init packer/config.pkr.hcl
$(PACKER) init packer/scaleway/config.pkr.hcl

## --------------------------------------
## Packer Configuration
## --------------------------------------
Expand Down Expand Up @@ -404,6 +410,8 @@ VULTR_BUILD_NAMES ?= vultr-ubuntu-2204

MAAS_BUILD_NAMES ?= maas-ubuntu-2204-efi maas-ubuntu-2404-efi

SCALEWAY_BUILD_NAMES ?= scaleway-rockylinux-9 scaleway-ubuntu-2204 scaleway-ubuntu-2404

## --------------------------------------
## Dynamic build targets
## --------------------------------------
Expand Down Expand Up @@ -454,6 +462,8 @@ VULTR_BUILD_TARGETS := $(addprefix build-,$(VULTR_BUILD_NAMES))
VULTR_VALIDATE_TARGETS := $(addprefix validate-,$(VULTR_BUILD_NAMES))
MAAS_BUILD_TARGETS := $(addprefix build-,$(MAAS_BUILD_NAMES))
MAAS_VALIDATE_TARGETS := $(addprefix validate-,$(MAAS_BUILD_NAMES))
SCALEWAY_BUILD_TARGETS := $(addprefix build-,$(SCALEWAY_BUILD_NAMES))
SCALEWAY_VALIDATE_TARGETS := $(addprefix validate-,$(SCALEWAY_BUILD_NAMES))

.PHONY: $(NODE_OVA_LOCAL_BUILD_TARGETS)
$(NODE_OVA_LOCAL_BUILD_TARGETS): deps-ova set-ssh-password
Expand Down Expand Up @@ -654,6 +664,13 @@ $(MAAS_BUILD_TARGETS): deps-qemu set-ssh-password
$(MAAS_VALIDATE_TARGETS): deps-qemu set-ssh-password
$(PACKER) validate $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/maas/$(subst validate-,,$@).json)" --var="ansible_user_vars=provider=maas" $(ABSOLUTE_PACKER_VAR_FILES) packer/maas/packer.json

.PHONY: $(SCALEWAY_BUILD_TARGETS)
$(SCALEWAY_BUILD_TARGETS): deps-scaleway
$(PACKER) build $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/scaleway/$(subst build-scaleway-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/scaleway/packer.json

.PHONY: $(SCALEWAY_VALIDATE_TARGETS)
$(SCALEWAY_VALIDATE_TARGETS): deps-scaleway
$(PACKER) validate $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/scaleway/$(subst validate-scaleway-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/scaleway/packer.json

## --------------------------------------
## Dynamic clean targets
Expand Down Expand Up @@ -920,6 +937,11 @@ build-proxmox-rockylinux-9: ## Builds the Proxmox rockylinux-9 image

build-vultr-ubuntu-2204: ## Builds Ubuntu 22.04 Vultr Snapshot

build-scaleway-rockylinux-9: ## Builds the Scaleway rockylinux-9 image
build-scaleway-ubuntu-2204: ## Builds Ubuntu 22.04 Scaleway image
build-scaleway-ubuntu-2404: ## Builds Ubuntu 24.04 Scaleway image
build-scaleway-all: $(SCALEWAY_BUILD_TARGETS) ## Builds all Scaleway Cloud images

## --------------------------------------
## Document dynamic validate targets
## --------------------------------------
Expand Down Expand Up @@ -1109,6 +1131,11 @@ validate-proxmox-flatcar: ## Validates Flatcar Proxmox Packer config

validate-vultr-ubuntu-2204: ## Validates Ubuntu 22.04 Vultr Snapshot Packer config

validate-scaleway-rockylinux-9: ## Validates Rocky Linux 9 Scaleway image Packer config
validate-scaleway-ubuntu-2204: ## Validates Ubuntu 22.04 Scaleway image Packer config
validate-scaleway-ubuntu-2404: ## Validates Ubuntu 24.04 Scaleway image Packer config
validate-scaleway-all: $(SCALEWAY_VALIDATE_TARGETS) ## Validates all Scaleway Cloud Packer config

validate-all: validate-ami-all \
validate-azure-all \
validate-do-all \
Expand All @@ -1120,7 +1147,8 @@ validate-all: validate-ami-all \
validate-osc-all \
validate-powervs-all \
validate-nutanix-all \
validate-hcloud-all
validate-hcloud-all \
validate-scaleway-all

validate-all: ## Validates the Packer config for all build targets

Expand Down
3 changes: 3 additions & 0 deletions images/capi/ansible/roles/providers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
- ansible.builtin.include_tasks: huaweicloud.yml
when: packer_builder_type.startswith('huaweicloud')

- ansible.builtin.include_tasks: scaleway.yml
when: packer_builder_type.startswith('scaleway')

- ansible.builtin.include_tasks: maas.yml
when: packer_builder_type is search('qemu') and provider is defined and provider is search('maas')

Expand Down
20 changes: 20 additions & 0 deletions images/capi/ansible/roles/providers/tasks/scaleway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 The Kubernetes Authors.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Disable Hyper-V KVP protocol daemon on Ubuntu
ansible.builtin.systemd:
name: hv-kvp-daemon
state: stopped
enabled: false
when: ansible_os_family == "Debian"
4 changes: 2 additions & 2 deletions images/capi/ansible/roles/setup/tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
ansible.builtin.rpm_key:
state: present
key: "{{ epel_rpm_gpg_key }}"
when: epel_rpm_gpg_key != "" and not packer_builder_type.startswith('amazon')
when: epel_rpm_gpg_key != "" and not packer_builder_type.startswith('amazon') and not packer_builder_type.startswith('scaleway')

- name: Add epel repo
ansible.builtin.yum:
name: "{{ redhat_epel_rpm }}"
state: present
lock_timeout: 60
when: redhat_epel_rpm != "" and not packer_builder_type.startswith('amazon')
when: redhat_epel_rpm != "" and not packer_builder_type.startswith('amazon') and not packer_builder_type.startswith('scaleway')

- ansible.builtin.import_tasks: rpm_repos.yml

Expand Down
12 changes: 12 additions & 0 deletions images/capi/packer/goss/goss-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ rockylinux:
- distro_version: "9"
package:
<<: *rh9_rpms
scaleway:
package:
cloud-init:
cloud-utils-growpart:
os_version:
- distro_version: "9"
package:
<<: *rh9_rpms
rhel:
common-package: *common_rpms
amazon:
Expand Down Expand Up @@ -566,6 +574,10 @@ ubuntu:
cloud-guest-utils:
cloud-initramfs-copymods:
cloud-initramfs-dyn-netconf:
scaleway:
service:
package:
command:

oracle linux:
common-kernel-param:
Expand Down
8 changes: 8 additions & 0 deletions images/capi/packer/scaleway/config.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
packer {
required_plugins {
scaleway = {
source = "github.com/scaleway/scaleway"
version = "~> 1.3.2"
}
}
}
111 changes: 111 additions & 0 deletions images/capi/packer/scaleway/packer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"builders": [
{
"access_key": "{{user `access_key`}}",
"commercial_type": "{{user `commercial_type`}}",
"image": "{{user `image`}}",
"image_name": "{{user `image_name`}}",
"project_id": "{{user `project_id`}}",
"remove_volume": true,
"root_volume": {
"type": "{{user `root_volume_type`}}"
},
"secret_key": "{{user `secret_key`}}",
"ssh_username": "root",
"type": "scaleway",
"zone": "{{user `zone`}}"
}
],
"provisioners": [
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/node.yml",
"type": "ansible"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": true,
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"ARCH": "amd64",
"OS": "{{user `distribution` | lower}}",
"OS_VERSION": "{{user `distribution_version` | lower}}",
"PROVIDER": "scaleway",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
},
"version": "{{user `goss_version`}}"
}
],
"variables": {
"access_key": "{{env `SCW_ACESS_KEY`}}",
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_scp_extra_args": "",
"build_timestamp": "{{timestamp}}",
"commercial_type": "DEV1-S",
"containerd_gvisor_runtime": "false",
"containerd_gvisor_version": "latest",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"image_name": "cluster-api-{{user `build_name`}}-{{user `kubernetes_semver`}}-{{user `build_timestamp`}}",
"kubernetes_cni_deb_version": null,
"kubernetes_cni_http_source": null,
"kubernetes_cni_rpm_version": null,
"kubernetes_cni_semver": null,
"kubernetes_cni_source_type": null,
"kubernetes_container_registry": null,
"kubernetes_deb_gpg_key": null,
"kubernetes_deb_repo": null,
"kubernetes_deb_version": null,
"kubernetes_http_source": null,
"kubernetes_load_additional_imgs": null,
"kubernetes_rpm_gpg_check": null,
"kubernetes_rpm_gpg_key": null,
"kubernetes_rpm_repo": null,
"kubernetes_rpm_version": null,
"kubernetes_semver": null,
"kubernetes_series": null,
"kubernetes_source_type": null,
"project_id": "{{env `SCW_PROJECT_ID`}}",
"root_volume_type": "sbs_volume",
"secret_key": "{{env `SCW_SECRET_KEY`}}",
"zone": "fr-par-1"
}
}
6 changes: 6 additions & 0 deletions images/capi/packer/scaleway/rockylinux-9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build_name": "rockylinux-9",
"distribution": "rockylinux",
"distribution_version": "9",
"image": "rockylinux_9"
}
6 changes: 6 additions & 0 deletions images/capi/packer/scaleway/ubuntu-2204.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build_name": "ubuntu-2204",
"distribution": "ubuntu",
"distribution_version": "2204",
"image": "ubuntu_jammy"
}
6 changes: 6 additions & 0 deletions images/capi/packer/scaleway/ubuntu-2404.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build_name": "ubuntu-2404",
"distribution": "ubuntu",
"distribution_version": "2404",
"image": "ubuntu_noble"
}
1 change: 1 addition & 0 deletions images/capi/scripts/ci-packer-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ AZURE_LOCATION=fake RESOURCE_GROUP_NAME=fake STORAGE_ACCOUNT_NAME=fake \
NUTANIX_ENDPOINT=fake NUTANIX_CLUSTER_NAME=fake NUTANIX_USERNAME=fake \
NUTANIX_PASSWORD=fake NUTANIX_SUBNET_NAME=fake \
HCLOUD_LOCATION=fake HCLOUD_TOKEN=fake \
SCW_ACCESS_KEY=fake SCW_PROJECT_ID=fake SCW_SECRET_KEY=fake \
make validate-all