API Endpoints for kubernetes-client/python

Defined Routes in the Codebase

In the kubernetes-client/python codebase, there are several routes defined as part of the HTTP ingress functionality. These routes are associated with Kubernetes Ingress resources that map incoming HTTP requests to backend services. Key components include V1HTTPIngressPath and V1HTTPIngressRuleValue, which define the paths used for routing.

V1IngressRule and Paths

The V1IngressRule is responsible for mapping the paths for specific hosts to their corresponding backends.

  • Description: The IngressRule represents the rules mapping the paths under a specified host to related backend services. Incoming requests are evaluated first for a host match, followed by routing to the appropriate backend based on matching IngressRuleValue.

  • Source:

    IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.
    

    (kubernetes/docs/V1IngressRule.md)

Defining Paths

The path definitions are encapsulated within the V1HTTPIngressRuleValue class, which contains a list of paths. Each path is an object of V1HTTPIngressPath.

V1HTTPIngressPath

The V1HTTPIngressPath class holds the details necessary for path routing, such as the path itself, the backend service, and the type of matching to be done.

  • Attributes:

    • backend: Defines the backend service to which the request should be routed.
    • path: Specifies the incoming request path to match.
    • path_type: Indicates how the path matching should be interpreted (Exact, Prefix, or ImplementationSpecific).
  • Example Code:

class V1HTTPIngressPath(object):
"""NOTE: This class is auto generated by OpenAPI Generator."""

openapi_types = { 'backend': 'V1IngressBackend', 'path': 'str', 'path_type': 'str' }

def init(self, backend=None, path=None, path_type=None, local_vars_configuration=None): self.backend = backend self.path = path self.path_type = path_type

@property def path(self): """Gets the path of this V1HTTPIngressPath.""" return self._path

@path.setter def path(self, path): """Sets the path of this V1HTTPIngressPath.""" self._path = path

@property def path_type(self): """Gets the path_type of this V1HTTPIngressPath.""" return self._path_type

@path_type.setter def path_type(self, path_type): """Sets the path_type of this V1HTTPIngressPath.""" self._path_type = path_type

Path Types

The path type can be set to one of three values:

  1. Exact: Matches the URL path exactly.
  2. Prefix: Matches based on a URL path prefix, split by ‘/’.
  3. ImplementationSpecific: The interpretation of the path matching is dependent on the IngressClass.
  • Example Path Definition:
path_type = "Prefix"
path = "/foo/bar"

V1HTTPIngressRuleValue

This class encapsulates the collection of paths that connect requests to backends through the paths attribute:

  • Source:

    paths is a collection of paths that map requests to backends.
    
  • Example Code:

class V1HTTPIngressRuleValue(object):
openapi_types = {
'paths': 'list[V1HTTPIngressPath]'
}

def init(self, paths=None): self.paths = paths

@property def paths(self): """Gets the paths of this V1HTTPIngressRuleValue.""" return self._paths

@paths.setter def paths(self, paths): """Sets the paths of this V1HTTPIngressRuleValue.""" self._paths = paths

Summary

The routing functionality is primarily managed through the V1IngressRule, V1HTTPIngressPath, and V1HTTPIngressRuleValue classes found throughout the codebase. Each class plays a vital role in defining how requests are routed to backend services based on specified paths and types. The specific routes and their configurations can be customized through instances of these classes, allowing for flexible HTTP request handling in a Kubernetes environment.