Anotações para controlador de entrada de gateway de aplicaçãoAnnotations for Application Gateway Ingress Controller
ApresentaçõesIntroductions
O recurso Kubernetes Ingress pode ser anotado com pares arbitrários de chave/valor.The Kubernetes Ingress resource can be annotated with arbitrary key/value pairs. A AGIC baseia-se em anotações para programar funcionalidades de Gateway de Aplicação, que não são configuráveis através do INgress YAML.AGIC relies on annotations to program Application Gateway features, which are not configurable via the Ingress YAML. As anotações ingres são aplicadas a todas as definições HTTP, piscinas de backend e ouvintes derivados de um recurso de entrada.Ingress annotations are applied to all HTTP setting, backend pools, and listeners derived from an ingress resource.
Lista de anotações apoiadasList of supported annotations
Para que um recurso Ingress seja observado pela AGIC, deve ser anotado com kubernetes.io/ingress.class: azure/application-gateway
.For an Ingress resource to be observed by AGIC, it must be annotated with kubernetes.io/ingress.class: azure/application-gateway
. Só então a AGIC trabalhará com o recurso Ingress em questão.Only then AGIC will work with the Ingress resource in question.
Prefixo do caminho de backendBackend Path Prefix
Esta anotação permite que o caminho de backend especificado num recurso ingresso seja reescrito com prefixo especificado nesta anotação.This annotation allows the backend path specified in an ingress resource to be rewritten with prefix specified in this annotation. Isto permite que os utilizadores exponham serviços cujos pontos finais são diferentes dos nomes de pontos finais usados para expor um serviço num recurso de entrada.This allows users to expose services whose endpoints are different than endpoint names used to expose a service in an ingress resource.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/backend-path-prefix: <path prefix>
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-bkprefix
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/backend-path-prefix: "/test/"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 80
No exemplo acima, definimos um recurso ingresso nomeado go-server-ingress-bkprefix
com uma appgw.ingress.kubernetes.io/backend-path-prefix: "/test/"
anotação.In the example above, we have defined an ingress resource named go-server-ingress-bkprefix
with an annotation appgw.ingress.kubernetes.io/backend-path-prefix: "/test/"
. A anotação indica a porta de entrada da aplicação para criar uma definição HTTP, que terá um prefixo de caminho para o caminho /hello
para /test/
.The annotation tells application gateway to create an HTTP setting, which will have a path prefix override for the path /hello
to /test/
.
Nota
No exemplo acima, temos apenas uma regra definida.In the above example we have only one rule defined. No entanto, as anotações são aplicáveis a todo o recurso ingresso, por isso, se um utilizador tivesse definido várias regras, o prefixo do caminho de backend seria configurado para cada um dos caminhos especificados.However, the annotations are applicable to the entire ingress resource, so if a user had defined multiple rules, the backend path prefix would be set up for each of the paths specified. Assim, se um utilizador quiser regras diferentes com prefixos de caminhos diferentes (mesmo para o mesmo serviço) teria de definir diferentes recursos de entrada.Thus, if a user wants different rules with different path prefixes (even for the same service) they would need to define different ingress resources.
Redirecionamento de TLSTLS Redirect
O Gateway de Aplicações pode ser configurado para redirecionar automaticamente os URLs HTTP para as suas congéneres HTTPS.Application Gateway can be configured to automatically redirect HTTP URLs to their HTTPS counterparts. Quando esta anotação estiver presente e o TLS estiver devidamente configurado, o controlador Kubernetes Ingress criará uma regra de encaminhamento com uma configuração de redireccionamento e aplicará as alterações no seu Gateway de Aplicação.When this annotation is present and TLS is properly configured, Kubernetes Ingress controller will create a routing rule with a redirection configuration and apply the changes to your Application Gateway. O redirecionamento criado será HTTP 301 Moved Permanently
.The redirect created will be HTTP 301 Moved Permanently
.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/ssl-redirect: "true"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-redirect
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- www.contoso.com
secretName: testsecret-tls
rules:
- host: www.contoso.com
http:
paths:
- backend:
serviceName: websocket-repeater
servicePort: 80
Drenagem de ligaçãoConnection Draining
connection-draining
: Esta anotação permite que os utilizadores especifiquem se permitem a drenagem da ligação.connection-draining
: This annotation allows users to specify whether to enable connection draining.
connection-draining-timeout
: Esta anotação permite que os utilizadores especifiquem um intervalo após o qual o Application Gateway terminará os pedidos para o ponto final de retenção de drenagem.connection-draining-timeout
: This annotation allows users to specify a timeout after which Application Gateway will terminate the requests to the draining backend endpoint.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/connection-draining: "true"
appgw.ingress.kubernetes.io/connection-draining-timeout: "60"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-drain
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/connection-draining: "true"
appgw.ingress.kubernetes.io/connection-draining-timeout: "60"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 80
Afinidade baseada em cookiesCookie Based Affinity
Esta anotação permite especificar se permite a afinidade baseada em cookies.This annotation allows to specify whether to enable cookie based affinity.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/cookie-based-affinity: "true"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-affinity
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/cookie-based-affinity: "true"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 80
Tempo Limite do PedidoRequest Timeout
Esta anotação permite especificar o tempo limite de pedido em segundos após o qual o Application Gateway falhará o pedido se a resposta não for recebida.This annotation allows to specify the request timeout in seconds after which Application Gateway will fail the request if response is not received.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/request-timeout: "20"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-timeout
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/request-timeout: "20"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 80
Utilizar IP privadoUse Private IP
Esta anotação permite-nos especificar se devemos expor este ponto final no Private IP do Application Gateway.This annotation allows us to specify whether to expose this endpoint on Private IP of Application Gateway.
Nota
- O Application Gateway não suporta vários IPs na mesma porta (exemplo: 80/443).Application Gateway doesn't support multiple IPs on the same port (example: 80/443). A entrada com anotação
appgw.ingress.kubernetes.io/use-private-ip: "false"
e outra com on fará com que aappgw.ingress.kubernetes.io/use-private-ip: "true"
HTTP
AGIC falhe na atualização do Gateway de Aplicação.Ingress with annotationappgw.ingress.kubernetes.io/use-private-ip: "false"
and another withappgw.ingress.kubernetes.io/use-private-ip: "true"
onHTTP
will cause AGIC to fail in updating the Application Gateway. - Para o Application Gateway que não tenha um IP privado, Ingresses com
appgw.ingress.kubernetes.io/use-private-ip: "true"
será ignorado.For Application Gateway that doesn't have a private IP, Ingresses withappgw.ingress.kubernetes.io/use-private-ip: "true"
will be ignored. Isto refletir-se-á nos registos do controlador e nos eventos de entrada para aqueles que se ingressam comNoPrivateIP
aviso.This will reflected in the controller logs and ingress events for those ingresses withNoPrivateIP
warning.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/use-private-ip: "true"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-timeout
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/use-private-ip: "true"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 80
Protocolo de BackendBackend Protocol
Esta anotação permite-nos especificar o protocolo que o Application Gateway deve utilizar enquanto fala com os Pods.This annotation allows us to specify the protocol that Application Gateway should use while talking to the Pods. Protocolos apoiados: http
, https
Supported Protocols: http
, https
Nota
- Embora os certificados auto-assinados sejam suportados no Application Gateway, atualmente, a AGIC só suporta
https
quando os Pods estão a usar o certificado assinado por um conhecido CA.While self-signed certificates are supported on Application Gateway, currently, AGIC only supporthttps
when Pods are using certificate signed by a well-known CA. - Certifique-se de que não utiliza a porta 80 com HTTPS e a porta 443 com HTTP nas Cápsulas.Make sure to not use port 80 with HTTPS and port 443 with HTTP on the Pods.
UtilizaçãoUsage
appgw.ingress.kubernetes.io/backend-protocol: "https"
ExemploExample
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: go-server-ingress-timeout
namespace: test-ag
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/backend-protocol: "https"
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: go-server-service
servicePort: 443