Skip to content

Commit

Permalink
Merge pull request #1710 from FabianKramm/refactor
Browse files Browse the repository at this point in the history
refactor: introduce vCluster manager
  • Loading branch information
FabianKramm authored Apr 23, 2024
2 parents 7d47e20 + 90fd3af commit 464ec88
Show file tree
Hide file tree
Showing 93 changed files with 4,131 additions and 2,288 deletions.
32 changes: 20 additions & 12 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1985,9 +1985,9 @@
},
"Platform": {
"properties": {
"apiKey": {
"$ref": "#/$defs/PlatformAPIKey",
"description": "APIKey defines how vCluster can find the api key used for the platform."
"api": {
"$ref": "#/$defs/PlatformAPI",
"description": "API defines how vCluster can contact the platform api."
},
"name": {
"type": "string",
Expand All @@ -2005,34 +2005,42 @@
"additionalProperties": false,
"type": "object"
},
"PlatformAPIKey": {
"PlatformAPI": {
"properties": {
"value": {
"accessKey": {
"type": "string",
"description": "AccessKey specifies the access key as a regular text value."
},
"host": {
"type": "string",
"description": "Value specifies the api key as a regular text value."
"description": "Host specifies the platform host to use."
},
"insecure": {
"type": "boolean",
"description": "Insecure specifies if the host uses a self-signed certificate."
},
"secretRef": {
"$ref": "#/$defs/PlatformAPIKeySecretReference",
"description": "SecretRef defines where to find the platform api key. By default vCluster will search in the following locations in this precedence:\n* platform.apiKey.value\n* environment variable called LICENSE\n* secret specified under platform.secret.name\n* secret called \"vcluster-platform-api-key\" in the vCluster namespace"
"$ref": "#/$defs/PlatformAccessKeySecretReference",
"description": "SecretRef defines where to find the platform access key and host. By default, vCluster will search in the following locations in this precedence:\n* platform.api.accessKey\n* environment variable called LICENSE\n* secret specified under platform.api.secretRef.name\n* secret called \"vcluster-platform-api-key\" in the vCluster namespace"
}
},
"additionalProperties": false,
"type": "object"
},
"PlatformAPIKeySecretReference": {
"PlatformAccessKeySecretReference": {
"properties": {
"name": {
"type": "string",
"description": "Name is the name of the secret where the platform api key is stored. This defaults to vcluster-platform-api-key if undefined."
"description": "Name is the name of the secret where the platform access key is stored. This defaults to vcluster-platform-api-key if undefined."
},
"namespace": {
"type": "string",
"description": "Namespace defines the namespace where the api key secret should be retrieved from. If this is not equal to the namespace\nwhere the vCluster instance is deployed, you need to make sure vCluster has access to this other namespace."
"description": "Namespace defines the namespace where the access key secret should be retrieved from. If this is not equal to the namespace\nwhere the vCluster instance is deployed, you need to make sure vCluster has access to this other namespace."
}
},
"additionalProperties": false,
"type": "object",
"description": "PlatformAPIKeySecretReference defines where to find the platform api key."
"description": "PlatformAccessKeySecretReference defines where to find the platform access key."
},
"PlatformOwner": {
"properties": {
Expand Down
22 changes: 13 additions & 9 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,19 +844,23 @@ experimental:

# Platform holds options for connecting to vCluster Platform.
platform:
# APIKey defines how vCluster can find the api key used for the platform.
apiKey:
# Value specifies the api key as a regular text value.
value: ""
# SecretRef defines where to find the platform api key. By default vCluster will search in the following locations in this precedence:
# * platform.apiKey.value
# API defines how vCluster can contact the platform api.
api:
# AccessKey specifies the access key as a regular text value.
accessKey: ""
# Host specifies the platform host to use.
host: ""
# Insecure specifies if the host uses a self-signed certificate.
insecure: false
# SecretRef defines where to find the platform access key and host. By default, vCluster will search in the following locations in this precedence:
# * platform.api.accessKey
# * environment variable called LICENSE
# * secret specified under platform.secret.name
# * secret specified under platform.api.secretRef.name
# * secret called "vcluster-platform-api-key" in the vCluster namespace
secretRef:
# Name is the name of the secret where the platform api key is stored. This defaults to vcluster-platform-api-key if undefined.
# Name is the name of the secret where the platform access key is stored. This defaults to vcluster-platform-api-key if undefined.
name: ""
# Namespace defines the namespace where the api key secret should be retrieved from. If this is not equal to the namespace
# Namespace defines the namespace where the access key secret should be retrieved from. If this is not equal to the namespace
# where the vCluster instance is deployed, you need to make sure vCluster has access to this other namespace.
namespace: ""

Expand Down
54 changes: 54 additions & 0 deletions cmd/vclusterctl/cmd/activate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cmd

import (
"os"

loftctlUtil "github.com/loft-sh/loftctl/v3/pkg/util"
"github.com/loft-sh/log"
platformcmd "github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/platform"
"github.com/loft-sh/vcluster/config"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/spf13/cobra"
)

func NewActivateCmd(globalFlags *flags.GlobalFlags) (*cobra.Command, error) {
cmd := &platformcmd.ImportCmd{
GlobalFlags: globalFlags,
Log: log.GetInstance(),
}

description := `########################################################
################### vcluster activate ####################
########################################################
Imports a vCluster into a vCluster platform project.
Example:
vcluster activate my-vcluster --cluster connected-cluster \
--namespace vcluster-my-vcluster --project my-project --import-name my-vcluster
#######################################################
`

importCmd := &cobra.Command{
Use: "activate" + loftctlUtil.VClusterNameOnlyUseLine,
Aliases: []string{"import"},
Short: "Imports a vCluster into a vCluster platform project",
Long: description,
Args: loftctlUtil.VClusterNameOnlyValidator,
RunE: func(cobraCmd *cobra.Command, args []string) error {
if config.ShouldCheckForProFeatures() {
cmd.Log.Warnf("In order to use a Pro feature, please contact us at https://www.vcluster.com/pro-demo or downgrade by running `vcluster upgrade --version v0.19.5`")
os.Exit(1)
}

return cmd.Run(cobraCmd.Context(), args)
},
}

importCmd.Flags().StringVar(&cmd.Manager, "manager", "", "The manager to use for managing the virtual cluster, can be either helm or platform.")

importCmd.Flags().StringVar(&cmd.ClusterName, "cluster", "", "Cluster name of the cluster the virtual cluster is running on")
importCmd.Flags().StringVar(&cmd.Project, "project", "", "The project to import the vCluster into")
importCmd.Flags().StringVar(&cmd.ImportName, "import-name", "", "The name of the vCluster under projects. If unspecified, will use the vcluster name")

return importCmd, nil
}
4 changes: 2 additions & 2 deletions cmd/vclusterctl/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"time"

"github.com/loft-sh/log"
"github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/find"
"github.com/loft-sh/vcluster/cmd/vclusterctl/flags"
"github.com/loft-sh/vcluster/pkg/cli/find"
"github.com/loft-sh/vcluster/pkg/cli/flags"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down
Loading

0 comments on commit 464ec88

Please sign in to comment.