From d5e345d41df1dde1c143dc81a8ca4332688a13f8 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 8 Sep 2020 11:43:47 +0100 Subject: [PATCH] util/kubernetes: fix TCPSocketAction bug (#1987) --- util/kubernetes/client/client.go | 12 +++++++----- util/kubernetes/client/types.go | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/util/kubernetes/client/client.go b/util/kubernetes/client/client.go index 7b14e08c..707f7ac6 100644 --- a/util/kubernetes/client/client.go +++ b/util/kubernetes/client/client.go @@ -274,10 +274,12 @@ func NewDeployment(name, version, typ, namespace string) *Deployment { logger.Tracef("kubernetes default deployment: name: %s, version: %s", name, version) } - Labels := map[string]string{ - "name": name, - "version": version, - "micro": typ, + Labels := map[string]string{"name": name} + if len(typ) > 0 { + Labels["micro"] = typ + } + if len(version) > 0 { + Labels["version"] = version } depName := name @@ -322,7 +324,7 @@ func NewDeployment(name, version, typ, namespace string) *Deployment { ContainerPort: 8080, }}, ReadinessProbe: &Probe{ - TCPSocket: TCPSocketAction{ + TCPSocket: &TCPSocketAction{ Port: 8080, }, PeriodSeconds: 10, diff --git a/util/kubernetes/client/types.go b/util/kubernetes/client/types.go index da78d1dd..922aa27b 100644 --- a/util/kubernetes/client/types.go +++ b/util/kubernetes/client/types.go @@ -225,15 +225,15 @@ type ServiceAccount struct { // Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic. type Probe struct { - TCPSocket TCPSocketAction `json:"tcpSocket,omitempty"` - PeriodSeconds int `json:"periodSeconds"` - InitialDelaySeconds int `json:"initialDelaySeconds"` + TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty"` + PeriodSeconds int `json:"periodSeconds"` + InitialDelaySeconds int `json:"initialDelaySeconds"` } // TCPSocketAction describes an action based on opening a socket type TCPSocketAction struct { - Host string `json:"host,omitempty"` - Port int `json:"port,omitempty"` + Host string `json:"host,omitempty"` + Port interface{} `json:"port,omitempty"` } // ResourceRequirements describes the compute resource requirements.