mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Fix condition for adding kubernetes endpoints (#3941)
* Fix condition for adding kubernetes endpoints Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com> * Fix condition for adding kubernetes endpoints Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
parent
4d6ddfea51
commit
933052a02c
@ -44,23 +44,17 @@ type handler struct {
|
||||
// This controller will update the version.program/apiaddresses etcd key with a list of
|
||||
// api addresses endpoints found in the kubernetes service in the default namespace
|
||||
func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) {
|
||||
if endpoint == nil {
|
||||
return nil, nil
|
||||
if endpoint != nil &&
|
||||
endpoint.Namespace == "default" &&
|
||||
endpoint.Name == "kubernetes" {
|
||||
w := &bytes.Buffer{}
|
||||
if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if endpoint.Namespace != "default" && endpoint.Name != "kubernetes" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
w := &bytes.Buffer{}
|
||||
if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return endpoint, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user