Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment désactiver et réactiver la fonctionnalité de certificats TLS gérés, qui fournit et renouvelle automatiquement les certificats TLS afin d'accepter les connexions HTTPS sur Knative serving.
Si vous souhaitez utiliser HTTPS :
Votre conteneur doit continuer à écouter sur le port $PORT.
Vous devez choisir la manière dont vous fournissez les certificats TLS :
Utiliser des certificats TLS gérés : dans ce cas, les certificats TLS sont créés automatiquement si nécessaire, et ils sont également renouvelés automatiquement. La présente page décrit cette fonctionnalité, qui est disponible dans les versions Google Kubernetes Engine compatibles.
Utiliser vos propres certificats : dans ce cas, il vous incombe d'obtenir et de renouveler des certificats. Dans certains contextes, décrits dans la section Limites, vous devez utiliser vos propres certificats.
Si vous utilisez des certificats gérés, vous devez également mapper votre domaine personnalisé afin d'utiliser la fonctionnalité de certificats gérés.
Utiliser HTTPS et HTTP
Par défaut, si vous utilisez des certificats gérés, les clusters ou les services Knative serving avec certificats gérés sont exposés au trafic HTTP et HTTPS.
Si vous souhaitez autoriser uniquement le trafic HTTPS, vous pouvez activer les redirections HTTPS pour forcer l'ensemble du trafic à utiliser HTTPS.
Les points suivants doivent être pris en compte pour l'utilisation de la fonctionnalité de certificats TLS gérés :
Les certificats TLS gérés sont désactivés et ne sont pas compatibles avec les clusters privés de Knative serving sur Google Cloud.
Pour utiliser la fonctionnalité de certificats gérés, votre service doit être exposé en externe : il ne peut pas s'agir d'un service local au cluster ni d'un service exposé par le cloud privé virtuel.
La fonctionnalité de certificats gérés ne fonctionne qu'avec Cloud Service Mesh. Le module complémentaire Istio ou d'autres configurations Istio ne sont pas compatibles.
Cette fonctionnalité utilise Let's Encrypt, dont la limite de quota initiale est de 50 certificats TLS par semaine et par domaine enregistré. Vous pouvez demander une augmentation du quota en suivant la documentation de Let's Encrypt.
Lorsque vous exécutez un cluster de diffusion Knative sur d'autres plates-formes, telles qu'une plate-forme sur site ou AWS, cette fonctionnalité est désactivée. Pour utiliser cette fonctionnalité, vous devez vous assurer que votre cluster peut accéder à Let's Encrypt et que votre service d'entrée Cloud Service Mesh est exposé à l'Internet public.
Avant de commencer
Les instructions figurant sur cette page présupposent ce qui suit :
Vous possédez un domaine. Si vous n'en avez pas, vous pouvez en obtenir un auprès de Google ou d'un autre fournisseur de domaine.
Vous avez créé un mappage de domaine pour votre service et avez mis à jour votre enregistrement DNS en suivant les instructions de la page concernant le mappage de domaines.
Sinon, utilisez Cloud DNS ou un serveur DNS de votre choix.
Désactiver les certificats TLS gérés et HTTPS pour l'intégralité d'un cluster
Pour désactiver les certificats TLS gérés pour un cluster, mettez à jour le fichier ConfigMap config-domainmapping :
Assurez-vous que le protocole HTTPS ne fonctionne pas :
curlhttps://DOMAIN
Assurez-vous que le protocole HTTP est utilisé pour le service :
gcloudrundomain-mappingsdescribe--domainDOMAIN
Remplacez DOMAIN par votre propre nom de domaine, par exemple your-domain.com.
Vérifiez le champ url: dans le résultat de la commande ci-dessus : l'URL doit afficher http, et non https.
Réactiver les certificats TLS gérés et HTTPS
Pour réactiver la fonctionnalité de certificats TLS gérés, procédez comme suit :
Si vous ne l'avez pas déjà fait, créez un mappage de domaine pour votre service et mettez à jour votre enregistrement DNS en suivant les instructions de la page concernant le mappage de domaines.
Activez les certificats TLS gérés et HTTPS en mettant à jour le fichier ConfigMap config-domainmapping :
Attendez quelques minutes que la commande aboutisse, puis assurez-vous que la fonctionnalité de certificats est opérationnelle :
kubectlgetkcert
Si le certificat est prêt, un message de ce type doit s'afficher :
NAMEREADYREASON
your-domain.comTrue
Il peut s'écouler entre 20 secondes et 2 minutes avant que le certificat Kcert ne soit prêt. Si vous rencontrez des problèmes, consultez les instructions de dépannage concernant cette fonctionnalité.
Vérifier la réussite de l'opération
Vérifiez que l'enregistrement DNS est activé en exécutant la commande suivante :
gcloudrundomain-mappingsdescribe--domainDOMAIN
Remplacez DOMAIN par votre propre nom de domaine, par exemple your-domain.com.
Vérifiez le champ url: dans le résultat de la commande ci-dessus : l'URL doit afficher https, et non http.
Vérifiez l'adresse IP dans la commande ci-dessus, répertoriée sous resourceRecords:rrdata, et comparez-la à la valeur affichée lors de l'exécution de la commande host DOMAIN. Elles doivent être identiques.
Activer les redirections HTTPS pour le service Knative
Si vous utilisez la fonctionnalité de certificats TLS gérés, le cluster est par défaut exposé au trafic HTTP et HTTPS pour des raisons de rétrocompatibilité. Si vous souhaitez forcer l'ensemble du trafic à utiliser HTTPS, vous pouvez activer les redirections HTTPS pour un mappage de domaine existant en appelant la commande suivante :
Consultez la section Résoudre les problèmes liés aux certificats TLS gérés pour en savoir plus sur la vérification des mappages de domaines, des quotas de certificats, de l'état des commandes, des délais avant expiration des commandes et des échecs d'autorisation.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/31 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/08/31 (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."]]