mirror of https://github.com/k3s-io/k3s
* 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>pull/3963/head v1.21.4-engine0+k3s1
parent
a4c8810e5d
commit
841793de01
|
@ -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