- 
                Notifications
    
You must be signed in to change notification settings  - Fork 338
 
Edit CLUSTER_DOMAIN environment variable support #3283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…omains This change modifies the getClusterDomainName() function to prioritize the CLUSTER_DOMAIN environment variable over /etc/resolv.conf parsing, enabling explicit configuration of cluster domains. This is particularly useful when using service mesh configurations where the internal DNS domain (e.g., mesh.net) differs from the Kubernetes cluster domain. Changes: - Modified getClusterDomainName() to check CLUSTER_DOMAIN env var first - Falls back to /etc/resolv.conf parsing if env var is not set - Updated tests to validate precedence behavior - Added test cases for custom domain scenarios
| 
           Welcome @prashanthjos! It looks like this is your first PR to knative/pkg 🎉  | 
    
| 
           Hi @prashanthjos. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with  Once the patch is verified, the new status will be reflected by the  I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.  | 
    
| 
           We have a release next week and   | 
    
          
 Do you have an example on this can be setup with Istio?  | 
    
| 
           When using Istio with a custom mesh domain, we configured a ServiceEntry to route all internal service-to-service traffic through the Istio proxy instead of using Kubernetes default DNS resolution. With Default Kubernetes DNS all the services are accessed via ..svc.cluster.local, but however with custom mesh DNS through  Istio Interception: When one service calls another service in our mesh 
 Without the CLUSTER_DOMAIN environment variable, Knative components would: 
 We have required VS and DR (generated by our custom implementations of the Knative network spec) in place so that Knative components work as expected. We also created an issue to see how can use net-istio so that we don't write our own custom implementation but that is a long shot for us.  | 
    
          
 @dprotaso can we expect this to be merged next week?  | 
    
| 
           @dprotaso please do let me know if you have any questions. I would be happy to try any alternatives too before we can merge this PR.  | 
    
          
 Technically this isn't accurate - setting the env var now will take precedence over  Though this env var is being used in tests (#2092) so it's probably ok to tweak this.  | 
    
| 
           /ok-to-test  | 
    
| 
           /hold cancel  | 
    
        
          
                network/domain_test.go
              
                Outdated
          
        
      | }, { | ||
| name: "env variable with custom domain", | ||
| resolvConf: ``, | ||
| env: "custom.local", | ||
| want: "custom.local", | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems unnecessary - I say we drop it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I removed the test!
…omains This change modifies the getClusterDomainName() function to prioritize the CLUSTER_DOMAIN environment variable over /etc/resolv.conf parsing, enabling explicit configuration of cluster domains. This is particularly useful when using service mesh configurations where the internal DNS domain (e.g., mesh.net) differs from the Kubernetes cluster domain. Changes: - Modified getClusterDomainName() to check CLUSTER_DOMAIN env var first - Falls back to /etc/resolv.conf parsing if env var is not set - Updated tests to validate precedence behavior - Added test cases for custom domain scenarios
| 
           /lgtm  | 
    
| 
           [APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, prashanthjos The full list of commands accepted by this bot can be found here. The pull request process is described here 
Needs approval from an approver in each of these files:
 
      
 Approvers can indicate their approval by writing   | 
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@            Coverage Diff             @@
##             main    #3283      +/-   ##
==========================================
- Coverage   74.96%   74.58%   -0.39%     
==========================================
  Files         188      188              
  Lines       10263     8184    -2079     
==========================================
- Hits         7694     6104    -1590     
+ Misses       2330     1840     -490     
- Partials      239      240       +1     ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
  | 
    
Description
This PR changes support for the
CLUSTER_DOMAINenvironment variable to allow explicit configuration of the cluster domain, taking precedence over/etc/resolv.confparsing.Motivation
When using custom service mesh configurations (e.g., Istio with custom domains), the internal DNS domain may differ from the Kubernetes cluster domain. Currently, Knative derives the cluster domain by parsing
/etc/resolv.conf, which doesn't work in these scenarios.For example, a service mesh might use
mesh.netinternally while Kubernetes usescluster.local. This PR enables users to explicitly set the cluster domain via environment variable.Changes
network/domain.go : Modified getClusterDomainName() to check
CLUSTER_DOMAINenvironment variable first, then fall back to /etc/resolv.conf parsingRelease Note
Edit CLUSTER_DOMAIN environment variable support to allow explicit configuration of cluster domain for custom service mesh configurations.