tczekajlo / kube-consul-register

a tool to register Kubernetes PODs as Consul Services
Apache License 2.0
105 stars 50 forks source link

Possibility to specify tags? #14

Closed cabrinoob closed 6 years ago

cabrinoob commented 7 years ago

Hi, Is it possible to specify tags while registering services in consul? I'am familiar with registrator (gliderlabs/registrator) in which you can set a SERVICE_TAGS label to specify a tag list to use in consul. Ex: SERVICE_TAGS="dev,1.0.0"

Thank you

tczekajlo commented 7 years ago

Hi, Yes, it's possible. Here you can find an example. The rule is simple, every label (key) which has a value equal to "tag" will be added as a tag.

jameshartig commented 6 years ago

I have a pod defined as part of a statefulset like so:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: cockroachdb
  namespace: production
  labels:
    app: cockroachdb
spec:
  serviceName: cockroachdb
  replicas: 3
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: cockroachdb
  template:
    metadata:
      labels:
        app: cockroachdb
        # set this to add a consul tag of "production"
        production: tag
...

I can confirm that the label is being added as production: tag to the pod itself but when I look at Consul it's being added as production:tag and not production.

Looks like the ReplicaSet I pulled from the examples was using the 0.1.4 tag of the container. Switching to 0.1.6 fixed it.

tczekajlo commented 6 years ago

@fastest963, what version of Kubernetes and kube-consul-register do you use and what value have you set in option register_source?

jameshartig commented 6 years ago

Oh woops, I just updated my comment that it seems fixed now since I updated what container version I was using.