=============================
Configuring platform settings
=============================

Global configurations:
    * The Authentication Center client URL
    * The internal database
    * Optional NFS server volume mounts
    * HTTPS certificate settings
    * Resource profiles
    * The Kubernetes cluster
    * Any users, groups, or roles with Admin authorization
    * The git commit file size limit (Anaconda recommends keeping files under 50MB)

Per-Service configurations:
    * The authentication server used to secure access
    * The deployment server used to deploy apps
    * The workspace server used to run sessions
    * The storage server used to store and version projects
    * The local repository server used for channels and packages
    * The S3 endpoint and Git server used to store object and data
    * The local documentation server URL and platform UI configuration
    * System metrics from Prometheus
    * Alert management
    * Grafana dashboard visualizations

.. _helm_config_changes:

Setting platform configurations using the Helm chart
====================================================

*This is the preferred and recommended method for updating platform configurations.*

Anaconda's Kubernetes Helm chart encapsulates application definitions, dependencies, and configurations into a single ``values.yaml`` file. This file contains both global and per-service settings for the platform. For more information about how Workbench uses Helm and to view the default Helm chart template, see :ref:`Helm chart <helm_values>`. 

To make configuration changes to the platform:

#. Connect to your instance of Workbench.
#. Save your current configurations using the ``extract_config.sh`` script by running the following command:

    .. code-block:: none

        # Replace <NAMESPACE> with the namespace Workbench is installed in
        NAMESPACE=<NAMESPACE> ./extract_config.sh

    .. note::
        
        The ``extract_config.sh`` script creates multiple files and saves them in the directory where the script was run. You need the ``helm_values.yaml`` file. 

#. Verify that the information captured in ``helm_values.yaml`` file contains your current cluster configuration settings.
#. Update the ``helm_values.yaml`` file to include or alter your cluster configurations, then save your changes. 
#. Perform a Helm upgrade by running the following command: 

    .. code-block:: none

        helm upgrade --values ./helm_values.yaml anaconda-enterprise ./Anaconda-Enterprise/

Setting platform configurations using the config map
====================================================

Workbench platform settings can also be managed by the ``anaconda-enterprise-anaconda-platform.yml`` config map, though this is *no longer the recommended method for platform configuration updates*. 

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

    .. tab-set:: 

        .. tab-item:: BYOK8s
            
            Run the 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-anaconda-platform.yml -o=jsonpath={.data."anaconda-platform\.yml"} > anaconda-platform.yml
                kubectl delete cm -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml
                kubectl create cm -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml --from-file anaconda-platform.yml

        .. 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 -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml -o=jsonpath={.data."anaconda-platform\.yml"} > anaconda-platform.yml
                kubectl delete cm -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml
                kubectl create cm -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml --from-file anaconda-platform.yml

#. 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-anaconda-platform.yml
            kubectl create cm -n <NAMESPACE> anaconda-enterprise-anaconda-platform.yml --from-file anaconda-platform.yml