diff --git a/libvirt/kcli_cluster.sh b/libvirt/kcli_cluster.sh index 3ceea138f..6791f2dd9 100755 --- a/libvirt/kcli_cluster.sh +++ b/libvirt/kcli_cluster.sh @@ -52,7 +52,7 @@ create () { -P disk_size="$CLUSTER_DISK_SIZE" \ "$CLUSTER_NAME" - export KUBECONFIG=$HOME/.kcli/clusters/peer-pods/auth/kubeconfig + export KUBECONFIG=$HOME/.kcli/clusters/$CLUSTER_NAME/auth/kubeconfig local cmd="kubectl get nodes | grep '\.*worker'" echo "Wait at least one worker be Ready" diff --git a/test/e2e/README.md b/test/e2e/README.md index 7c5c130cd..7f456e147 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -63,6 +63,7 @@ Use the properties on the table below for Libvirt: |libvirt_ssh_key_file|Path to SSH private key|| |pause_image|k8s pause image|| |vxlan_port| VXLAN port number|| +|cluster_name|Cluster Name| "peer-pods"| # Adding support for a new cloud provider diff --git a/test/provisioner/provision_libvirt.go b/test/provisioner/provision_libvirt.go index 777644b24..0e0331691 100644 --- a/test/provisioner/provision_libvirt.go +++ b/test/provisioner/provision_libvirt.go @@ -32,6 +32,7 @@ type LibvirtProvisioner struct { uri string // Libvirt URI wd string // libvirt's directory path on this repository volumeName string // Podvm volume name + clusterName string // Cluster name } // LibvirtInstallOverlay implements the InstallOverlay interface @@ -76,6 +77,11 @@ func NewLibvirtProvisioner(properties map[string]string) (CloudProvisioner, erro return nil, err } + clusterName := "peer-pods" + if properties["cluster_name"] != "" { + clusterName = properties["cluster_name"] + } + // TODO: Check network and storage are not nil? return &LibvirtProvisioner{ conn: conn, @@ -85,22 +91,27 @@ func NewLibvirtProvisioner(properties map[string]string) (CloudProvisioner, erro uri: uri, wd: wd, volumeName: vol_name, + clusterName: clusterName, }, nil } func (l *LibvirtProvisioner) CreateCluster(ctx context.Context, cfg *envconf.Config) error { + cmd := exec.Command("/bin/bash", "-c", "./kcli_cluster.sh create") cmd.Dir = l.wd cmd.Stdout = os.Stdout // TODO: better handle stderr. Messages getting out of order. cmd.Stderr = os.Stderr + cmd.Env = os.Environ() + cmd.Env = append(cmd.Env, "CLUSTER_NAME="+l.clusterName) + cmd.Env = append(cmd.Env, "LIBVIRT_NETWORK="+l.network) + cmd.Env = append(cmd.Env, "LIBVIRT_POOL="+l.storage) err := cmd.Run() if err != nil { return err } - // TODO: cluster name should be customized. - clusterName := "peer-pods" + clusterName := l.clusterName home, _ := os.UserHomeDir() kubeconfig := path.Join(home, ".kcli/clusters", clusterName, "auth/kubeconfig") cfg.WithKubeconfigFile(kubeconfig)