-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segment labels: Docker #3055
Segment labels: Docker #3055
Conversation
575fae0
to
379fcef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Great job @ldez 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job @ldez
Mostly comments on the doc :)
# For advanced users :) | ||
# | ||
# Optional | ||
# - "1": previous template (must be use only with a old custom template, see "filename") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous template version (must be used only with a older custom templates, see "filename")
# | ||
# Optional | ||
# - "1": previous template (must be use only with a old custom template, see "filename") | ||
# - "2": current template (must be use to force template version when "filename" is used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current template version (must be used to force template version when "filename" is used)
@@ -237,70 +255,71 @@ Labels can be used on containers to override default behaviour. | |||
| `traefik.frontend.headers.referrerPolicy=VALUE` | Adds referrer policy header. | | |||
| `traefik.frontend.headers.isDevelopment=false` | This will cause the `AllowedHosts`, `SSLRedirect`, and `STSSeconds`/`STSIncludeSubdomains` options to be ignored during development.<br>When deploying to production, be sure to set this to false. | | |||
|
|||
### On Service | |||
### On container with multiple ports (segment label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On containers with multiple ports (segment labels)
|
||
Services labels can be used for overriding default behaviour | ||
Segment labels are a way to define more than one (default) port on the same container so you can create different routes to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segment labels are used to define routes to a container exposing multiple ports. A segment is a group of labels that apply to a port exposed by a container. You can define as many segments as ports exposed in a container.
|
||
Services labels can be used for overriding default behaviour | ||
Segment labels are a way to define more than one (default) port on the same container so you can create different routes to it. | ||
Segment labels are overriding the default behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segment labels are overrideing the default behavior.
For applications that expose multiple ports, specific labels can be used to extract one frontend/backend configuration pair per port. Each such pair is called a _service_. The (freely choosable) name of the service is an integral part of the service label name. | ||
For applications that expose multiple ports, specific labels can be used to extract one frontend/backend configuration pair per port. | ||
Each such pair is called a _segment_. | ||
The (freely choosable) name of the segment is an integral part of the segment label name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The segment
labels explanation should be consistent between Docker, Marathon and Rancher documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now behavior, between Docker and Marathon on segment labels are not consistent (ex: Docker use container labels as default and not Marathon).
I will update the documentation when I will rewrite the Marathon provider.
provider/label/label.go
Outdated
ServicesPropertiesRegexp = regexp.MustCompile(`^traefik\.(?P<service_name>.+?)\.(?P<property_name>port|portIndex|weight|protocol|backend|frontend\.(.+))$`) | ||
// SegmentPropertiesRegexp used to extract the name of the segment and the name of the property for this segment | ||
// All properties are under the format traefik.<segment_name>.frontend.*= except the port/portIndex/weight/protocol/backend directly after traefik.<segment_name>. | ||
SegmentPropertiesRegexp = regexp.MustCompile(`^traefik\.(?P<service_name>.+?)\.(?P<property_name>port|portIndex|weight|protocol|backend|frontend\.(.+))$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/service_name/segment_name
provider/label/label.go
Outdated
|
||
// PortRegexp used to extract the port label of the service | ||
// PortRegexp used to extract the port label of the segment | ||
PortRegexp = regexp.MustCompile(`^traefik\.(?P<service_name>.+?)\.port$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/service_name/segment_name
provider/label/label.go
Outdated
var propertyName string | ||
for i, name := range SegmentPropertiesRegexp.SubexpNames() { | ||
if i != 0 { | ||
if name == "service_name" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/service_name/segment_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM, I would just add few comments in the code to make it easier to read later
provider/label/label.go
Outdated
var propertyName string | ||
for i, name := range ServicesPropertiesRegexp.SubexpNames() { | ||
for i, name := range SegmentPropertiesRegexp.SubexpNames() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment here to explain why if i != 0 {
provider/label/label.go
Outdated
var segmentName string | ||
var propertyName string | ||
for i, name := range SegmentPropertiesRegexp.SubexpNames() { | ||
if i != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment here to explain why if i != 0 {
provider/label/label.go
Outdated
} | ||
|
||
func (s SegmentProperties) mergeDefault() { | ||
if defaultLabels, okDefault := s[""]; okDefault { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here would be welcome
10a7bfa
to
a58ec45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @ldez
Thanks a lot !
LGTM
47432c3
to
8a14d42
Compare
What does this PR do?
"Service labels" become "segment labels".
Full rewrite of the template management in Docker.
Motivation
Homogenization of the providers [part4]:ave a common way to manage segment labels.
Related to #2785
More
Additional Notes
It's the first step, next: Marathon and Rancher.