add endpoint mode in service pretty
Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
parent
33466024e7
commit
70bb832060
5 changed files with 23 additions and 9 deletions
|
@ -19,9 +19,9 @@ Labels:
|
|||
{{- range $k, $v := .Labels }}
|
||||
{{ $k }}{{if $v }}={{ $v }}{{ end }}
|
||||
{{- end }}{{ end }}
|
||||
Mode:
|
||||
{{- if .IsModeGlobal }} Global
|
||||
{{- else if .IsModeReplicated }} Replicated
|
||||
Service Mode:
|
||||
{{- if .IsModeGlobal }} Global
|
||||
{{- else if .IsModeReplicated }} Replicated
|
||||
{{- if .ModeReplicatedReplicas }}
|
||||
Replicas: {{ .ModeReplicatedReplicas }}
|
||||
{{- end }}{{ end }}
|
||||
|
@ -90,6 +90,7 @@ Resources:
|
|||
{{- if .Networks }}
|
||||
Networks:
|
||||
{{- range $network := .Networks }} {{ $network }}{{ end }} {{ end }}
|
||||
Endpoint Mode: {{ .EndpointMode }}
|
||||
{{- if .Ports }}
|
||||
Ports:
|
||||
{{- range $port := .Ports }}
|
||||
|
@ -282,6 +283,14 @@ func (ctx *serviceInspectContext) Networks() []string {
|
|||
return out
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) EndpointMode() string {
|
||||
if ctx.Service.Spec.EndpointSpec == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return string(ctx.Service.Spec.EndpointSpec.Mode)
|
||||
}
|
||||
|
||||
func (ctx *serviceInspectContext) Ports() []swarm.PortConfig {
|
||||
return ctx.Service.Endpoint.Ports
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ func (i *TemplateInspector) tryRawInspectFallback(rawElement []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Flush write the result of inspecting all elements into the output stream.
|
||||
// Flush writes the result of inspecting all elements into the output stream.
|
||||
func (i *TemplateInspector) Flush() error {
|
||||
if i.buffer.Len() == 0 {
|
||||
_, err := io.WriteString(i.outputStream, "\n")
|
||||
|
@ -156,7 +156,7 @@ func (i *IndentedInspector) Inspect(typedElement interface{}, rawElement []byte)
|
|||
return nil
|
||||
}
|
||||
|
||||
// Flush write the result of inspecting all elements into the output stream.
|
||||
// Flush writes the result of inspecting all elements into the output stream.
|
||||
func (i *IndentedInspector) Flush() error {
|
||||
if len(i.elements) == 0 && len(i.rawElements) == 0 {
|
||||
_, err := io.WriteString(i.outputStream, "[]\n")
|
||||
|
|
|
@ -115,7 +115,7 @@ ID: c8wgl7q4ndfd52ni6qftkvnnp
|
|||
Name: frontend
|
||||
Labels:
|
||||
- org.example.projectname=demo-app
|
||||
Mode: REPLICATED
|
||||
Service Mode: REPLICATED
|
||||
Replicas: 5
|
||||
Placement:
|
||||
UpdateConfig:
|
||||
|
@ -123,6 +123,7 @@ UpdateConfig:
|
|||
ContainerSpec:
|
||||
Image: nginx:alpine
|
||||
Resources:
|
||||
Endpoint Mode: vip
|
||||
Ports:
|
||||
Name =
|
||||
Protocol = tcp
|
||||
|
|
|
@ -29,7 +29,7 @@ about a service in an easily readable format.
|
|||
|
||||
ID: 9uk4639qpg7npwf3fn2aasksr
|
||||
Name: helloworld
|
||||
Mode: REPLICATED
|
||||
Service Mode: REPLICATED
|
||||
Replicas: 1
|
||||
Placement:
|
||||
UpdateConfig:
|
||||
|
@ -37,6 +37,8 @@ about a service in an easily readable format.
|
|||
ContainerSpec:
|
||||
Image: alpine
|
||||
Args: ping docker.com
|
||||
Resources:
|
||||
Endpoint Mode: vip
|
||||
```
|
||||
|
||||
>**Tip**: To return the service details in json format, run the same command
|
||||
|
|
|
@ -59,7 +59,7 @@ update delay:
|
|||
|
||||
ID: 0u6a4s31ybk7yw2wyvtikmu50
|
||||
Name: redis
|
||||
Mode: Replicated
|
||||
Service Mode: Replicated
|
||||
Replicas: 3
|
||||
Placement:
|
||||
Strategy: Spread
|
||||
|
@ -69,6 +69,7 @@ update delay:
|
|||
ContainerSpec:
|
||||
Image: redis:3.0.6
|
||||
Resources:
|
||||
Endpoint Mode: vip
|
||||
```
|
||||
|
||||
4. Now you can update the container image for `redis`. The swarm manager
|
||||
|
@ -97,7 +98,7 @@ desired state:
|
|||
|
||||
ID: 0u6a4s31ybk7yw2wyvtikmu50
|
||||
Name: redis
|
||||
Mode: Replicated
|
||||
Service Mode: Replicated
|
||||
Replicas: 3
|
||||
Placement:
|
||||
Strategy: Spread
|
||||
|
@ -107,6 +108,7 @@ desired state:
|
|||
ContainerSpec:
|
||||
Image: redis:3.0.7
|
||||
Resources:
|
||||
Endpoint Mode: vip
|
||||
```
|
||||
|
||||
The output of `service inspect` shows if your update paused due to failure:
|
||||
|
|
Loading…
Reference in a new issue