You are adding the annotations in the Service, but checking on the pods. Add them to the template section in websocket-replication-controller.yaml to get the pods created from this controller annotated.
/MR On Wed, May 24, 2017, 16:36 <ijunaidsubh...@gmail.com> wrote: > My Kubernetes versions is :: > > # kubectl --version > Kubernetes v1.4.0 > > > I am planning to use prometheus to monitor my Kube cluster. For this, I > need to annotate the metrics URL. > > My current metrics URL is like : > > http://172.16.33.7:8080/metrics > > But I want it like : > > http://172.16.33.7:8080/websocket/metrics > > First I tried to do this manually :: > > kubectl annotate pods > websocket-backend-controller-db83999c5b534b277b82badf6c152cb9m1 > prometheus.io/path=/websocket/metrics > kubectl annotate pods > websocket-backend-controller-db83999c5b534b277b82badf6c152cb9m1 > prometheus.io/scrape='true' > kubectl annotate pods > websocket-backend-controller-db83999c5b534b277b82badf6c152cb9m1 > prometheus.io/port='8080' > > All these commands work perfectly fine and I am able to see the > annotations. > > { > "metadata": { > "name": "websocket-backend-controller-v1krf", > "generateName": "websocket-backend-controller-", > "namespace": "default", > "selfLink": > "/api/v1/namespaces/default/pods/websocket-backend-controller-v1krf", > "uid": "e323994b-4081-11e7-8bd0-0050569b6f44", > "resourceVersion": "27534379", > "creationTimestamp": "2017-05-24T13:07:06Z", > "labels": { > "name": "websocket-backend" > }, > "annotations": { > "kubernetes.io/created-by": > "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"websocket-backend-controller\",\"uid\":\"e321f1a8-4081-11e7-8bd0-0050569b6f44\",\"apiVersion\":\"v1\",\"resourceVersion\":\"27531840\"}}\n", > "prometheus.io/path": "/websocket/metrics", > "prometheus.io/port": "8080", > "prometheus.io/scrape": "true" > } > > But since I want these configs to remain permanent, I am configuring them > in my services files. > > # cat websocket-service.yaml > apiVersion: v1 > kind: Service > metadata: > name: websocket-service > labels: > baseApi: websocket > annotations: > prometheus.io/scrape: 'true' > prometheus.io/path: /websocket/metrics > prometheus.io/port: '8080' > spec: > selector: > name: websocket-backend > ports: > - port: 8080 > targetPort: 8080 > nodePort: 30800 > protocol: TCP > type: NodePort > clusterIP: 10.100.10.45 > > I restarted my websocket service and the corresponding pods but these > configs dont seem to be taking effect. > > kubectl create -f websocket-service.yaml > kubectl create -f ../controllers/websocket-replication-controller.yaml > > The result does not show the annotations configured. > > { > "metadata": { > "name": "websocket-backend-controller-v1krf", > "generateName": "websocket-backend-controller-", > "namespace": "default", > "selfLink": > "/api/v1/namespaces/default/pods/websocket-backend-controller-v1krf", > "uid": "e323994b-4081-11e7-8bd0-0050569b6f44", > "resourceVersion": "27531879", > "creationTimestamp": "2017-05-24T13:07:06Z", > "labels": { > "name": "websocket-backend" > }, > "annotations": { > "kubernetes.io/created-by": > "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"websocket-backend-controller\",\"uid\":\"e321f1a8-4081-11e7-8bd0-0050569b6f44\",\"apiVersion\":\"v1\",\"resourceVersion\":\"27531840\"}}\n" > } > > All Im doing is rather than using a command line, I am setting the configs > using services config but it does not seem to be working. > > -- > 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. > -- 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.