Skip to content

Commit ea9ff03

Browse files
authored
Merge pull request #5167 from mboersma/community-gallery-ref-images
Use community gallery for default VM images
2 parents 74bd11f + f05ef21 commit ea9ff03

24 files changed

+234
-1206
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ARG ARCH
1919

2020
# Build the manager binary
21-
FROM golang:1.22 as builder
21+
FROM golang:1.22 AS builder
2222
WORKDIR /workspace
2323

2424
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ GINKGO_VER := $(shell go list -m -f '{{.Version}}' github.com/onsi/ginkgo/v2)
114114
GINKGO_BIN := ginkgo
115115
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)
116116

117-
KUBECTL_VER := v1.28.4
117+
KUBECTL_VER := v1.29.10
118118
KUBECTL_BIN := kubectl
119119
KUBECTL := $(TOOLS_BIN_DIR)/$(KUBECTL_BIN)-$(KUBECTL_VER)
120120

Tiltfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def validate_auth():
129129

130130
tilt_helper_dockerfile_header = """
131131
# Tilt image
132-
FROM golang:1.22 as tilt-helper
132+
FROM golang:1.22 AS tilt-helper
133133
# Support live reloading with Tilt
134134
RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/restart.sh && \
135135
wget --output-document /start.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/start.sh && \
@@ -138,7 +138,7 @@ RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com
138138
"""
139139

140140
tilt_dockerfile_header = """
141-
FROM gcr.io/distroless/base:debug as tilt
141+
FROM gcr.io/distroless/base:debug AS tilt
142142
WORKDIR /tilt
143143
RUN ["/busybox/chmod", "0777", "."]
144144
COPY --from=tilt-helper /process.txt .

api/v1beta1/azuremachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type AzureMachineSpec struct {
4444
FailureDomain *string `json:"failureDomain,omitempty"`
4545

4646
// Image is used to provide details of an image to use during VM creation.
47-
// If image details are omitted the image will default the Azure Marketplace "capi" offer,
48-
// which is based on Ubuntu.
47+
// If image details are omitted, the default is to use an Azure Compute Gallery Image
48+
// from CAPZ's community gallery.
4949
// +kubebuilder:validation:nullable
5050
// +optional
5151
Image *Image `json:"image,omitempty"`

azure/converters/vmss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func GetOrchestrationMode(modeType infrav1.OrchestrationModeType) armcompute.Orc
183183
return armcompute.OrchestrationModeUniform
184184
}
185185

186-
// IDImageRefToImage converts an ID to a infrav1.Image with ComputerGallery set or ID, depending on the structure of the ID.
186+
// IDImageRefToImage converts an ID to a infrav1.Image with ComputeGallery set or ID, depending on the structure of the ID.
187187
func IDImageRefToImage(id string) infrav1.Image {
188188
// compute gallery image
189189
if ok, params := getParams(RegExpStrComputeGalleryID, id); ok {

azure/defaults.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ const (
4848
)
4949

5050
const (
51-
// DefaultImageOfferID is the default Azure Marketplace offer ID.
52-
DefaultImageOfferID = "capi"
53-
// DefaultWindowsImageOfferID is the default Azure Marketplace offer ID for Windows.
54-
DefaultWindowsImageOfferID = "capi-windows"
55-
// DefaultImagePublisherID is the default Azure Marketplace publisher ID.
56-
DefaultImagePublisherID = "cncf-upstream"
57-
// LatestVersion is the image version latest.
58-
LatestVersion = "latest"
51+
// DefaultPublicGalleryName is the default Azure compute gallery.
52+
DefaultPublicGalleryName = "ClusterAPI-f72ceb4f-5159-4c26-a0fe-2ea738f0d019"
53+
// DefaultLinuxGalleryImageName is the default Linux community gallery image definition.
54+
DefaultLinuxGalleryImageName = "capi-ubun2-2404"
55+
// DefaultWindowsGalleryImageName is the default Windows community gallery image definition.
56+
DefaultWindowsGalleryImageName = "capi-win-2019-containerd"
5957
)
6058

6159
const (

azure/scope/machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ func (m *MachineScope) GetVMImage(ctx context.Context) (*infrav1.Image, error) {
727727
}
728728

729729
log.Info("No image specified for machine, using default Linux Image", "machine", m.AzureMachine.GetName())
730-
return svc.GetDefaultUbuntuImage(ctx, m.Location(), ptr.Deref(m.Machine.Spec.Version, ""))
730+
return svc.GetDefaultLinuxImage(ctx, m.Location(), ptr.Deref(m.Machine.Spec.Version, ""))
731731
}
732732

733733
// SetSubnetName defaults the AzureMachine subnet name to the name of one the subnets with the machine role when there is only one of them.

azure/scope/machine_test.go

Lines changed: 8 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
"sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus"
4444
"sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments"
4545
"sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages"
46-
"sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages/mock_virtualmachineimages"
4746
"sigs.k8s.io/cluster-api-provider-azure/azure/services/vmextensions"
4847
)
4948

@@ -1538,7 +1537,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15381537
clusterMock.EXPECT().SubscriptionID().AnyTimes()
15391538
clusterMock.EXPECT().CloudEnvironment().AnyTimes()
15401539
clusterMock.EXPECT().Token().Return(&azidentity.DefaultAzureCredential{}).AnyTimes()
1541-
svc := virtualmachineimages.Service{Client: mock_virtualmachineimages.NewMockClient(mockCtrl)}
1540+
svc := virtualmachineimages.Service{}
15421541

15431542
tests := []struct {
15441543
name string
@@ -1547,7 +1546,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15471546
expectedErr string
15481547
}{
15491548
{
1550-
name: "returns AzureMachine image is found if present in the AzureMachine spec",
1549+
name: "returns AzureMachine image if present in the AzureMachine spec",
15511550
machineScope: MachineScope{
15521551
AzureMachine: &infrav1.AzureMachine{
15531552
ObjectMeta: metav1.ObjectMeta{
@@ -1566,7 +1565,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15661565
expectedErr: "",
15671566
},
15681567
{
1569-
name: "if no image is specified and os specified is windows with version below 1.22, returns windows dockershim image",
1568+
name: "if no image is specified and os specified is windows, returns windows containerd image",
15701569
machineScope: MachineScope{
15711570
Machine: &clusterv1.Machine{
15721571
ObjectMeta: metav1.ObjectMeta{
@@ -1589,42 +1588,13 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15891588
ClusterScoper: clusterMock,
15901589
},
15911590
want: func() *infrav1.Image {
1592-
image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.20.1", "dockershim", "")
1591+
image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.20.1", "containerd", "")
15931592
return image
15941593
}(),
15951594
expectedErr: "",
15961595
},
15971596
{
1598-
name: "if no image is specified and os specified is windows with version is 1.22+ with no annotation, returns windows containerd image",
1599-
machineScope: MachineScope{
1600-
Machine: &clusterv1.Machine{
1601-
ObjectMeta: metav1.ObjectMeta{
1602-
Name: "machine-name",
1603-
},
1604-
Spec: clusterv1.MachineSpec{
1605-
Version: ptr.To("1.22.1"),
1606-
},
1607-
},
1608-
AzureMachine: &infrav1.AzureMachine{
1609-
ObjectMeta: metav1.ObjectMeta{
1610-
Name: "machine-name",
1611-
},
1612-
Spec: infrav1.AzureMachineSpec{
1613-
OSDisk: infrav1.OSDisk{
1614-
OSType: azure.WindowsOS,
1615-
},
1616-
},
1617-
},
1618-
ClusterScoper: clusterMock,
1619-
},
1620-
want: func() *infrav1.Image {
1621-
image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.22.1", "containerd", "")
1622-
return image
1623-
}(),
1624-
expectedErr: "",
1625-
},
1626-
{
1627-
name: "if no image is specified and os specified is windows with version is 1.22+ with annotation dockershim, returns windows dockershim image",
1597+
name: "if no image is specified and os specified is windows with annotation dockershim, returns error",
16281598
machineScope: MachineScope{
16291599
Machine: &clusterv1.Machine{
16301600
ObjectMeta: metav1.ObjectMeta{
@@ -1653,71 +1623,10 @@ func TestMachineScope_GetVMImage(t *testing.T) {
16531623
image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.22.1", "dockershim", "")
16541624
return image
16551625
}(),
1656-
expectedErr: "",
1657-
},
1658-
{
1659-
name: "if no image is specified and os specified is windows with version is less and 1.22 with annotation dockershim, returns windows dockershim image",
1660-
machineScope: MachineScope{
1661-
Machine: &clusterv1.Machine{
1662-
ObjectMeta: metav1.ObjectMeta{
1663-
Name: "machine-name",
1664-
},
1665-
Spec: clusterv1.MachineSpec{
1666-
Version: ptr.To("1.21.1"),
1667-
},
1668-
},
1669-
AzureMachine: &infrav1.AzureMachine{
1670-
ObjectMeta: metav1.ObjectMeta{
1671-
Name: "machine-name",
1672-
Annotations: map[string]string{
1673-
"runtime": "dockershim",
1674-
},
1675-
},
1676-
Spec: infrav1.AzureMachineSpec{
1677-
OSDisk: infrav1.OSDisk{
1678-
OSType: azure.WindowsOS,
1679-
},
1680-
},
1681-
},
1682-
ClusterScoper: clusterMock,
1683-
},
1684-
want: func() *infrav1.Image {
1685-
image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.21.1", "dockershim", "")
1686-
return image
1687-
}(),
1688-
expectedErr: "",
1689-
},
1690-
{
1691-
name: "if no image is specified and os specified is windows with version is less and 1.22 with annotation containerd, returns error",
1692-
machineScope: MachineScope{
1693-
Machine: &clusterv1.Machine{
1694-
ObjectMeta: metav1.ObjectMeta{
1695-
Name: "machine-name",
1696-
},
1697-
Spec: clusterv1.MachineSpec{
1698-
Version: ptr.To("1.21.1"),
1699-
},
1700-
},
1701-
AzureMachine: &infrav1.AzureMachine{
1702-
ObjectMeta: metav1.ObjectMeta{
1703-
Name: "machine-name",
1704-
Annotations: map[string]string{
1705-
"runtime": "containerd",
1706-
},
1707-
},
1708-
Spec: infrav1.AzureMachineSpec{
1709-
OSDisk: infrav1.OSDisk{
1710-
OSType: azure.WindowsOS,
1711-
},
1712-
},
1713-
},
1714-
ClusterScoper: clusterMock,
1715-
},
1716-
want: nil,
1717-
expectedErr: "containerd image only supported in 1.22+",
1626+
expectedErr: "unsupported runtime dockershim",
17181627
},
17191628
{
1720-
name: "if no image is specified and os specified is windows with windowsServerVersion annotation set to 2019, retrurns 2019 image",
1629+
name: "if no image is specified and os specified is windows with windowsServerVersion annotation set to 2019, returns error",
17211630
machineScope: MachineScope{
17221631
Machine: &clusterv1.Machine{
17231632
ObjectMeta: metav1.ObjectMeta{
@@ -1799,7 +1708,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
17991708
ClusterScoper: clusterMock,
18001709
},
18011710
want: func() *infrav1.Image {
1802-
image, _ := svc.GetDefaultUbuntuImage(context.TODO(), "", "1.20.1")
1711+
image, _ := svc.GetDefaultLinuxImage(context.TODO(), "", "1.20.1")
18031712
return image
18041713
}(),
18051714
expectedErr: "",

azure/scope/machinepool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ func (m *MachinePoolScope) GetVMImage(ctx context.Context) (*infrav1.Image, erro
800800
log.V(4).Info("No image specified for machine, using default Windows Image", "machine", m.MachinePool.GetName(), "runtime", runtime, "windowsServerVersion", windowsServerVersion)
801801
defaultImage, err = svc.GetDefaultWindowsImage(ctx, m.Location(), ptr.Deref(m.MachinePool.Spec.Template.Spec.Version, ""), runtime, windowsServerVersion)
802802
} else {
803-
defaultImage, err = svc.GetDefaultUbuntuImage(ctx, m.Location(), ptr.Deref(m.MachinePool.Spec.Template.Spec.Version, ""))
803+
defaultImage, err = svc.GetDefaultLinuxImage(ctx, m.Location(), ptr.Deref(m.MachinePool.Spec.Template.Spec.Version, ""))
804804
}
805805

806806
if err != nil {

azure/scope/machinepool_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,10 @@ func TestMachinePoolScope_GetVMImage(t *testing.T) {
425425
Verify: func(g *WithT, amp *infrav1exp.AzureMachinePool, vmImage *infrav1.Image, err error) {
426426
g.Expect(err).NotTo(HaveOccurred())
427427
image := &infrav1.Image{
428-
Marketplace: &infrav1.AzureMarketplaceImage{
429-
ImagePlan: infrav1.ImagePlan{
430-
Publisher: "cncf-upstream",
431-
Offer: "capi",
432-
SKU: "k8s-1dot19dot11-ubuntu-1804",
433-
},
434-
Version: "latest",
435-
ThirdPartyImage: false,
428+
ComputeGallery: &infrav1.AzureComputeGalleryImage{
429+
Gallery: "ClusterAPI-f72ceb4f-5159-4c26-a0fe-2ea738f0d019",
430+
Name: "capi-ubun2-2404",
431+
Version: "1.19.11",
436432
},
437433
}
438434
g.Expect(vmImage).To(Equal(image))

0 commit comments

Comments
 (0)