MongoDB Persistency when deploying to Kubernetes via VSCode Cloud Studio

75 Views Asked by At

I am trying to use VSCode Cloud Studio plugin to deploy and debug a project in Kubernetes. When I use intellij and Cloud Studio plugin there, everything works perfect. My MongoDB is persistent with each deployment. When I use VSCode and Cloud Studio there, MongoDB is not persistent anymore. I would appreciate any tips to make it work in VSCode too.

When I deploy via intellij it uses the same persistent volume claim. When I deploy via VSCode it creates a new persistent volume claim everytime.

Here is the launch.json for VSCode:

    {
    "configurations": [
        {
            "name": "Kubernetes: Run/Debug",
            "type": "cloudcode.kubernetes",
            "request": "launch",
            "skaffoldConfig": "${workspaceFolder}\\skaffold.yaml",
            "watch": false,
            "cleanUp": false,
            "portForward": true,
            "imageRegistry": "XYZ",
            "debug": [
                {
                    "image": "XYZ",
                    "containerName": "XYZ",
                    "sourceFileMap": {
                        "${workspaceFolder}": "/root/"
                    }
                }
            ]
        }
    ]
}

Here is the workspace.xml from intellij:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="b5a077d4-323a-4042-8c4a-3bdd2d997e47" name="Changes" comment="" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="MarkdownSettingsMigration">
    <option name="stateVersion" value="1" />
  </component>
  <component name="ProjectId" id="2KV2OUqPUEf43q5Aj0UCGkKKm10" />
  <component name="ProjectViewState">
    <option name="hideEmptyMiddlePackages" value="true" />
    <option name="showLibraryContents" value="true" />
  </component>
  <component name="PropertiesComponent">
    <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
    <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="com.google.cloudcode.ide_session_index" value="20230118_0001" />
    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
    <property name="nodejs_package_manager_path" value="npm" />
    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
    <property name="ts.external.directory.path" value="C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\plugins\JavaScriptLanguage\jsLanguageServicesImpl\external" />
  </component>
  <component name="RunDashboard">
    <option name="excludedTypes">
      <set>
        <option value="gcp-app-engine-local-run" />
      </set>
    </option>
  </component>
  <component name="RunManager">
    <configuration name="Develop on Kubernetes" type="google-container-tools-skaffold-run-config" factoryName="google-container-tools-skaffold-run-config-dev" show_console_on_std_err="false" show_console_on_std_out="false">
      <option name="allowRunningInParallel" value="false" />
      <option name="buildEnvironment" value="Local" />
      <option name="cleanupDeployments" value="false" />
      <option name="deployToCurrentContext" value="true" />
      <option name="deployToMinikube" value="false" />
      <option name="envVariables" />
      <option name="imageRepositoryOverride" />
      <option name="kubernetesContext" />
      <option name="mappings">
        <list />
      </option>
      <option name="moduleDeploymentType" value="DEPLOY_MODULE_SUBSET" />
      <option name="projectPathOnTarget" />
      <option name="resourceDeletionTimeoutMins" value="2" />
      <option name="selectedOptions">
        <list />
      </option>
      <option name="skaffoldConfigurationFilePath" value="$PROJECT_DIR$/skaffold.yaml" />
      <option name="skaffoldModules">
        <list>
          <option value="XYZ" />
        </list>
      </option>
      <option name="skaffoldNamespace" />
      <option name="skaffoldProfile" />
      <option name="skaffoldWatchMode" value="ON_DEMAND" />
      <option name="statusCheck" value="true" />
      <option name="verbosity" value="WARN" />
      <method v="2" />
    </configuration>
  </component>
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="b5a077d4-323a-4042-8c4a-3bdd2d997e47" name="Changes" comment="" />
      <created>1674045398429</created>
      <option name="number" value="Default" />
      <option name="presentableId" value="Default" />
      <updated>1674045398429</updated>
      <workItem from="1674045401219" duration="2543000" />
    </task>
    <servers />
  </component>
  <component name="TypeScriptGeneratedFilesManager">
    <option name="version" value="3" />
  </component>
</project>

All other files are the same for the project of course.

1

There are 1 best solutions below

2
On

It looks like the Cloud Code for IntelliJ configuration is restricting the deployment to the XYZ module, but not in the Cloud Code for VS Code configuration.