diff --git a/pkg/capi/edit/ClusterConfig.vue b/pkg/capi/edit/ClusterConfig.vue new file mode 100644 index 0000000..d42390b --- /dev/null +++ b/pkg/capi/edit/ClusterConfig.vue @@ -0,0 +1,425 @@ + + diff --git a/pkg/capi/edit/NetworkSection.vue b/pkg/capi/edit/NetworkSection.vue new file mode 100644 index 0000000..337b0a4 --- /dev/null +++ b/pkg/capi/edit/NetworkSection.vue @@ -0,0 +1,87 @@ + + diff --git a/pkg/capi/edit/WorkerItem.vue b/pkg/capi/edit/WorkerItem.vue new file mode 100644 index 0000000..38d8e04 --- /dev/null +++ b/pkg/capi/edit/WorkerItem.vue @@ -0,0 +1,253 @@ + + diff --git a/pkg/capi/edit/cluster.x-k8s.io.cluster.vue b/pkg/capi/edit/cluster.x-k8s.io.cluster.vue index ed3158f..4eabd08 100644 --- a/pkg/capi/edit/cluster.x-k8s.io.cluster.vue +++ b/pkg/capi/edit/cluster.x-k8s.io.cluster.vue @@ -1,115 +1,171 @@ diff --git a/pkg/capi/index.ts b/pkg/capi/index.ts index bac72d4..34b60d5 100644 --- a/pkg/capi/index.ts +++ b/pkg/capi/index.ts @@ -38,36 +38,36 @@ export default function(plugin: IPlugin): void { ); // add enable auto-import action to namespace table - plugin.addAction(ActionLocation.TABLE, - { path: [{ urlPath: '/c/local/explorer/projectsnamespaces', exact: true }, { urlPath: 'cluster.x-k8s.io.cluster', endsWith: true }] }, - { - labelKey: 'capi.autoImport.enableAction', - icon: 'icon-plus', - enabled(target: any) { - return target.metadata.labels[LABELS.AUTO_IMPORT] !== 'true'; - }, - invoke(opts, resources = []) { - resources.forEach((ns) => { - toggleAutoImport(ns); - }); - } - }); + // plugin.addAction(ActionLocation.TABLE, + // { path: [{ urlPath: '/c/local/explorer/projectsnamespaces', exact: true }, { urlPath: 'cluster.x-k8s.io.cluster', endsWith: true }] }, + // { + // labelKey: 'capi.autoImport.enableAction', + // icon: 'icon-plus', + // enabled(target: any) { + // return target.metadata.labels[LABELS.AUTO_IMPORT] !== 'true'; + // }, + // invoke(opts, resources = []) { + // resources.forEach((ns) => { + // toggleAutoImport(ns); + // }); + // } + // }); // add disable auto-import action to namespace table - plugin.addAction(ActionLocation.TABLE, - { path: [{ urlPath: '/c/local/explorer/projectsnamespaces', exact: true }, { urlPath: 'cluster.x-k8s.io.cluster', endsWith: true }] }, - { - labelKey: 'capi.autoImport.disableAction', - icon: 'icon-minus', - enabled(target: any) { - return target.metadata.labels[LABELS.AUTO_IMPORT] === 'true'; - }, - invoke(opts, resources = []) { - resources.forEach((ns) => { - toggleAutoImport(ns); - }); - } - }); + // plugin.addAction(ActionLocation.TABLE, + // { path: [{ urlPath: '/c/local/explorer/projectsnamespaces', exact: true }, { urlPath: 'cluster.x-k8s.io.cluster', endsWith: true }] }, + // { + // labelKey: 'capi.autoImport.disableAction', + // icon: 'icon-minus', + // enabled(target: any) { + // return target.metadata.labels[LABELS.AUTO_IMPORT] === 'true'; + // }, + // invoke(opts, resources = []) { + // resources.forEach((ns) => { + // toggleAutoImport(ns); + // }); + // } + // }); // add column to namespace table plugin.addTableColumn( diff --git a/pkg/capi/l10n/en-us.yaml b/pkg/capi/l10n/en-us.yaml index ef4d22e..ae82485 100644 --- a/pkg/capi/l10n/en-us.yaml +++ b/pkg/capi/l10n/en-us.yaml @@ -12,6 +12,48 @@ capi: disableAction: Disable CAPI Auto-Import warnings: embeddedFeatureFlag: "It looks like the Rancher-managed cluster API feature is disabled. To provision and manage RKE2 clusters you must either enable the embedded-cluster-api feature flag or install the Rancher Turtles extension." + cluster: + steps: + basics: + title: Basics + label: Basics + subtext: + description: '' + configuration: + title: Configuration + label: Configuration + subtext: + description: '' + secret: + reuse: Use existing credential + create: Create new credential + controlPlane: + title: Control Plane Options + provisioner: Type + providerConfig: + title: Infrastructure + clusterClass: + title: Cluster Class + label: Cluster Class + description: Cluster Class Description + variables: + title: Variables + version: + title: Kubernetes Version + networking: + title: Networking + apiServerPort: API Server Port + serviceDomain: Service Domain + pods: Pod CIDR Blocks + services: Service VIP CIDR Blocks + workers: + title: Workers + class: Class + name: Name + machineDeployments: + title: Machine Deployments + machinePools: + title: Machine Pools nav: group: @@ -45,3 +87,4 @@ validation: minItems: '"{key}" must contain at least {minItems} items.' pattern: '"{key}" must match the pattern {pattern}.' uniqueItems: '"{key}" may not contain duplicate elements.' + version: Version format must match format for this provisioner. diff --git a/pkg/capi/types/capi.ts b/pkg/capi/types/capi.ts index f75f6fe..7ea379c 100644 --- a/pkg/capi/types/capi.ts +++ b/pkg/capi/types/capi.ts @@ -8,3 +8,60 @@ export const CAPI = { CLUSTER_CLASS: 'cluster.x-k8s.io.clusterclass', PROVIDER: 'operator.cluster.x-k8s.io.infrastructureprovider', }; + +// Includes bootrstap providers, control plane providers, and add-on providers: +// BOOTSTRAP_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'ocne', 'kubekey-k3s', 'rke2']; +// CP_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'nested', 'ocne', 'kubekey-k3s', 'kamaji', 'rke2']; +// ADD_ON_PROVIDERS = ['helm']; +export const NON_INFRASTRUCTURE_PROVIDERS = ['kubeadm', 'talos', 'microk8s', 'nested', 'ocne', 'kubekey-k3s', 'kamaji', 'rke2', 'helm']; + +export const CP_VERSIONS = { + 'kubekey-k3s': ['k3s1', 'k3s2'], + rke2: ['rke2r1', 'rke2r2'] +}; + +export const CREDENTIALS_UPDATE_REQUIRED = ['aks']; +export const CREDENTIALS_NOT_REQUIRED = ['docker']; +interface Worker { + name: String, + class: String +} + +export interface CAPIClusterTopology { + version: String, + class: String, + workers: { + machineDeployments: Worker[], + machinePools: Worker[] + } +} + +export interface CAPIClusterNetwork { + apiServerPort?: Number, + pods?: { + cidrBlocks: String[] + }, + serviceDomain?: String, + services?: { + cidrBlocks: String[] + }, +} + +export interface ClusterClass { + metadata: { + name: String, + annotations: Object + }, + spec: { + infrastructure: Object, + workers: Object, + controlPlane: Object + } +} + +export interface InfrastructureProvider { + metadata: { + name: String, + annotations: Object + } +} diff --git a/pkg/capi/util/validators.ts b/pkg/capi/util/validators.ts index b932b8b..bb79b32 100644 --- a/pkg/capi/util/validators.ts +++ b/pkg/capi/util/validators.ts @@ -1,6 +1,7 @@ import { Validator, ValidationOptions } from '@shell/utils/validators/formRules'; import { Translation } from '@shell/types/t'; import isEmpty from 'lodash/isEmpty'; +import { CP_VERSIONS } from '@pkg/capi/types/capi'; // const stringFormats = { // // this is a mongodb id - requires library to validate? @@ -120,3 +121,21 @@ export const openAPIV3SchemaValidators = function(t: Translation, { key = 'Value }; export const isDefined = (val: any) => (val || val === false) && !isEmpty(val); +export const versionTest = function(t: Translation, type: String): RegExp { + let ending = ''; + + if (CP_VERSIONS[type]) { + ending = `\\+(${ CP_VERSIONS[type].join('|') })`; + } + + return new RegExp(`^v(\\d+.){2}\\d+${ ending }$`); +}; + +export const versionValidator = function(t: Translation, type: String): Validator[] { + const out = [] as any[]; + const test = versionTest(t, type); + + out.push((val: String) => val && !val.match(test) ? t('validation.version') : undefined); + + return out; +};