Skip to content
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

Support arm64 #46

Merged
merged 2 commits into from
Mar 14, 2024
Merged
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
############# builder
FROM golang:1.21.1 AS builder
FROM golang:1.21.4 AS builder

WORKDIR /go/src/github.com/gardener/gardener-extension-provider-openstack
COPY . .
Expand All @@ -15,6 +15,7 @@ FROM gcr.io/distroless/static-debian11:nonroot AS base
FROM base AS gardener-extension-provider-openstack
WORKDIR /

COPY charts /charts
COPY --from=builder /go/bin/gardener-extension-provider-openstack /gardener-extension-provider-openstack
ENTRYPOINT ["/gardener-extension-provider-openstack"]

Expand Down
37 changes: 37 additions & 0 deletions docs/operations/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ machineImages:
- name: coreos
versions:
- version: 2135.6.0
# Fallback to image name if no region mapping is found
# Only works for amd64 and is strongly discouraged. Prefer image IDs!
image: coreos-2135.6.0
regions:
- name: europe
id: "1234-amd64"
architecture: amd64 # optional, defaults to amd64
- name: europe
id: "1234-arm64"
architecture: arm64
- name: asia
id: "5678-amd64"
architecture: amd64
# keystoneURL: https://url-to-keystone/v3/
# keystoneURLs:
# - region: europe
Expand Down Expand Up @@ -158,11 +170,24 @@ spec:
- name: coreos
versions:
- version: 2135.6.0
architectures: # optional, defaults to [amd64]
- amd64
- arm64
machineTypes:
- name: medium_4_8
cpu: "4"
gpu: "0"
memory: 8Gi
architecture: amd64 # optional, defaults to amd64
storage:
class: standard
type: default
size: 40Gi
- name: medium_4_8_arm
cpu: "4"
gpu: "0"
memory: 8Gi
architecture: arm64
storage:
class: standard
type: default
Expand All @@ -180,7 +205,19 @@ spec:
- name: coreos
versions:
- version: 2135.6.0
# Fallback to image name if no region mapping is found
# Only works for amd64 and is strongly discouraged. Prefer image IDs!
image: coreos-2135.6.0
regions:
- name: europe
id: "1234-amd64"
architecture: amd64 # optional, defaults to amd64
- name: europe
id: "1234-arm64"
architecture: arm64
- name: asia
id: "5678-amd64"
architecture: amd64
keystoneURL: https://url-to-keystone/v3/
constraints:
floatingPools:
Expand Down
24 changes: 24 additions & 0 deletions hack/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,18 @@ string
<p>ID is the id of the image. (one of Image or ID must be set)</p>
</td>
</tr>
<tr>
<td>
<code>architecture</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Architecture is the CPU architecture of the machine image</p>
</td>
</tr>
</tbody>
</table>
<h3 id="openstack.provider.extensions.gardener.cloud/v1alpha1.MachineImageVersion">MachineImageVersion
Expand Down Expand Up @@ -1480,6 +1492,18 @@ string
<p>ID is the ID for the machine image in the given region.</p>
</td>
</tr>
<tr>
<td>
<code>architecture</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Architecture is the CPU architecture of the machine image</p>
</td>
</tr>
</tbody>
</table>
<h3 id="openstack.provider.extensions.gardener.cloud/v1alpha1.Router">Router
Expand Down
36 changes: 25 additions & 11 deletions pkg/apis/openstack/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package helper
import (
"fmt"

v1beta1constants "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants"
"k8s.io/utils/pointer"

api "github.com/gardener/gardener-extension-provider-openstack/pkg/apis/openstack"
"github.com/gardener/gardener-extension-provider-openstack/pkg/utils"
)
Expand Down Expand Up @@ -48,9 +51,11 @@ func FindSecurityGroupByPurpose(securityGroups []api.SecurityGroup, purpose api.
// FindMachineImage takes a list of machine images and tries to find the first entry
// whose name, version, and zone matches with the given name, version, and cloud profile. If no such
// entry is found then an error will be returned.
func FindMachineImage(machineImages []api.MachineImage, name, version string) (*api.MachineImage, error) {
func FindMachineImage(machineImages []api.MachineImage, name, version, architecture string) (*api.MachineImage, error) {
for _, machineImage := range machineImages {
if machineImage.Name == name && machineImage.Version == version {
// If the architecture field is not present, ignore it for backwards-compatibility.
if machineImage.Name == name && machineImage.Version == version &&
(machineImage.Architecture == nil || *machineImage.Architecture == architecture) {
return &machineImage, nil
}
}
Expand All @@ -60,7 +65,7 @@ func FindMachineImage(machineImages []api.MachineImage, name, version string) (*
// FindImageFromCloudProfile takes a list of machine images, and the desired image name and version. It tries
// to find the image with the given name and version in the desired cloud profile. If it cannot be found then an error
// is returned.
func FindImageFromCloudProfile(cloudProfileConfig *api.CloudProfileConfig, imageName, imageVersion, regionName string) (*api.MachineImage, error) {
func FindImageFromCloudProfile(cloudProfileConfig *api.CloudProfileConfig, imageName, imageVersion, regionName, architecture string) (*api.MachineImage, error) {
if cloudProfileConfig != nil {
for _, machineImage := range cloudProfileConfig.MachineImages {
if machineImage.Name != imageName {
Expand All @@ -71,19 +76,28 @@ func FindImageFromCloudProfile(cloudProfileConfig *api.CloudProfileConfig, image
continue
}
for _, region := range version.Regions {
if regionName == region.Name {
if regionName == region.Name && architecture == pointer.StringDeref(region.Architecture, v1beta1constants.ArchitectureAMD64) {
return &api.MachineImage{
Name: imageName,
Version: imageVersion,
ID: region.ID,
Name: imageName,
Version: imageVersion,
Architecture: &architecture,
ID: region.ID,
}, nil
}
}
if version.Image != "" {

// if we haven't found a region mapping, fallback to the image name
if version.Image != "" && architecture == v1beta1constants.ArchitectureAMD64 {
// The fallback image name doesn't specify an architecture, but we assume it is amd64 as arm was not supported
// previously.
// Referencing images by name is error-prone and is highly discouraged anyways.
// If people want to use arm images in their CloudProfile, they need to specify a region mapping and can't
// use the fallback MachineImage by name.
return &api.MachineImage{
Name: imageName,
Version: imageVersion,
Image: version.Image,
Name: imageName,
Version: imageVersion,
Architecture: pointer.String(v1beta1constants.ArchitectureAMD64),
Image: version.Image,
}, nil
}
}
Expand Down
Loading
Loading