diff --git a/content/en/docs/Storage/external.md b/content/en/docs/Storage/external.md new file mode 100644 index 0000000..38a37f1 --- /dev/null +++ b/content/en/docs/Storage/external.md @@ -0,0 +1,48 @@ +--- +title: External Storage +categories: [Storage Provider] +description: What does your user need to know to try your project? +tags: [storage, core] +--- + +# External MongoDB Storage + +Refer : `internal/storage/external/mongodb` + +## Data to store and filtering it performs +1. first it gets the cluster data / credentials data based on this filters + - `cluster_name` (for cluster) + - `region` (for cluster) + - `cloud_provider` (for cluster & credentials) + - `cluster_type` (for cluster) + - also when the state of the cluster has recieved the stable desired state mark the IsCompleted flag in the specific cloud_provider struct to indicate its done +2. make sure the above things are specified before writing in the storage + +## How to use it +1. you need to call the Init function to get the storage make sure you have the interface type variable as the caller +2. before performing any operations you must call the **Connect()**. +3. for using methods: **Read()**, **Write()**, **Delete()** make sure you have called the **Setup()** +4. for calling **ReadCredentials()**, **WriteCredentials()** you can use it directly just need to specify the cloud provider you want to write +5. for calling **GetOneOrMoreClusters()** you need simply specify the filter +6. for calling **AlreadyCreated()** you just have to specify the func args +7. Don't forget to call the **storage.Kill()** when you want to stop the complte execution. it guarantees that it will wait till all the pending operations on the storage are completed +8. Custom Storage Directory you would need to specify the env var `KSCTL_CUSTOM_DIR_ENABLED` the value must be directory names wit space separated +9. specify the **Required ENV vars** + - `export MONGODB_USER=""` + - `export MONGODB_PASSWORD=""` + - `export MONGODB_DNS=""` + also it uses mongodb uri as **mongodb+srv** + +## Things to look for +1. make sure when you recieve return data from **Read()**. copy the address value to the storage pointer variable and not the address! +2. When any credentials are written, it will be stored in + - Database: `ksctl-{userid}-db` + - Collection: `{cloud_provider}` + - Document/Record: `raw bson data` with above specified data and filter fields +3. When any clusterState is written, it gets stored in + - Database: `ksctl-{userid}-db` + - Collection: `credentials` + - Document/Record: `raw bson data` with above specified data and filter fields + +4. When you do Switch aka getKubeconfig it fetches the kubeconfig from the point 3 and stores it to `/.ksctl/kubeconfig` + diff --git a/content/en/docs/Storage/local.md b/content/en/docs/Storage/local.md index d48594a..3ff8afa 100644 --- a/content/en/docs/Storage/local.md +++ b/content/en/docs/Storage/local.md @@ -4,6 +4,44 @@ description: What does your user need to know to try your project? categories: [Storage Provider] tags: [storage, core] --- -# Local -Uses Host Computer for storing the state for ksctl \ No newline at end of file +# Local Storage + +Refer: `internal/storage/local` + +## Data to store and filtering it performs +1. first it gets the cluster data / credentials data based on this filters + - `cluster_name` (for cluster) + - `region` (for cluster) + - `cloud_provider` (for cluster & credentials) + - `cluster_type` (for cluster) + - also when the state of the cluster has recieved the stable desired state mark the IsCompleted flag in the specific cloud_provider struct to indicate its done +2. make sure the above things are specified before writing in the storage + +it is stored something like this +``` + it will use almost the same construct. + * ClusterInfos => $USER_HOME/.ksctl/state/ + |-- {cloud_provider} + |-- {cluster_type} aka (ha, managed) + |-- "{cluster_name} {region}" + |-- state.json + * CredentialInfo => $USER_HOME/.ksctl/credentials/{cloud_provider}.json +``` + +## How to use it +1. you need to call the Init function to get the storage make sure you have the interface type variable as the caller +2. before performing any operations you must call the **Connect()**. +3. for using methods: **Read()**, **Write()**, **Delete()** make sure you have called the **Setup()** +4. for calling **ReadCredentials()**, **WriteCredentials()** you can use it directly just need to specify the cloud provider you want to write +5. for calling **GetOneOrMoreClusters()** you need simply specify the filter +6. for calling **AlreadyCreated()** you just have to specify the func args +7. Don't forget to call the **storage.Kill()** when you want to stop the complte execution. it guarantees that it will wait till all the pending operations on the storage are completed +8. Custom Storage Directory you would need to specify the env var `KSCTL_CUSTOM_DIR_ENABLED` the value must be directory names wit space separated +9. it creates the configuration directories on your behalf + +## Things to look for +1. make sure when you receive return data from **Read()**. copy the address value to the storage pointer variable and not the address! +2. When any credentials are written, it will be stored in `/.ksctl/credentials/{cloud_provider}.json` +3. When any clusterState is written, it gets stored in `/.ksctl/state/{cloud_provider}/{cluster_type}/{cluster_name} {region}/state.json` +4. When you do Switch aka getKubeconfig it fetches the kubeconfig from the point 3 and stores it to `/.ksctl/kubeconfig` diff --git a/content/en/docs/Storage/remote.md b/content/en/docs/Storage/remote.md deleted file mode 100644 index 13165a5..0000000 --- a/content/en/docs/Storage/remote.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Remote Storage -categories: [Storage Provider] -description: What does your user need to know to try your project? -tags: [storage, core] ---- - -# Remote - -Uses Remote Storage for storing the state for ksctl \ No newline at end of file