← Back to Tutorial Chapter 2 of 8
1 2 3 4 5 6 7 8
⚙️ Chapter 2

Configuration

Learn how the OpenFaaS Gateway is configured and discover all the available settings and knobs that control system behavior.

Settings Environment Variables Configuration Files

⚙️ How is the Gateway Configured?

The OpenFaaS Gateway uses a flexible configuration system that supports multiple configuration methods, allowing you to customize the behavior for different deployment scenarios.

Configuration Methods:

  • Environment variables (most common)
  • Configuration files (YAML/JSON)
  • Command-line flags
  • Kubernetes ConfigMaps

🎛️ Configuration Categories

The Gateway configuration is organized into logical categories that control different aspects of the system's behavior.

Server Configuration

HTTP server settings, port configuration, TLS settings, and basic server behavior.

Function Configuration

Function invocation settings, timeout values, and resource allocation parameters.

Provider Configuration

Kubernetes provider settings, namespace configuration, and cluster-specific options.

Security Configuration

Authentication, authorization, CORS settings, and security-related parameters.

🔑 Key Configuration Options

Here are some of the most important configuration options that control the Gateway's behavior.

Essential Environment Variables:

PORT

HTTP server port (default: 8080)

READ_TIMEOUT

Request read timeout (default: 10s)

WRITE_TIMEOUT

Response write timeout (default: 10s)

MAX_IDLE_CONN

Maximum idle connections (default: 100)

💻 Configuration Example

Here's an example of how to configure the Gateway using environment variables in a Kubernetes deployment.

# Kubernetes Deployment Configuration
apiVersion: apps/v1
kind: Deployment
metadata:
name: openfaas-gateway
spec:
template:
spec:
containers:
- name: gateway
env:
- name: PORT
value: "8080"
- name: READ_TIMEOUT
value: "30s"
- name: WRITE_TIMEOUT
value: "30s"

✨ Configuration Best Practices

Follow these best practices to ensure your Gateway configuration is secure, performant, and maintainable.

Security First

  • • Use environment variables for secrets
  • • Enable TLS in production
  • • Configure proper CORS policies

Performance Tuning

  • • Set appropriate timeouts
  • • Configure connection pools
  • • Monitor resource usage

➡️ What's Next?

Now that you understand how the Gateway is configured, let's explore how the REST API is defined and how requests are routed.