-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement service health check in Antrea-agent (#4120)
When services are created with "externalTrafficPolicy: Local", a "healthCheckNodePort" is created in the k8s service object. kube-proxy in turn will listen on this port and answer queries on http://0.0.0.0:healthCheckNodePort/healthz". In kube-proxy replacement mode, antrea does not support this feature. This becomes more important for Windows support as userspace kube-proxy is being deprecated. This commit implements this feature in Antrea and is inspired by the same feature in upstream kube-proxy with some differences. The predominant difference is that upstream kube-proxy goes through all endpoints of cluster in each iteration of endpoints:update() to find the local endpoints. This has been changed here to only look for changed endpoints. Signed-off-by: Guru Shetty <[email protected]>
- Loading branch information
Showing
9 changed files
with
434 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package proxy/healthcheck is copied from [k8s.io/kubernetes@/v1.24.4](https://github.com/kubernetes/kubernetes/tree/v1.24.4) to avoid importing the whole kubernetes repo. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2016 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package healthcheck | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
) | ||
|
||
// listener allows for testing of ServiceHealthServer and ProxierHealthServer. | ||
type listener interface { | ||
// Listen is very much like net.Listen, except the first arg (network) is | ||
// fixed to be "tcp". | ||
Listen(addr string) (net.Listener, error) | ||
} | ||
|
||
// httpServerFactory allows for testing of ServiceHealthServer and ProxierHealthServer. | ||
type httpServerFactory interface { | ||
// New creates an instance of a type satisfying HTTPServer. This is | ||
// designed to include http.Server. | ||
New(addr string, handler http.Handler) httpServer | ||
} | ||
|
||
// httpServer allows for testing of ServiceHealthServer and ProxierHealthServer. | ||
// It is designed so that http.Server satisfies this interface, | ||
type httpServer interface { | ||
Serve(listener net.Listener) error | ||
} | ||
|
||
// Implement listener in terms of net.Listen. | ||
type stdNetListener struct{} | ||
|
||
func (stdNetListener) Listen(addr string) (net.Listener, error) { | ||
return net.Listen("tcp", addr) | ||
} | ||
|
||
var _ listener = stdNetListener{} | ||
|
||
// Implement httpServerFactory in terms of http.Server. | ||
type stdHTTPServerFactory struct{} | ||
|
||
func (stdHTTPServerFactory) New(addr string, handler http.Handler) httpServer { | ||
return &http.Server{ | ||
Addr: addr, | ||
Handler: handler, | ||
} | ||
} | ||
|
||
var _ httpServerFactory = stdHTTPServerFactory{} |
Oops, something went wrong.