From 215ffce7e0c4379d7bd074956db939cd32b04d25 Mon Sep 17 00:00:00 2001 From: RyanSwanson Date: Tue, 16 Jul 2024 14:01:39 -0600 Subject: [PATCH] Adds autoSleep and autoDelete to platform vcluster.yaml docs --- hack/platform/partials/main.go | 58 +++++++++++- .../config/external/platform/apiKey.mdx | 5 +- .../config/external/platform/autoDelete.mdx | 28 ++++++ .../config/external/platform/autoSleep.mdx | 88 +++++++++++++++++++ .../api/resources/vcluster-yaml/README.mdx | 4 + .../external/platform/api-key.mdx | 1 - .../external/platform/auto-delete.mdx | 8 ++ .../external/platform/auto-sleep.mdx | 8 ++ 8 files changed, 193 insertions(+), 7 deletions(-) create mode 100755 platform/api/_partials/resources/config/external/platform/autoDelete.mdx create mode 100755 platform/api/_partials/resources/config/external/platform/autoSleep.mdx create mode 100644 platform/api/resources/vcluster-yaml/external/platform/auto-delete.mdx create mode 100644 platform/api/resources/vcluster-yaml/external/platform/auto-sleep.mdx diff --git a/hack/platform/partials/main.go b/hack/platform/partials/main.go index 01678aef9..932ec1d46 100644 --- a/hack/platform/partials/main.go +++ b/hack/platform/partials/main.go @@ -15,10 +15,60 @@ import ( // Config represents the external config for vcluster.yaml to generate associated partials type Config struct { External struct { - *config.PlatformConfig `json:"platform"` + Platform struct { + // APIKey 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 external.platform.apiKey.secretName + // * secret called "vcluster-platform-api-key" in the vCluster namespace + APIKey config.PlatformAPIKey `json:"apiKey,omitempty"` + + // AutoSleep holds configuration for automatic sleep and wakeup + // +optional + AutoSleep *AutoSleep `json:"autoSleep,omitempty"` + + // AutoDelete holds configuration for automatic delete + // +optional + AutoDelete *AutoDelete `json:"autoDelete,omitempty"` + } `json:"platform"` } `json:"external"` } +type AutoSleep struct { + // AfterInactivity specifies after how many seconds of inactivity the virtual cluster should sleep + // +optional + AfterInactivity int64 `json:"afterInactivity,omitempty"` + + // Schedule specifies scheduled virtual cluster sleep in Cron format, see https://en.wikipedia.org/wiki/Cron. + // Note: timezone defined in the schedule string will be ignored. Use ".Timezone" field instead. + // +optional + Schedule string `json:"schedule,omitempty"` + + // Timezone specifies time zone used for scheduled virtual cluster operations. Defaults to UTC. + // Accepts the same format as time.LoadLocation() in Go (https://pkg.go.dev/time#LoadLocation). + // The value should be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York". + // +optional + Timezone string `json:"timezone,omitempty"` + + // AutoSleep holds configuration for automatic wakeup + // +optional + AutoWakeup *AutoWakeup `json:"autoWakeup,omitempty"` +} + +type AutoWakeup struct { + // Schedule specifies scheduled wakeup from sleep in Cron format, see https://en.wikipedia.org/wiki/Cron. + // Note: timezone defined in the schedule string will be ignored. The timezone for the autoSleep schedule will be + // used + // +optional + Schedule string `json:"schedule,omitempty"` +} + +type AutoDelete struct { + // AfterInactivity specifies after how many seconds of inactivity the virtual cluster be deleted + // +optional + AfterInactivity int64 `json:"afterInactivity,omitempty"` +} + func main() { _ = os.RemoveAll(util.BasePath) @@ -904,7 +954,11 @@ spec: util.DefaultRequire = false - paths := []string{"external/platform/apiKey"} + paths := []string{ + "external/platform/apiKey", + "external/platform/autoSleep", + "external/platform/autoDelete", + } for _, p := range paths { util.GenerateFromPath(util.GenerateSchema(&Config{}), util.BasePath+"/config", p) } diff --git a/platform/api/_partials/resources/config/external/platform/apiKey.mdx b/platform/api/_partials/resources/config/external/platform/apiKey.mdx index b7d2da6b5..b3090cb6f 100755 --- a/platform/api/_partials/resources/config/external/platform/apiKey.mdx +++ b/platform/api/_partials/resources/config/external/platform/apiKey.mdx @@ -4,10 +4,7 @@ ## `apiKey` required object pro {#apiKey} -APIKey defines where to find the platform access key and host. By default, vCluster will search in the following locations in this precedence: -* environment variable called LICENSE -* secret specified under external.platform.apiKey.secretName -* secret called "vcluster-platform-api-key" in the vCluster namespace + diff --git a/platform/api/_partials/resources/config/external/platform/autoDelete.mdx b/platform/api/_partials/resources/config/external/platform/autoDelete.mdx new file mode 100755 index 000000000..942749f30 --- /dev/null +++ b/platform/api/_partials/resources/config/external/platform/autoDelete.mdx @@ -0,0 +1,28 @@ + +
+ + +## `autoDelete` required object pro {#autoDelete} + + + + + + + + +
+ + +### `afterInactivity` required integer pro {#autoDelete-afterInactivity} + + + + + + + +
+ + +
diff --git a/platform/api/_partials/resources/config/external/platform/autoSleep.mdx b/platform/api/_partials/resources/config/external/platform/autoSleep.mdx new file mode 100755 index 000000000..26876c6b7 --- /dev/null +++ b/platform/api/_partials/resources/config/external/platform/autoSleep.mdx @@ -0,0 +1,88 @@ + +
+ + +## `autoSleep` required object pro {#autoSleep} + + + + + + + + +
+ + +### `afterInactivity` required integer pro {#autoSleep-afterInactivity} + + + + + + + +
+ + + +
+ + +### `schedule` required string pro {#autoSleep-schedule} + + + + + + + +
+ + + +
+ + +### `timezone` required string pro {#autoSleep-timezone} + + + + + + + +
+ + + +
+ + +### `autoWakeup` required object pro {#autoSleep-autoWakeup} + + + + + + + + +
+ + +#### `schedule` required string pro {#autoSleep-autoWakeup-schedule} + + + + + + + +
+ + +
+ + +
diff --git a/platform/api/resources/vcluster-yaml/README.mdx b/platform/api/resources/vcluster-yaml/README.mdx index f786f01ea..c1ce18ca3 100644 --- a/platform/api/resources/vcluster-yaml/README.mdx +++ b/platform/api/resources/vcluster-yaml/README.mdx @@ -4,6 +4,8 @@ sidebar_label: vcluster.yaml --- import ApiKey from '@site/platform/api/_partials/resources/config/external/platform/apiKey.mdx' +import AutoSleep from '@site/platform/api/_partials/resources/config/external/platform/autoSleep.mdx' +import AutoDelete from '@site/platform/api/_partials/resources/config/external/platform/autoDelete.mdx' ## Create a virtual cluster with a config file @@ -14,4 +16,6 @@ please see [vcluster.yaml](/docs/vcluster/configure/vcluster-yaml). + + diff --git a/platform/api/resources/vcluster-yaml/external/platform/api-key.mdx b/platform/api/resources/vcluster-yaml/external/platform/api-key.mdx index 19fd118e7..98f2b94ad 100644 --- a/platform/api/resources/vcluster-yaml/external/platform/api-key.mdx +++ b/platform/api/resources/vcluster-yaml/external/platform/api-key.mdx @@ -1,7 +1,6 @@ --- title: apiKey sidebar_label: apiKey -sidebar_position: 12 --- import ApiKey from '@site/platform/api/_partials/resources/config/external/platform/apiKey.mdx' diff --git a/platform/api/resources/vcluster-yaml/external/platform/auto-delete.mdx b/platform/api/resources/vcluster-yaml/external/platform/auto-delete.mdx new file mode 100644 index 000000000..781c83370 --- /dev/null +++ b/platform/api/resources/vcluster-yaml/external/platform/auto-delete.mdx @@ -0,0 +1,8 @@ +--- +title: autoDelete +sidebar_label: autoDelete +--- + +import AutoDelete from '@site/platform/api/_partials/resources/config/external/platform/autoDelete.mdx' + + diff --git a/platform/api/resources/vcluster-yaml/external/platform/auto-sleep.mdx b/platform/api/resources/vcluster-yaml/external/platform/auto-sleep.mdx new file mode 100644 index 000000000..02ab2fe3b --- /dev/null +++ b/platform/api/resources/vcluster-yaml/external/platform/auto-sleep.mdx @@ -0,0 +1,8 @@ +--- +title: autoSleep +sidebar_label: autoSleep +--- + +import AutoSleep from '@site/platform/api/_partials/resources/config/external/platform/autoSleep.mdx' + +