Skip to content

Commit

Permalink
azure-provisioner: Support for custom CAA images
Browse files Browse the repository at this point in the history
Now a user can provide a custom CAA image to be deployed for the Azure
test runs using the property: `CAA_IMAGE`.

Fixes #1293

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
  • Loading branch information
surajssd committed Aug 3, 2023
1 parent 22b79cc commit c7be501
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
Expand Down
36 changes: 34 additions & 2 deletions test/provisioner/provision_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import (
"strings"
"time"

"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/e2e-framework/pkg/envconf"

"github.com/containerd/containerd/reference"
log "github.com/sirupsen/logrus"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/Azure/go-autorest/autorest"
log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/wait"
)

func init() {
Expand Down Expand Up @@ -431,6 +433,36 @@ func (lio *AzureInstallOverlay) Delete(ctx context.Context, cfg *envconf.Config)

func (lio *AzureInstallOverlay) Edit(ctx context.Context, cfg *envconf.Config, properties map[string]string) error {
var err error

// If a custom image is defined then update it in the kustomization file.
if AzureProps.CaaImage != "" {
spec, err := reference.Parse(AzureProps.CaaImage)
if err != nil {
return fmt.Errorf("parsing image: %w", err)
}

log.Infof("Updating CAA image with %q", spec.Locator)
if err = lio.overlay.SetKustomizeImage("cloud-api-adaptor", "newName", spec.Locator); err != nil {
return err
}

tag, digest := reference.SplitObject(spec.Object)

if tag != "" && strings.HasSuffix(tag, "@") {
tag = tag[:len(tag)-1]
}

log.Infof("Updating CAA image tag with %q", tag)
if err = lio.overlay.SetKustomizeImage("cloud-api-adaptor", "newTag", tag); err != nil {
return err
}

log.Infof("Updating CAA image digest with %q", digest)
if err = lio.overlay.SetKustomizeImage("cloud-api-adaptor", "digest", digest.String()); err != nil {
return err
}
}

for k, v := range properties {
// configMapGenerator
if isAzureKustomizeConfigMapKey(k) {
Expand Down
1 change: 1 addition & 0 deletions test/provisioner/provision_azure_cli_auth.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ AZURE_IMAGE_ID=""
SSH_USERNAME=""
AZURE_CLI_AUTH="true"
IS_CI_MANAGED_CLUSTER="true"
CAA_IMAGE="quay.io/confidential-containers/cloud-api-adaptor:latest"
2 changes: 2 additions & 0 deletions test/provisioner/provision_azure_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type AzureProperties struct {
ManagedIdentityName string
IsAzCliAuth bool
IsCIManaged bool
CaaImage string

InstanceSize string
NodeName string
Expand Down Expand Up @@ -66,6 +67,7 @@ func initAzureProperties(properties map[string]string) error {
SubnetID: properties["AZURE_SUBNET_ID"],
SshUserName: properties["SSH_USERNAME"],
ManagedIdentityName: properties["MANAGED_IDENTITY_NAME"],
CaaImage: properties["CAA_IMAGE"],
}

CIManagedStr := properties["IS_CI_MANAGED_CLUSTER"]
Expand Down

0 comments on commit c7be501

Please sign in to comment.