• Kubernetes Submit Queue's avatar
    Merge pull request #62497 from MrHohn/endpoint-controller-headless-ports · dfba1c1f
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
    Fix a bug that headless service without ports fails to have endpoint created.
    
    **What this PR does / why we need it**:
    Follow up of https://github.com/kubernetes/kubernetes/pull/47250. Headless service without ports fails to have corresponding endpoint created because endpoint controller deliberately attaches a dummy endpointPort with portNum=0, which will fail API validation check. Error as below:
    ```
    endpoints_controller.go:375] Error syncing endpoints for service "default/XXX": Endpoints "XXX" is invalid: subsets[0].ports[0].port: Invalid value: 0: must be between 1 and 65535, inclusive
    ```
    
    This PR makes endpoint controller not attach the dummy endpointPort for headless service.
    
    **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
    Fixes #55158, fixes #62440 
    
    **Special notes for your reviewer**:
    cc @xiangpengzhao 
    
    **Release note**:
    
    ```release-note
    Fix a bug that headless service without ports fails to have endpoint created.
    ```
    dfba1c1f
endpoints_controller_test.go 36.5 KB