Using a proxy for conda packages

You can configure Anaconda Enterprise to use a proxy for conda packages, if your organization’s network security policy requires it. To do so, you’ll need to do the following:


Installing Miniconda

Install Miniconda, a mini version of Anaconda that includes conda, its dependencies, and Python.

  1. Download the Miniconda installer to the current working directory.

Note

If you want the file saved in a different directory, make sure you cd to the working directory before running this command.

curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  1. Run the following command to install Miniconda to the root directory (e.g., ~centos/miniconda3):

    sh Miniconda3-latest-Linux-x86_64.sh
    
  2. Re-initialize your terminal for the previous steps to take effect:

    source ~/.bashrc
    
  3. Whitelist the local repository by running the following command to set the NO_PROXY environment variable, providing the FQDN of the local repo:

    export NO_PROXY=https://<your-server.domain.com>
    

Installing and configuring the Anaconda Enterprise CLI

You’ll need to use the Anaconda Enterprise CLI in subsequent steps, so install it now if you haven’t already done so.

  1. Run the following command to install the Anaconda Enteprise CLI and package mirroring tool:

    conda install -kc https://<your-server.domain.com>/repository/conda/anaconda-enterprise anaconda-enterprise-cli cas-mirror git
    
  2. After the list of package dependencies has been resolved, type y to proceed with the installation.

  3. To configure the Anaconda CLI, run the following commands, using the FQDN of your Anaconda Enterprise instance:

    anaconda-enterprise-cli config set sites.master.url https://<your-server.domain.com>/repository/api
    
    anaconda-enterprise-cli config set default_site master
    
    anaconda-enterprise-cli config set ssl_verify false
    

Configuring Anaconda Enterprise

After you’ve installed and configured the required tools, you can update your Anaconda Enterprise configuration:

  1. Log in to the Operations Center UI at https://<your-server.domain.com>:32009, using either the default credentials aeplatform@anaconda.com / aeplatform or the credentials of another Operations Center Admin user.

  2. Click Configuration in the menu on the left and use the Config maps drop-down menu to select the anaconda-enterprise-anaconda-platform.yml configuration file.

Warning

We strongly recommend you make a manual backup copy of this file before editing it, as any changes you make will impact how Anaconda Enterprise functions.

  1. Scroll down to the conda section and ensure it looks like the following:

    conda: # Common conda settings for editing sessions and deployments
      channels:
        - defaults
    
    
      default_channels: # List of channels that should be used for channel 'defaults'
        - https://repo.anaconda.com/pkgs/main
        - https://repo.anaconda.com/pkgs/free
        - https://repo.anaconda.com/pkgs/
    
  2. Run this command to access the CLI:

    anaconda-enterprise-cli login
    
  3. Log in using the same username and password that you use to log in the Anaconda Enterprise web interface (or the default Admin credentials anaconda-enterprise/anaconda-enterprise).

  4. Create a config file (condarc.secret.txt) for conda proxying with the following content, and mount it at /etc/conda/.condarc:

    proxy_servers:
        http: http://proxy.url.com:<port>
        https: https://proxy.url.com:<port>
    
  5. Run the following command to create a Kubernetes secret:

    anaconda-enterprise-cli spark-config --config /etc/conda/.condarc condarc.secret.txt
    
  6. Upload the secret to Kubernetes.

Warning

This will delete any existing custom Kubernetes secrets in anaconda-config-files-secret.yaml, so if you’ve already configured other secrets (e.g., for Hadoop Spark access) make sure you include those secrets and move the existing file to a remote location to preserve it.

sudo kubectl replace -f anaconda-config-files-secret.yaml -n default
  1. Restart the relevant pods:

    sudo gravity enter
    kubectl get pods | grep 'ap-deploy\|ap-workspace\|ap-ui' | cut -d' ' -f1 | xargs kubectl delete pods
    

Verifying the proxy works

After you’ve configured the platform, you can test your changes to verify that it’s using the proxy.

  1. Log into Anaconda Enterprise.

  2. Click Projects, and open the project you want to use to test the proxy.

Note

If the project already has an open session, you’ll need to stop the current session and start a new session.

  1. Open a terminal window within JupyterLab and run the following command to display the conda configuration:

    conda config --show
    
  2. Verify the proxy config information from condarc.secret.txt is being set.

  3. Run the following command to prepare the project:

    anaconda-project prepare
    

Packages should be resolving and being pulled from public Anaconda repositories.