Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se muestra cómo desactivar y volver a habilitar la función de certificados TLS administrados que proporciona y renueva de forma automática los certificados TLS para admitir conexiones HTTPS en Knative serving.
Si quieres usar HTTPS, debe suceder lo siguiente:
Tu contenedor debería seguir escuchando en $PORT.
Debes elegir la forma en la que proporcionas certificados TLS:
Usa certificados TLS administrados, en los que los certificados TLS se crean y renuevan de forma automática según sea necesario. En esta página, se describe esta función que está disponible en las versiones compatibles de Google Kubernetes Engine.
Usa tus propios certificados. Si eliges esta opción, serás responsable de obtener y renovar los certificados. En algunas situaciones, descritas en Limitaciones, debes usar tus propios certificados.
Para usar la función de certificados administrados, también debes asignar tu dominio personalizado si usas certificados administrados.
Usa HTTPS y HTTP
De forma predeterminada, si usas certificados administrados, los clústeres o servicios de Knative serving con dichos certificados se exponen al tráfico HTTP y HTTPS.
Si solo deseas tráfico HTTPS, puedes habilitar los redireccionamientos a HTTPS para forzar el uso de HTTPS en todo el tráfico.
Las siguientes consideraciones se aplican al uso de la función de certificados TLS administrados:
Los certificados TLS administrados están inhabilitados y no son compatibles con los clústeres privados de Knative serving en Google Cloud.
Para usar la función de certificados administrados, tu servicio debe estar expuesto de manera externa; no puede ser un servicio local de clúster ni uno que expone la nube privada virtual.
La función de certificados administrados solo funciona con Cloud Service Mesh. No se admiten el complemento ni otras opciones de configuración de Istio.
Esta función usa Let's Encrypt, que tiene un límite de cuota inicial de 50 certificados TLS por semana, por dominio registrado. Para solicitar un aumento de la cuota, sigue los pasos que se indican en la documentación de Let's Encrypt.
Cuando se ejecuta un clúster de Knative serving en otras plataformas, como una local o AWS, esta función se inhabilita. Para usar esta función, debes asegurarte de que el clúster pueda acceder a Let's Encrypt y que tu servicio de entrada de Cloud Service Mesh esté expuesto en la Internet pública.
Antes de comenzar
En las instrucciones de esta página, se supone lo siguiente:
Reemplaza DOMAIN por el nombre de tu dominio, por ejemplo: your-domain.com.
Verifica el campo url: en el resultado del comando anterior. La URL debe contener http, no https.
Vuelve a habilitar los certificados TLS administrados y HTTPS
Para volver a habilitar TLS administrados, sigue estos pasos:
Si aún no lo hiciste, crea una asignación de dominio para el servicio y actualiza el registro DNS según las instrucciones de la página de asignación de dominios.
Actualiza el ConfigMap config-domainmapping para activar los certificados TLS administrados y HTTPS:
Espera unos minutos después de que el comando se ejecute de forma correcta. Luego, asegúrate de que la función de certificados funcione:
kubectlgetkcert
Si el certificado está listo, deberías ver un mensaje similar al siguiente:
NAMEREADYREASON
your-domain.comTrue
Es posible que transcurran entre 20 segundos y 2 minutos hasta que el Kcert esté listo. Si tienes algún problema, consulta las instrucciones para solucionar problemas de esta función.
Verifica si se realizó de forma correcta
Ejecuta el siguiente comando para verificar que el registro DNS haya entrado en vigor:
gcloudrundomain-mappingsdescribe--domainDOMAIN
Reemplaza DOMAIN por el nombre de tu dominio, por ejemplo: your-domain.com.
Verifica el campo url: en el resultado del comando anterior. La URL debe contener https, no http.
Verifica la dirección IP del comando anterior, que aparece en resourceRecords:rrdata, y compárala con el valor que ves cuando ejecutas el comando host DOMAIN. Deberían ser iguales.
Habilita redireccionamientos HTTPS para Knative serving
Si usas la función de certificados TLS administrados, de forma predeterminada, el clúster se expone al tráfico HTTP y HTTPS por motivos de retrocompatibilidad. Si deseas forzar el uso de HTTPS en todo el tráfico, puedes habilitar los redireccionamientos a HTTPS para una asignación de dominio existente mediante la invocación del siguiente comando:
En el ejemplo anterior, DOMAIN es el nombre de la asignación de dominio.
Temas relacionados
Consulta Solución de problemas de TLS administrados para obtener información sobre cómo verificar las asignaciones de dominios, las cuotas de certificados, el estado y los tiempos de espera de pedidos, y los errores de autorización.
Consulta Usa tus propios certificados TLS si deseas obtener instrucciones para usar tus propios certificados TLS en lugar de los administrados.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2024-11-21 (UTC)"],[],[],null,["# Using managed TLS certificates and HTTPS\n\nThis page shows how to turn off and re-enable the managed TLS certificates feature that automatically provides and renews TLS certificates to support HTTPS connections on Knative serving.\n\n\u003cbr /\u003e\n\nIf you want to use HTTPS,\n\n- Your container should continue listening on `$PORT`\n- You must choose how you are supplying TLS certificates:\n\n - Use managed TLS certificates, where TLS certificates are automatically created as needed, and are automatically renewed. This page describes this feature, which is available in the [supported Google Kubernetes Engine versions](/kubernetes-engine/enterprise/knative-serving/docs/cluster-versions).\n - [Use your own certificates](/kubernetes-engine/enterprise/knative-serving/docs/bring-your-own-cert), where you are responsible for obtaining and renewing certificates. In some situations, described under [Limitations](#limitations), you must use your own certificates.\n- If you are using managed certificates, you must also\n [map your custom domain](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains) in order to use the\n managed certificates feature.\n\nUsing HTTPS and HTTP\n--------------------\n\nBy default, if you use managed certificates, clusters or Knative serving\nservices with managed certificates are exposed to both HTTP and HTTPS traffic.\nIf you want only HTTPS traffic, you can [enable HTTPS redirects](#redirects) to\nforce all traffic to use HTTPS only.\n\nTroubleshooting\n---------------\n\nIf you experience issues when using managed TLS certificates, refer to the\n[managed TLS troubleshooting](/kubernetes-engine/enterprise/knative-serving/docs/troubleshooting#managed-tls) page.\n\nLimitations\n-----------\n\nThe following considerations apply to the use of the managed TLS certificates\nfeature:\n\n- Managed TLS certificates are disabled and not supported for Knative serving private clusters on Google Cloud.\n- To use the managed certificates feature, your service must be [exposed externally](/kubernetes-engine/enterprise/knative-serving/docs/managing/services#connectivity): it cannot be a cluster-local service or a service exposed by [Virtual Private Cloud](/vpc).\n- The managed certificates feature works only with Cloud Service Mesh. The Istio addon or other Istio configurations are not supported.\n- This feature uses [Let's Encrypt](https://letsencrypt.org/), which has an initial quota limit of 50 TLS certificates per week per registered domain. You can ask for a quota increase by following the [Let's Encrypt documentation](https://letsencrypt.org/docs/rate-limits/).\n- When running a Knative serving cluster on other platforms, such as on-prem or AWS, this feature is disabled. To use this feature, you must make sure your cluster is able to access [Let's Encrypt](https://acme-v02.api.letsencrypt.org/directory), and your Cloud Service Mesh ingress service is exposed to the public internet.\n\nBefore you begin\n----------------\n\nThe instructions on this page assume the following:\n\n- You have [deployed your Knative serving service](/kubernetes-engine/enterprise/knative-serving/docs/deploying) to the cluster.\n- You own a domain. If you don't have a domain, you can obtain one from [Google](https://domains.google/) or from another domain vendor.\n- You created a domain mapping for your service and updated your DNS record accordingly following the instructions at the [domains mapping page](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains).\n- Use [Cloud DNS](/dns/docs/set-up-dns-records-domain-name), or a DNS server of your choice.\n\n| **Note:** By default, `gke-system-gateway` supports HTTP requests that have the Host header. However, if you have customized this gateway, make sure it still accepts the HTTP requests that contain the Host header.\n\nDisabling managed TLS certificates and HTTPS for a whole cluster\n----------------------------------------------------------------\n\nDisable managed TLS for a cluster by updating the ConfigMap\n`config-domainmapping`:\n\n\u003cbr /\u003e\n\n```bash\nkubectl patch cm config-domainmapping -n knative-serving -p '{\"data\":{\"autoTLS\":\"Disabled\"}}'\n```\n\n\u003cbr /\u003e\n\nDisabling managed TLS and HTTPS for a specific domain mapping\n-------------------------------------------------------------\n\nIf needed, you can turn off managed TLS for a specific domain mapping:\n\n1. Add the annotation `domains.cloudrun.com/disableAutoTLS: \"true\"`\\`:\n\n ```bash\n kubectl annotate domainmappings DOMAIN domains.cloudrun.com/disableAutoTLS=true\n ```\n2. Verify that HTTPS does not work:\n\n ```bash\n curl https://DOMAIN\n ```\n\n \u003cbr /\u003e\n\n3. Verify that HTTP is being used for the service:\n\n ```bash\n gcloud run domain-mappings describe --domain DOMAIN\n ```\n\n Replace \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e with your own domain name, for example:\n `your-domain.com`\n\n Check the `url:` field in the return from the above command: the URL should\n have `http`, not `https`.\n\nRe-enabling managed TLS certificates and HTTPS\n----------------------------------------------\n\nTo re-enable managed TLS:\n\n1. If you haven't already done so, create a domain mapping for your service and\n update your DNS record accordingly following the instructions at the\n [domains mapping page](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains).\n\n2. Turn on managed TLS certificates and HTTPS by updating the ConfigMap\n `config-domainmapping`:\n\n ```bash\n kubectl patch cm config-domainmapping -n knative-serving -p '{\"data\":{\"autoTLS\":\"Enabled\"}}'\n ```\n3. Wait for a few minutes after the command succeeds, then make sure the\n certificates feature is working:\n\n ```bash\n kubectl get kcert\n ```\n\n If the certificate is ready, you should see a message similar to this one: \n\n ```bash\n NAME READY REASON\n your-domain.com True\n ```\n\n It may take from 20 seconds to 2 minutes for the `Kcert` to become ready. If\n you experience any issues, see the\n [troubleshooting instructions](/kubernetes-engine/enterprise/knative-serving/docs/troubleshooting) for this\n feature.\n\n### Verifying success\n\n1. Verify that the DNS record has gone into effect by running the command:\n\n ```bash\n gcloud run domain-mappings describe --domain DOMAIN\n ```\n\n Replace \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e with your own domain name, for example:\n `your-domain.com`\n2. Check the `url:` field in the return from the above command: the URL should\n have `https`, not `http`.\n\n3. Check the IP address from the above command, listed under\n `resourceRecords:rrdata`, and compare it to the value you see when you execute\n the command `host `\u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e. They should be the same.\n\nEnabling HTTPS redirects for Knative serving\n--------------------------------------------\n\n| **Important:** HTTPS redirect is available for cluster version `1.17.7-gke.8` and later.\n\nIf you use the managed TLS certificates feature, by default the cluster is\nexposed to both HTTP and HTTPS traffic for backwards compatibility reasons. If\nyou want to force all traffic to use HTTPS only, you can enable HTTPS redirects\nfor [an existing domain mapping](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains) by invoking\nthe command \n\n kubectl annotate domainmappings \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e domains.cloudrun.com/httpsRedirect=Enabled\n\nwhere \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e is the name of the domain mapping.\n\nRelated topics\n--------------\n\n- [Troubleshooting managed TLS](/kubernetes-engine/enterprise/knative-serving/docs/troubleshooting#managed-tls) for details on checking domain mappings, certificate quotas, order status and order timeouts, and authorization failures.\n- [Bring your own TLS certificates](/kubernetes-engine/enterprise/knative-serving/docs/bring-your-own-cert) for instructions on using your own TLS certificates instead of the managed TLS certificates."]]