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

Azure: Add self managed provisioner for e2e test #1447

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
12 changes: 11 additions & 1 deletion test/provisioner/provision_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func NewAzureCloudProvisioner(properties map[string]string) (CloudProvisioner, e
return nil, err
}

if AzureProps.IsSelfManaged {
return &AzureSelfManagedClusterProvisioner{}, nil
}

return &AzureCloudProvisioner{}, nil
}

Expand All @@ -176,6 +180,7 @@ func (p *AzureCloudProvisioner) DeleteVPC(ctx context.Context, cfg *envconf.Conf
func createFederatedIdentityCredential(aksOIDCIssuer string) error {
namespace := "confidential-containers-system"
serviceAccountName := "cloud-api-adaptor"
log.Infof("Successfully created federated identity credential %q in resource group %q", AzureProps.federatedIdentityCredentialName, AzureProps.ResourceGroupName)

if _, err := AzureProps.FederatedIdentityCredentialsClient.CreateOrUpdate(
context.Background(),
Expand Down Expand Up @@ -348,7 +353,7 @@ func (p *AzureCloudProvisioner) DeleteCluster(ctx context.Context, cfg *envconf.
return nil
}

func (p *AzureCloudProvisioner) GetProperties(ctx context.Context, cfg *envconf.Config) map[string]string {
func getPropertiesImpl() map[string]string {
props := map[string]string{
"CLOUD_PROVIDER": "azure",
"AZURE_SUBSCRIPTION_ID": AzureProps.SubscriptionID,
Expand All @@ -366,6 +371,11 @@ func (p *AzureCloudProvisioner) GetProperties(ctx context.Context, cfg *envconf.
return props
}

func (p *AzureCloudProvisioner) GetProperties(ctx context.Context, cfg *envconf.Config) map[string]string {
log.Trace("GetProperties()")
return getPropertiesImpl()
}

func (p *AzureCloudProvisioner) UploadPodvm(imagePath string, ctx context.Context, cfg *envconf.Config) error {
log.Trace("UploadPodvm()")
log.Trace("Image is uploaded via packer in case of azure")
Expand Down
1 change: 1 addition & 0 deletions test/provisioner/provision_azure.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ AZURE_IMAGE_ID=""
SSH_USERNAME=""
AZURE_CLI_AUTH="false"
IS_CI_MANAGED_CLUSTER="false"
IS_SELF_MANAGED_CLUSTER="false"
7 changes: 7 additions & 0 deletions test/provisioner/provision_azure_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type AzureProperties struct {
ManagedIdentityName string
IsCIManaged bool
CaaImage string
IsSelfManaged bool

InstanceSize string
NodeName string
Expand Down Expand Up @@ -71,6 +72,12 @@ func initAzureProperties(properties map[string]string) error {
AzureProps.IsCIManaged = true
}

selfManagedStr := properties["IS_SELF_MANAGED_CLUSTER"]
AzureProps.IsSelfManaged = false
if strings.EqualFold(selfManagedStr, "yes") || strings.EqualFold(selfManagedStr, "true") {
AzureProps.IsSelfManaged = true
}

if AzureProps.SubscriptionID == "" {
return errors.New("AZURE_SUBSCRIPTION_ID was not set.")
}
Expand Down
40 changes: 40 additions & 0 deletions test/provisioner/provision_azure_self_mgr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//go:build azure

// (C) Copyright Confidential Containers Contributors
// SPDX-License-Identifier: Apache-2.0

package provisioner

import (
"context"

"sigs.k8s.io/e2e-framework/pkg/envconf"
)

// AzureSelfManagedClusterProvisioner implements the CloudProvisioner interface for self-managed k8s cluster in azure cloud.
type AzureSelfManagedClusterProvisioner struct {
}

func (p *AzureSelfManagedClusterProvisioner) CreateCluster(ctx context.Context, cfg *envconf.Config) error {
return nil
}

func (p *AzureSelfManagedClusterProvisioner) CreateVPC(ctx context.Context, cfg *envconf.Config) error {
return createResourceImpl()
}

func (p *AzureSelfManagedClusterProvisioner) DeleteCluster(ctx context.Context, cfg *envconf.Config) error {
return nil
}

func (p *AzureSelfManagedClusterProvisioner) DeleteVPC(ctx context.Context, cfg *envconf.Config) error {
return deleteResourceImpl()
}

func (p *AzureSelfManagedClusterProvisioner) UploadPodvm(imagePath string, ctx context.Context, cfg *envconf.Config) error {
return nil
}

func (p *AzureSelfManagedClusterProvisioner) GetProperties(ctx context.Context, cfg *envconf.Config) map[string]string {
return getPropertiesImpl()
}
Loading