Global Kubernetes Upstreams
Directory Structure
|-- global_k8s_upstreams/
|-- global_k8s_upstreams.yaml
|-- ...
The YAML files can contain one or more global Kubernetes upstream configurations.
Configuration Description
Each global Kubernetes upstream configuration is a key-value pair, where the key is the upstream name and the value is an object containing the following parameters:
Parameter Name | Data Type | Required | Description |
---|---|---|---|
ssl | boolean | No | Enable SSL connection, default is false |
disable_ssl_verify | boolean | No | Disable SSL verification, default is false |
enable_checker | boolean | No | Enable health check, default is false |
k8s_services | array | Yes | List of Kubernetes services |
checker | object | No | Health check configuration, only valid when enable_checker is true |
k8s_services Configuration
Parameter Name | Data Type | Required | Description |
---|---|---|---|
k8s_name | string | Yes | Kubernetes cluster name |
k8s_namespace | string | Yes | Kubernetes namespace |
k8s_service | string | Yes | Kubernetes service name |
k8s_service_port | integer | Yes | Kubernetes service port |
checker Configuration
The health check configuration contains multiple parameters to define how health checks are performed. Main parameters include:
Parameter Name | Data Type | Description |
---|---|---|
type | string | Health check type, e.g., “http” |
interval | integer | Check interval |
timeout | integer | Timeout |
fall | integer | Consecutive failure threshold |
rise | integer | Consecutive success threshold |
http_req_method | string | HTTP request method |
http_req_uri | string | HTTP request URI |
valid_statuses | array | List of valid HTTP status codes |
Configuration Example
global_k8s_upstream_name1:
ssl: false
disable_ssl_verify: false
enable_checker: true
k8s_services:
- k8s_name: k8s_cluster_name1
k8s_namespace: default
k8s_service: test-hello
k8s_service_port: 80
- k8s_name: k8s_cluster_name1
k8s_namespace: default
k8s_service: test-hello-2
k8s_service_port: 82
checker:
user_agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
valid_statuses:
- 200
- 302
rise: 2
type: http
fall: 3
interval: 3
timeout: 1
http_req_method: GET
http_req_host: test.com
http_req_uri: /status
global_k8s_upstream_name2:
ssl: true
disable_ssl_verify: true
enable_checker: false
k8s_services:
- k8s_name: k8s_cluster_name1
k8s_namespace: default
k8s_service: test-hello-2
k8s_service_port: 82
This configuration defines two global Kubernetes upstreams, one with health checks enabled and another with SSL enabled but health checks disabled.
Usage Example
Update configuration to OpenResty Edge:
edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l global_k8s_upstreams -i /root/oredge-configs
Export configuration from OpenResty Edge:
edge-config -u https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -E -l global_k8s_upstreams
Both examples use -l global_k8s_upstreams
to specify importing/exporting only global Kubernetes upstream related configurations.
Notes
Global Kubernetes upstream is a global configuration. Delete operations are not performed when updating configurations to maintain compatibility with multiple local configurations.
Each global Kubernetes upstream must have a unique name.
k8s_name
must be a Kubernetes cluster name already defined in the tool.k8s_service_port
must be a valid port number (1-65535).If health checks are enabled (
enable_checker: true
), a validchecker
configuration must be provided.When updating configurations, the tool compares new and old configurations to determine if an update is needed. If there are changes, an update operation will be performed.
When importing configurations, the tool first checks the validity of the configuration before performing add or update operations.
When exporting configurations, the tool converts Kubernetes cluster IDs to cluster names for better readability and portability of the configuration.