===============================
Setting global config variables
===============================

Data Science & AI Workbench provides a secondary config map (``anaconda-enterprise-env-var-config``) that you can use to configure the platform. Any environment variables added to this config map will be available to all sessions, deployments, and scheduled jobs. This is a convenient alternative to using the Workbench CLI, as you can add any variable `supported by conda configuration <https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#general-configuration>`_. 

To make global configuration changes to the platform:

.. _global_config:

#. Create a backup of your current configmap file, then edit your configurations by running the following commands: 

    .. tab-set:: 

        .. tab-item:: BYOK8s
            
            Run the following commands from anywhere you have ``kubectl`` access to the cluster:

            .. code-block:: none

                # Replace <NAMESPACE> with your Workbench cluster namespace
                kubectl get cm -n <NAMESPACE> anaconda-enterprise-env-var-config -o=jsonpath={.data."container-env-vars\.yml"} > container-env-vars.yaml
                kubectl edit cm -n <NAMESPACE> anaconda-enterprise-env-var-config

        .. tab-item:: Gravity
         
            Run the following commands in an interactive shell *on the master node*:

            .. code-block:: none

                # Replace <NAMESPACE> with your Workbench cluster namespace
                sudo gravity enter
                kubectl get cm anaconda-enterprise-env-var-config -o yaml > anaconda-env-var-config.yaml
                kubectl edit cm -n <NAMESPACE> anaconda-enterprise-env-var-config

#. Make your changes to the file, then save it.
#. Restart all pods using the following command:

    .. code-block:: none
      
        # Replace <NAMESPACE> with your Workbench cluster namespace
        kubectl delete -n <NAMESPACE> --wait=false $(kubectl get pods -o name|grep ap-)

.. tip:: 

    If something goes wrong with your configuration updates, you can restore your previous configurations by re-running the following commands:

        .. code-block:: none

            # Replace <NAMESPACE> with your Workbench cluster namespace
            kubectl delete cm -n <NAMESPACE> anaconda-enterprise-env-var-config
            kubectl create cm -n <NAMESPACE> anaconda-enterprise-env-var-config --from-file anaconda-env-var-config.yml