-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate kuberesolver into Buildbarn binaries
When running Buildbarn on bare metal Kubernetes clusters, it may not always be useful to set up things like kube-proxy, a CNI, or coredns. Just some plain kubelets that only run pods with 'hostNetwork: true' will do. Though very light-weight, it does make it a bit harder to establish network connections between individual components. It requires applications to do a 'kubectl get endpoints' against the API server to figure out the addresses of services are. This change does exactly that. It allows users to register a custom gRPC connection schema like kubernetes://${service}.${namespace}:${port} that automatically expands to the right set of systems.
- Loading branch information
1 parent
f52022c
commit a4267fc
Showing
8 changed files
with
321 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package global | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/sercand/kuberesolver/v5" | ||
) | ||
|
||
type simpleK8sClient struct { | ||
httpClient *http.Client | ||
url string | ||
} | ||
|
||
// newSimpleK8sClient creates a Kubernetes API server client for use | ||
// with kuberesolver. The implementation that ships with kuberesolver | ||
// makes strong assumptions about pathnames and environment variables. | ||
func newSimpleK8sClient(httpClient *http.Client, url string) kuberesolver.K8sClient { | ||
return &simpleK8sClient{ | ||
httpClient: httpClient, | ||
url: url, | ||
} | ||
} | ||
|
||
func (kc *simpleK8sClient) GetRequest(url string) (*http.Request, error) { | ||
return http.NewRequest(http.MethodGet, url, nil) | ||
} | ||
|
||
func (kc *simpleK8sClient) Do(req *http.Request) (*http.Response, error) { | ||
return kc.httpClient.Do(req) | ||
} | ||
|
||
func (kc *simpleK8sClient) Host() string { | ||
return kc.url | ||
} |
Oops, something went wrong.