Skip to main content

Overview

The OpenShift Python Wrapper supports proxy configuration, allowing you to route all cluster communication through an HTTP or HTTPS proxy server. This is essential for environments with restricted network access or corporate proxy requirements.

Quick Start

Enable proxy configuration by setting environment variables:
The wrapper automatically detects and uses proxy settings from HTTPS_PROXY or HTTP_PROXY environment variables. No code changes are required.

Configuration Methods

HTTPS Proxy

For secure connections (recommended):

HTTP Proxy

For non-secure connections:

Proxy Priority

If both are set, HTTPS_PROXY takes precedence:

Proxy URL Format

Proxy URLs should follow this format:

Without Authentication

With Authentication

With Special Characters

URL-encode special characters in credentials:
Use Python’s urllib.parse.quote() to encode credentials with special characters:

No Proxy Configuration

Exclude specific hosts from proxying:
The NO_PROXY variable accepts comma-separated values:
  • Hostnames: localhost, example.com
  • IP addresses: 127.0.0.1, 192.168.1.1
  • CIDR notation: 10.0.0.0/8, 172.16.0.0/12
  • Domain suffixes: .internal.example.com (matches all subdomains)

Usage Examples

Basic Usage

Set proxy and use the wrapper normally:

With Authentication

Multiple Clusters with Different Proxies

Corporate Proxy Setup

Windows Environment

Linux/Mac Environment

Docker Container

Pass proxy settings to containers:

Kubernetes Pod

Configure proxy in pod environment:

Verification

Check Proxy Configuration

Verify proxy settings are detected:

Test Proxy Connection

Test if the proxy is working:

Troubleshooting

Proxy Connection Refused

Certificate Verification Errors

If using a corporate proxy with SSL inspection, you may encounter certificate errors.
For testing only, you can disable SSL verification (not recommended for production):
Better solution - add corporate CA certificate:

Proxy Authentication Failures

If authentication fails:
  1. Verify credentials are correct
  2. Check if special characters need URL encoding
  3. Test credentials with curl:

Requests Not Using Proxy

If requests aren’t going through proxy:
  1. Verify environment variables are set:
  2. Check NO_PROXY isn’t excluding your cluster:
  3. Ensure variables are set before importing wrapper:

Security Considerations

  1. Avoid Hardcoding Credentials: Never hardcode proxy credentials in scripts
  2. Use Environment Variables: Store credentials in environment variables
  3. Secure Credential Storage: Use secrets management for production
  4. HTTPS Proxy: Prefer HTTPS proxies for encrypted traffic
  5. Audit Logging: Enable proxy logging for security audits
  6. Least Privilege: Use proxy accounts with minimum required permissions

Best Practices

  1. Set Globally: Configure proxy environment variables at the system level
  2. Use NO_PROXY: Exclude internal traffic from proxying
  3. Test Connectivity: Always test proxy configuration before deployment
  4. Document Settings: Document proxy requirements for your environment
  5. Monitor Traffic: Monitor proxy logs for connection issues
  6. Use Authentication: Secure proxies with authentication
  7. Handle Errors: Add proper error handling for proxy failures

Complete Example

Here’s a complete script with proxy configuration:
Run with: