As the value for `control-plane.alpha.kubernetes.io/leader` is the output 
of json marshal. So, you can not just use the kubectl command line `kubectl 
-s http://APISERVER --namespace=kube-system get endpoints 
kube-controller-manager -o 
jsonpaata.annotations.control-plane\.alpha\.kubernetes\.io/leader}'` to 
extract. But be using `jq` you can do this `kubectl -s http://APISERVER 
--namespace=kube-system get endpoints kube-controller-manager -o 
jsonpath='{.metadata.annotations.control-plane\.alpha\.kubernetes\.io/leader}'|jq
 
'.holderIdentity'`

在 2017年7月1日星期六 UTC+8上午3:24:20,Junaid Subhani写道:
>
> Hello Jerzy ,
>
> Is there a much more direct way to get just the value of *holderIdentity *
> ?
>
> My request :
>
> http://
> 172.29.240.172:8080/api/v1/namespaces/kube-system/endpoints/kube-controller-manager
>
> This gives me :
>
> { "kind": "Endpoints", "apiVersion": "v1", "metadata": { "name": 
> "kube-controller-manager", "namespace": "kube-system", "selfLink": 
> "/api/v1/namespaces/kube-system/endpoints/kube-controller-manager", "uid": 
> "89e09aae-5dc6-11e7-89c1-0050569b569d", "resourceVersion": "19152", 
> "creationTimestamp": "2017-06-30T19:01:35Z", "annotations": { 
> "control-plane.alpha.kubernetes.io/leader": 
> "{\"holderIdentity\":\"master2\",\"leaseDurationSeconds\":15,\"acquireTime\":\"2017-06-30T19:01:35Z\",\"renewTime\":\"2017-06-30T19:18:01Z\",\"leaderTransitions\":0}"
>  } }, "subsets": [] }
>
> I basically need to configure HAProxy based on the value of holderIdentity
>
>
>
> On Tuesday, 14 February 2017 09:18:54 UTC-5, Jerzy Szczepkowski wrote:
>>
>> You can get it from endpoints resource. The endpoint should have an 
>> annotation pointing to the leader.
>>
>> $ kubectl get endpoints kube-controller-manager --namespace=kube-system 
>>  -o yaml
>>
>> apiVersion: v1
>> kind: Endpoints
>> metadata:
>>   annotations:
>>     *control-plane.alpha.kubernetes.io/leader 
>> <http://control-plane.alpha.kubernetes.io/leader>*: '{"holderIdentity":"
>> *kubernetes-master*
>> ","leaseDurationSeconds":15,"acquireTime":"2017-02-14T14:05:57Z","renewTime":"2017-02-14T14:14:42Z","leaderTransitions":0}'
>> ...
>>
>>
>> Regards,
>> Jerzy
>>
>> On Tue, Feb 14, 2017 at 2:27 PM, Qian Zhang <zhq5...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have a Kubernetes HA cluster which consists of 3 master nodes, each of 
>>> them has kube-apiserver, kube-scheduler and kube-controller-manager 
>>> running, and kube-scheduler and kube-controller-manager are started with 
>>> the option "--leader-elect", my question is, is there a way to tell the 
>>> current leader of kube-scheduler/kube-controller-manager? E.g., a 
>>> Kubernetes API to get such info? Or directly get it from etcd?
>>>
>>>
>>> Thanks,
>>> Qian Zhang
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Kubernetes user discussion and Q&A" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to kubernetes-use...@googlegroups.com.
>>> To post to this group, send email to kubernet...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to kubernetes-users+unsubscr...@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to