[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Using test domains\n\nLearn how to access the Knative serving services in your cluster for testing\npurposes before you choose to\n[map a custom domain](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains).\n\nBy default, the services that you deploy to your Knative serving clusters are\nset to the `nip.io` base domain. Therefore, if you use the recommended name for\ningress gateway, you can immediately test your services and send requests\nwithout additional configuration. For example:\n`http://{SERVICE_NAME}.{NAMESPACE}.kuberun.{EXTERNAL_IP}.nip.io`.\n| **Important:** For production, you must [map a custom domain](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains), which is also required to enable HTTPS and [use automatic TLS certificates](/kubernetes-engine/enterprise/knative-serving/docs/managed-tls).\n\nNote that there can be\n[issues around the reliability of requests](https://en.wikipedia.org/wiki/Wildcard_DNS_record)\nwhen using DNS wildcards, including the [nip.io](http://nip.io/) domain, which\nis a free DNS wildcard service. In contrast, setting up and using a\n[custom domain](/kubernetes-engine/enterprise/knative-serving/docs/mapping-custom-domains) for testing can offer\nincreased reliability.\n\nOptionally, you can also access your services through the\n[external IP address](#externalip).\n\nUsing the `nip.io` test domain\n------------------------------\n\nTo access a service using the default `nip.io` base domain, you can locate the\nURL from within the Google Cloud console or you can construct the URL manually. \n\n### Console\n\n1. In the Google Cloud console, go to the **Knative serving** page.\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. In the list, click the service for which you want to obtain the URL.\n\n3. Near the top of the page the **URL** is displayed.\n\n For example: `http://my-service.default.kuberun.11.111.11.111.nip.io`\n\n Where *my-service* is the name of the Knative serving service, *default*\n is the namespace, and *11.111.11.111* is the IP address of your external\n load balancer.\n\n### Manually\n\nTo manually construct the URL to your service, you use the name of the\nservice, the namespace in which that service is running, and the IP address\nof your load balancer: \n\n http://\u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e.\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e.kuberun.\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e.nip.io\n\nReplace:\n\n- \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name of your service.\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e with the namespace where you deployed the service. By default, services are deployed to the `default` namespace.\n- \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e with the [external IP address](#external_ip) of your load balancer.\n\nFor example, if you have a service named `hello` in the `default` namespace\nand your external IP address is `12.345.67.890`, the URL might look like:\n\n`http://hello.default.kuberun.12.345.67.890.nip.io`\n\nUsing the external IP address\n-----------------------------\n\nOptionally, you can use the external IP address of your load balancer to access\nyour services through\n[cURL](https://curl.se/docs/manpage.html) commands or by\nmanually configuring an alternative DNS wildcard service.\n\n### Before you begin\n\n- Ensure that your Google Cloud CLI and kubectl command-line tools are installed and\n up-to-date:\n\n - [GKE clusters on Google Cloud](/kubernetes-engine/enterprise/knative-serving/docs/install/on-gcp/command-line-tools)\n - [GKE clusters outside Google Cloud](/kubernetes-engine/enterprise/knative-serving/docs/install/outside-gcp/command-line-tools)\n- You must have at least the\n [*Kubernetes Engine Developer*](/kubernetes-engine/docs/how-to/iam#roles)\n Identity and Access Management role or equivalent permissions.\n\n### Getting the external IP address\n\nWhen your GKE Enterprise cluster is created, the Istio ingress controller\ncreates a Google Cloud Network Load Balancer with a publicly available\nIP address.\n\nTo configure access to your service with cURL or a DNS service, you must first\nobtain the external IP address of the load balancer service: \n\n### Console\n\nTo get the load balancer's external IP address from the Google Cloud console:\n\n1. Go to the GKE page in the Google Cloud console: \n [Go to GKE](https://console.cloud.google.com/kubernetes)\n2. Click **Services and ingress**.\n3. Identify the service that is your cluster's Istio ingress. The service's **Type** will be **External load\n balancer** , and the **Name** will be `istio-ingressgateway`.\n4. Once you've found your cluster's Istio ingress service, copy its **Endpoint** . This will be the IP address without the port number. For example, you might see `00.000.000.000:11` listed as an endpoint, but you only need to copy `00.000.000.000`.\n\n### kubectl\n\nTo obtain the external IP for the Load Balancer, run the following command: \n\n```bash\nkubectl get svc istio-ingressgateway -n ASM-INGRESS-NAMESPACE\n```\n\nReplace \u003cvar translate=\"no\"\u003eASM-INGRESS-NAMESPACE\u003c/var\u003e with the namespace where your\nCloud Service Mesh ingress is located. Specify `istio-system` if you\ninstalled Cloud Service Mesh using its default configuration.\n\nThe resulting output looks similar to the following: \n\n```bash\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)\nistio-ingressgateway LoadBalancer XX.XX.XXX.XX pending 80:32380/TCP,443:32390/TCP,32400:32400/TCP\n```\n\nwhere the **EXTERNAL-IP** value is your external IP address of the Load\nBalancer.\n\nAfter obtaining the external IP address of your load balancer, you can use it\nto in cURL commands or with a DNS wildcard service to access your\nKnative serving services.\n\n### Using `cURL`\n\nYou can use [cURL](https://curl.se/docs/manpage.html)\ncommands with the default `nip.io` base domain to send requests to\nyour service.\n\nYou specify the external IP address of your load balancer along with\nthe names of your service and namespace in the cURL command: \n\n```bash\ncurl --header 'Host: \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e.kuberun.\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e.nip.io' EXTERNAL_IP\n```\n\nReplace:\n\n- \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e with the name of your Knative serving service.\n- \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e with the namespace in which your service is running.\n- \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e with the [external IP address](#external_ip) of your load balancer.\n\nExample:\n\n`curl --header 'Host: my-service.default.kuberun.12.345.67.890.nip.io' http://12.345.67.890`\n\n### Using other DNS wildcard services\n\nBy default, your Knative serving services use the [nip.io](http://nip.io/) DNS\nwildcard service. However, you can choose to use other services like\n[sslip.io](https://sslip.io/). To configure other DNS wildcard services\nyou must first obtain the [external IP address](#external_ip) of your load\nbalancer and then use that IP address to configure the DNS wildcard service.\n\n#### Configuring your cluster's domain\n\nKnative serving uses the `config-domain` ConfigMap to define the base\ndomain for which all your deployed Knative serving services use. You can\nupdate that ConfigMap through the Google Cloud console or with `kubectl` commands. \n\n### Console\n\nTo change the default base domain from `nip.io` to one of the DNS\nwildcard services in the Google Cloud console:\n\n1. Go to the Knative serving **Domain mappings** page in the\n Google Cloud console:\n\n [Go to Domain mappings](https://console.cloud.google.com/kubernetes/run/domains)\n2. Select **Add mapping \\\u003e Add cluster default domain**\n\n3. Select the checkbox next to \"Apply this domain mapping to all\n Knative serving services deployed to this cluster.\"\n\n4. Select your cluster from the drop-down menu.\n\n5. In the **Domain** field, enter the wildcard DNS site you want to use. For\n example: `sslip.io`\n\n### kubectl\n\nTo change the default base domain from `nip.io` to one of the DNS\nwildcard sites, use the command: \n\n```bash\nkubectl patch configmap config-domain --namespace knative-serving --patch \\\n '{\"data\": {\"kuberun.\u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e.nip.io\": null, \"\u003cvar translate=\"no\"\u003eDNS_SERVICE\u003c/var\u003e\": \"\"}}'\n```\n\nReplace\n\n- \u003cvar translate=\"no\"\u003eEXTERNAL_IP\u003c/var\u003e with the Load Balancer [external IP address](#external_ip).\n- \u003cvar translate=\"no\"\u003eDNS_SERVICE\u003c/var\u003e with the wildcard DNS site you are using. For example: `sslip.io`\n\nYour service is now available at\n`http://{SERVICE_NAME}.{NAMESPACE}.kuberun.{EXTERNAL_IP}.{DNS_SERVICE}`."]]