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

Provisioner: Add support to deploy kbs #1518

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
2 changes: 1 addition & 1 deletion install/overlays/azure/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ configMapGenerator:
# /subscriptions/<AZURE_SUBSCRIPTION_ID>/resourceGroups/<AZURE_RESOURCE_GROUP>/providers/Microsoft.Compute/images/<AZURE_IMAGE>
- AZURE_IMAGE_ID="" #set
- SSH_USERNAME="" #set peer pod vm admin user name
- AA_KBC_PARAMS="" #set KBC params for podvm
#- DISABLECVM="" # Uncomment it if you want a generic VM
#- PAUSE_IMAGE="" # Uncomment and set if you want to use a specific pause image
#- VXLAN_PORT="" # Uncomment and set if you want to use a specific vxlan port. Defaults to 4789
#- AZURE_INSTANCE_SIZES="" # comma separated
#- TAGS="" # Uncomment and add key1=value1,key2=value2 etc if you want to use specific tags for podvm
#- AA_KBC_PARAMS="" # Uncomment and set if you want to set KBC params for podvm
#- FORWARDER_PORT="" # Uncomment and set if you want to use a specific port for agent-protocol-forwarder. Defaults to 15150
##TLS_SETTINGS
#- CACERT_FILE="/etc/certificates/ca.crt" # for TLS
Expand Down
50 changes: 46 additions & 4 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package e2e

import (
"context"
"fmt"
"os"
"testing"

Expand All @@ -17,9 +18,10 @@ import (
)

var (
testEnv env.Environment
cloudProvider string
provisioner pv.CloudProvisioner
testEnv env.Environment
cloudProvider string
provisioner pv.CloudProvisioner
keyBrokerService *pv.KeyBrokerService
)

func init() {
Expand Down Expand Up @@ -93,6 +95,12 @@ func TestMain(m *testing.M) {
log.Fatal(err)
}

// The DEPLOY_KBS is exported then provisioner will install kbs before installing CAA
shouldDeployKbs := true
if os.Getenv("DEPLOY_KBS") != "yes" {
shouldDeployKbs = false
}

if !shouldProvisionCluster {
// Look for a suitable kubeconfig file in the sequence: --kubeconfig flag,
// or KUBECONFIG variable, or $HOME/.kube/config.
Expand All @@ -109,6 +117,12 @@ func TestMain(m *testing.M) {
log.Info("Do setup")
var err error

// Get properties
props := provisioner.GetProperties(ctx, cfg)
if props["KBS_IMAGE"] == "" || props["KBS_IMAGE_TAG"] == "" {
return ctx, fmt.Errorf("kbs image not provided")
}

if shouldProvisionCluster {
log.Info("Cluster provisioning")
if err = provisioner.CreateVPC(ctx, cfg); err != nil {
Expand All @@ -120,6 +134,25 @@ func TestMain(m *testing.M) {
}
}

var kbsparams string
if shouldDeployKbs {
log.Info("Deploying kbs")
if keyBrokerService, err = pv.NewKeyBrokerService(props["CLUSTER_NAME"]); err != nil {
return ctx, err
}

if err = keyBrokerService.Deploy(ctx, cfg, props); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deployment failed for me as:

✗ ./caa-provisioner-cli -action=provision
INFO[0000] Creating VPC...
...
KBS Service IP: 10.0.241.140
INFO[0138] KBS PARAMS: "cc_kbc::http:10.0.241.140:8080":
FATA[0139] loading KV pairs: env source files: [service-principal.env]: evalsymlink failure on '/Users/suraj/temp/2024-02-Feb-20-19-09-13/cloud-api-adaptor/install/overlays/azure/service-principal.env' : lstat /Users/suraj/temp/2024-02-Feb-20-19-09-13/cloud-api-adaptor/install/overlays/azure/service-principal.env: no such file or directory

I had to run ✗ touch /Users/suraj/temp/2024-02-Feb-20-19-09-13/cloud-api-adaptor/install/overlays/azure/service-principal.env and ✗ touch /Users/suraj/temp/2024-02-Feb-20-19-09-13/cloud-api-adaptor/install/overlays/azure/id_rsa.pub to move further.

return ctx, err
}
var kbsPodIP string
if kbsPodIP, err = keyBrokerService.GetKbsPodIP(ctx, cfg); err != nil {
return ctx, err
}

kbsparams = "cc_kbc::http://" + kbsPodIP + ":8080"
log.Infof("KBS PARAMS%s:", kbsparams)
}

if podvmImage != "" {
log.Info("Podvm uploading")
if err = provisioner.UploadPodvm(podvmImage, ctx, cfg); err != nil {
Expand All @@ -133,8 +166,11 @@ func TestMain(m *testing.M) {
if cloudAPIAdaptor, err = pv.NewCloudAPIAdaptor(cloudProvider, relativeInstallDirectory); err != nil {
return ctx, err
}

props = provisioner.GetProperties(ctx, cfg)
props["AA_KBC_PARAMS"] = kbsparams
log.Info("Deploy the Cloud API Adaptor")
if err = cloudAPIAdaptor.Deploy(ctx, cfg, provisioner.GetProperties(ctx, cfg)); err != nil {
if err = cloudAPIAdaptor.Deploy(ctx, cfg, props); err != nil {
return ctx, err
}
}
Expand Down Expand Up @@ -173,6 +209,12 @@ func TestMain(m *testing.M) {
}
}

if shouldDeployKbs {
if err = keyBrokerService.Delete(ctx, cfg); err != nil {
return ctx, err
}
}

return ctx, nil
})

Expand Down
2 changes: 2 additions & 0 deletions test/provisioner/azure/provision_azure.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ SSH_USERNAME=""
AZURE_CLI_AUTH="false"
IS_CI_MANAGED_CLUSTER="false"
IS_SELF_MANAGED_CLUSTER="false"
KBS_IMAGE="${KBS_IMAGE}"
KBS_IMAGE_TAG="${KBS_IMAGE_TAG}"
4 changes: 3 additions & 1 deletion test/provisioner/azure/provision_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ func getPropertiesImpl() map[string]string {
"AZURE_IMAGE_ID": AzureProps.ImageID,
"AZURE_SUBNET_ID": AzureProps.SubnetID,
"AZURE_INSTANCE_SIZE": AzureProps.InstanceSize,
"KBS_IMAGE": AzureProps.KbsImage,
"KBS_IMAGE_TAG": AzureProps.KbsImageTag,
}

return props
Expand All @@ -378,7 +380,7 @@ func (p *AzureCloudProvisioner) UploadPodvm(imagePath string, ctx context.Contex

func isAzureKustomizeConfigMapKey(key string) bool {
switch key {
case "CLOUD_PROVIDER", "AZURE_SUBSCRIPTION_ID", "AZURE_REGION", "AZURE_INSTANCE_SIZE", "AZURE_RESOURCE_GROUP", "AZURE_SUBNET_ID", "AZURE_IMAGE_ID", "SSH_USERNAME":
case "CLOUD_PROVIDER", "AZURE_SUBSCRIPTION_ID", "AZURE_REGION", "AZURE_INSTANCE_SIZE", "AZURE_RESOURCE_GROUP", "AZURE_SUBNET_ID", "AZURE_IMAGE_ID", "SSH_USERNAME", "AA_KBC_PARAMS":
return true
default:
return false
Expand Down
4 changes: 4 additions & 0 deletions test/provisioner/azure/provision_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type AzureProperties struct {
IsCIManaged bool
CaaImage string
IsSelfManaged bool
KbsImage string
KbsImageTag string

InstanceSize string
NodeName string
Expand Down Expand Up @@ -64,6 +66,8 @@ func initAzureProperties(properties map[string]string) error {
SshUserName: properties["SSH_USERNAME"],
ManagedIdentityName: properties["MANAGED_IDENTITY_NAME"],
CaaImage: properties["CAA_IMAGE"],
KbsImage: properties["KBS_IMAGE"],
KbsImageTag: properties["KBS_IMAGE_TAG"],
}

CIManagedStr := properties["IS_CI_MANAGED_CLUSTER"]
Expand Down
Loading
Loading