github.com/cilium/cilium@v1.16.2/Documentation/network/servicemesh/ingress.rst (about) 1 .. only:: not (epub or latex or html) 2 3 WARNING: You are looking at unreleased Cilium documentation. 4 Please use the official rendered version released here: 5 https://docs.cilium.io 6 7 .. _gs_ingress: 8 9 ************************** 10 Kubernetes Ingress Support 11 ************************** 12 13 Cilium uses the standard `Kubernetes Ingress`_ resource definition, with 14 an ``ingressClassName`` of ``cilium``. This can be used for path-based 15 routing and for TLS termination. For backwards compatibility, the 16 ``kubernetes.io/ingress.class`` annotation with value of ``cilium`` 17 is also supported. 18 19 .. Note:: 20 21 The ingress controller creates a Service of LoadBalancer type, so 22 your environment will need to support this. 23 24 Cilium allows you to specify load balancer mode for the Ingress resource: 25 26 - ``dedicated``: The Ingress controller will create a dedicated loadbalancer 27 for the Ingress. 28 - ``shared``: The Ingress controller will use a shared loadbalancer for all 29 Ingress resources. 30 31 Each load balancer mode has its own benefits and drawbacks. The shared mode saves 32 resources by sharing a single LoadBalancer config across all Ingress resources in 33 the cluster, while the dedicated mode can help to avoid potential conflicts (e.g. 34 path prefix) between resources. 35 36 .. Note:: 37 38 It is possible to change the load balancer mode for an Ingress resource. 39 When the mode is changed, active connections to backends of the Ingress 40 may be terminated during the reconfiguration due to a new load balancer 41 IP address being assigned to the Ingress resource. 42 43 This is a step-by-step guide on how to enable the Ingress Controller in 44 an existing K8s cluster with Cilium installed. 45 46 .. _Kubernetes Ingress: https://kubernetes.io/docs/concepts/services-networking/ingress/ 47 48 Prerequisites 49 ############# 50 51 * Cilium must be configured with NodePort enabled, using 52 ``nodePort.enabled=true`` or by enabling the kube-proxy replacement with 53 ``kubeProxyReplacement=true``. For more information, see :ref:`kube-proxy 54 replacement <kubeproxy-free>`. 55 * Cilium must be configured with the L7 proxy enabled using ``l7Proxy=true`` 56 (enabled by default). 57 * By default, the Ingress controller creates a Service of LoadBalancer type, 58 so your environment will need to support this. Alternatively, you can change 59 this to NodePort or, since Cilium 1.16+, directly expose the Cilium L7 proxy 60 on the :ref:`host network<gs_ingress_host_network_mode>`. 61 62 .. include:: installation.rst 63 64 .. include:: ingress-reference.rst 65 66 67 Ingress Path Types and Precedence 68 ********************************* 69 70 The Ingress specification supports three types of paths: 71 72 * **Exact** - match the given path exactly. 73 * **Prefix** - match the URL path prefix split by ``/``. The last path segment must 74 match the whole segment - if you configure a Prefix path of ``/foo/bar``, 75 ``/foo/bar/baz`` will match, but ``/foo/barbaz`` will not. 76 * **ImplementationSpecific** - Interpretation of the Path is up to the IngressClass. 77 **In Cilium's case, we define ImplementationSpecific to be "Regex"**, so Cilium will 78 interpret any given path as a regular expression and program Envoy accordingly. 79 Notably, some other implementations have ImplementationSpecific mean "Prefix", 80 and in those cases, Cilium will treat the paths differently. (Since a path like 81 ``/foo/bar`` contains no regex characters, when it is configured in Envoy as a 82 regex, it will function as an ``Exact`` match instead). 83 84 When multiple path types are configured on an Ingress object, Cilium will configure 85 Envoy with the matches in the following order: 86 87 #. Exact 88 #. ImplementationSpecific (that is, regular expression) 89 #. Prefix 90 #. The ``/`` Prefix match has special handling and always goes last. 91 92 Within each of these path types, the paths are sorted in decreasing order of string 93 length. 94 95 If you do use ImplementationSpecific regex support, be careful with using the 96 ``*`` operator, since it will increase the length of the regex, but may match 97 another, shorter option. 98 99 For example, if you have two ImplementationSpecific paths, ``/impl``, and ``/impl.*``, 100 the second will be sorted ahead of the first in the generated config. But because 101 ``*`` is in use, the ``/impl`` match will never be hit, as any request to that 102 path will match the ``/impl.*`` path first. 103 104 See the :ref:`Ingress Path Types <gs_ingress_path_types>` for more information. 105 106 Supported Ingress Annotations 107 ***************************** 108 109 .. list-table:: 110 :header-rows: 1 111 112 * - Name 113 - Description 114 - Default Value 115 * - ``ingress.cilium.io/loadbalancer-mode`` 116 - | The loadbalancer mode for the ingress. 117 | Allows a per ingress override 118 | of the default set in the Helm value 119 | ``ingressController.loadbalancerMode``. 120 | Applicable values are ``dedicated`` and 121 | ``shared``. 122 - | ``dedicated`` 123 | (from Helm chart) 124 * - ``ingress.cilium.io/loadbalancer-class`` 125 - | The loadbalancer class for the ingress. 126 | Only applicable when ``loadbalancer-mode`` is set to ``dedicated``. 127 - unspecified 128 * - ``ingress.cilium.io/service-type`` 129 - | The Service type for dedicated Ingress. 130 | Applicable values are ``LoadBalancer`` 131 | and ``NodePort``. 132 - ``LoadBalancer`` 133 * - ``ingress.cilium.io/service-external-traffic-policy`` 134 - | The Service externalTrafficPolicy for dedicated 135 | Ingress. Applicable values are ``Cluster`` 136 | and ``Local``. 137 - ``Cluster`` 138 * - ``ingress.cilium.io/insecure-node-port`` 139 - | The NodePort to use for the HTTP Ingress. 140 | Applicable only if ``ingress.cilium.io/service-type`` 141 | is ``NodePort``. If unspecified, a random 142 | NodePort will be allocated by kubernetes. 143 - unspecified 144 * - ``ingress.cilium.io/secure-node-port`` 145 - | The NodePort to use for the HTTPS Ingress. 146 | Applicable only if ``ingress.cilium.io/service-type`` 147 | is ``NodePort``. If unspecified, a random 148 | NodePort will be allocated by kubernetes. 149 - unspecified 150 * - ``ingress.cilium.io/host-listener-port`` 151 - | The port to use for the Envoy listener on the host 152 | network. Applicable and mandatory only for 153 | dedicated Ingress and if :ref:`host network mode<gs_ingress_host_network_mode>` is 154 | enabled. 155 - ``8080`` 156 * - ``ingress.cilium.io/tls-passthrough`` 157 - | Enable TLS Passthrough mode for this Ingress. 158 | Applicable values are ``enabled`` and ``disabled``, 159 | although boolean-style values will also be 160 | accepted. 161 | 162 | Note that some conditions apply to TLS 163 | Passthrough Ingresses, due to how 164 | TLS Passthrough works: 165 | * A ``host`` field must be set in the Ingress 166 | * Default backends are ignored 167 | * Rules with paths other than ``/`` are ignored 168 | If all the rules in an Ingress are ignored for 169 | these reasons, no Envoy config will be generated 170 | and the Ingress will have no effect. 171 | 172 | Note that this annotation is analogous to 173 | the ``ssl-passthrough`` on other Ingress 174 | controllers. 175 - ``disabled`` 176 * - ``ingress.cilium.io/force-https`` 177 - | Enable enforced HTTPS redirects for this Ingress. 178 | Applicable values are ``enabled`` and ``disabled``, 179 | although boolean-style values will also be 180 | accepted. 181 | 182 | Note that if the annotation is not present, this 183 | behavior will be controlled by the 184 | ``enforce-ingress-https`` configuration 185 | file setting (or ``ingressController.enforceHttps`` 186 | in Helm). 187 | 188 | Any host with TLS config will have redirects to 189 | HTTPS configured for each match specified in the 190 | Ingress. 191 - unspecified 192 193 Additionally, cloud-provider specific annotations for the LoadBalancer Service 194 are supported. 195 196 By default, annotations with values beginning with: 197 198 * ``lbipam.cilium.io`` 199 * ``nodeipam.cilium.io`` 200 * ``service.beta.kubernetes.io`` 201 * ``service.kubernetes.io`` 202 * ``cloud.google.com`` 203 204 will be copied from an Ingress object to the generated LoadBalancer Service objects. 205 206 This setting is controlled by the Cilium Operator's ``ingress-lb-annotation-prefixes`` 207 config flag, and can be configured in Cilium's Helm ``values.yaml`` 208 using the ``ingressController.ingressLBAnnotationPrefixes`` setting. 209 210 Please refer to the `Kubernetes documentation <https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer>`_ 211 for more details. 212 213 .. _gs_ingress_host_network_mode: 214 215 Host network mode 216 ################# 217 .. note:: 218 Supported since Cilium 1.16+ 219 220 Host network mode allows you to expose the Cilium ingress controller (Envoy 221 listener) directly on the host network. 222 This is useful in cases where a LoadBalancer Service is unavailable, such 223 as in development environments or environments with cluster-external 224 loadbalancers. 225 226 .. note:: 227 * Enabling the Cilium ingress controller host network mode automatically disables the LoadBalancer/NodePort type Service mode. They are mutually exclusive. 228 * The listener is exposed on all interfaces (``0.0.0.0`` for IPv4 and/or ``::`` for IPv6). 229 230 Host network mode can be enabled via Helm: 231 232 .. code-block:: yaml 233 234 ingressController: 235 enabled: true 236 hostNetwork: 237 enabled: true 238 239 Once enabled, host network ports can be specified with the following methods: 240 241 * Shared Ingress: Globally via Helm flags 242 * ``ingressController.hostNetwork.sharedListenerPort``: Host network port to expose the Cilium ingress controller Envoy listener. The default port is ``8080``. If you change it, you should choose a port number higher than ``1023`` (see `Bind to privileged port`_). 243 * Dedicated Ingress: Per ``Ingress`` resource via annotations 244 * ``ingress.cilium.io/host-listener-port``: Host network port to expose the Cilium ingress controller Envoy listener. The default port is ``8080`` but it can only be used for a single ``Ingress`` resource as it needs to be unique per ``Ingress`` resource. You should choose a port higher than ``1023`` (see `Bind to privileged port`_). This annotation is mandatory if the global Cilium ingress controller mode is configured to ``dedicated`` (``ingressController.loadbalancerMode``) or the ingress resource sets the ``ingress.cilium.io/loadbalancer-mode`` annotation to ``dedicated`` and multiple ``Ingress`` resources are deployed. 245 246 The default behavior regarding shared or dedicated ingress can be configured via 247 ``ingressController.loadbalancerMode``. 248 249 .. warning:: 250 Be aware that misconfiguration might result in port clashes. Configure unique ports that are still available on all Cilium Nodes where Cilium ingress controller Envoy listeners are exposed. 251 252 Bind to privileged port 253 *********************** 254 By default, the Cilium L7 Envoy process does not have any Linux capabilities 255 out-of-the-box and is therefore not allowed to listen on privileged ports. 256 257 If you choose a port equal to or lower than ``1023``, ensure that the Helm value 258 ``envoy.securityContext.capabilities.keepCapNetBindService=true`` is configured 259 and to add the capability ``NET_BIND_SERVICE`` to the respective 260 :ref:`Cilium Envoy container via Helm values<envoy>`: 261 262 * Standalone DaemonSet mode: ``envoy.securityContext.capabilities.envoy`` 263 * Embedded mode: ``securityContext.capabilities.ciliumAgent`` 264 265 Configure the following Helm values to allow privileged port bindings in host 266 network mode: 267 268 .. tabs:: 269 270 .. group-tab:: Standalone DaemonSet mode 271 272 .. code-block:: yaml 273 274 ingressController: 275 enabled: true 276 hostNetwork: 277 enabled: true 278 envoy: 279 enabled: true 280 securityContext: 281 capabilities: 282 keepCapNetBindService: true 283 envoy: 284 # Add NET_BIND_SERVICE to the list (keep the others!) 285 - NET_BIND_SERVICE 286 287 .. group-tab:: Embedded mode 288 289 .. code-block:: yaml 290 291 ingressController: 292 enabled: true 293 hostNetwork: 294 enabled: true 295 envoy: 296 securityContext: 297 capabilities: 298 keepCapNetBindService: true 299 securityContext: 300 capabilities: 301 ciliumAgent: 302 # Add NET_BIND_SERVICE to the list (keep the others!) 303 - NET_BIND_SERVICE 304 305 Deploy Gateway API listeners on subset of nodes 306 *********************************************** 307 The Cilium ingress controller Envoy listener can be exposed on a specific subset 308 of nodes. This only works in combination with the host network mode and can be 309 configured via a node label selector in the Helm values: 310 311 .. code-block:: yaml 312 313 ingressController: 314 enabled: true 315 hostNetwork: 316 enabled: true 317 nodes: 318 matchLabels: 319 role: infra 320 component: ingress 321 322 This will deploy the Ingress Controller Envoy listener only on the Cilium Nodes 323 matching the configured labels. An empty selector selects all nodes and 324 continues to expose the functionality on all Cilium nodes. 325 326 Examples 327 ######## 328 329 Please refer to one of the below examples on how to use and leverage 330 Cilium's Ingress features: 331 332 .. toctree:: 333 :maxdepth: 1 334 :glob: 335 336 http 337 ingress-and-network-policy 338 path-types 339 grpc 340 tls-termination 341 tls-default-certificate