Add service name field to Canary CRD

This commit is contained in:
stefanprodan
2020-01-26 12:46:08 +02:00
parent c38bd144e4
commit e3ecebc9ae
4 changed files with 25 additions and 3 deletions
+3
View File
@@ -115,6 +115,9 @@ spec:
type: object
required: ["port"]
properties:
name:
description: Kubernetes service name
type: string
port:
description: Container port number
type: number
+3
View File
@@ -116,6 +116,9 @@ spec:
type: object
required: ['port']
properties:
name:
description: Kubernetes service name
type: string
port:
description: Container port number
type: number
+3
View File
@@ -115,6 +115,9 @@ spec:
type: object
required: ["port"]
properties:
name:
description: Kubernetes service name
type: string
port:
description: Container port number
type: number
+16 -3
View File
@@ -17,6 +17,7 @@ limitations under the License.
package v1alpha3
import (
"fmt"
"time"
hpav1 "k8s.io/api/autoscaling/v1"
@@ -69,7 +70,7 @@ type CanarySpec struct {
// virtual service spec
Service CanaryService `json:"service"`
// metrics and thresholds
// metrics, thresholds and webhooks spec
CanaryAnalysis CanaryAnalysis `json:"canaryAnalysis"`
// the maximum time in seconds for a canary deployment to make progress
@@ -92,8 +93,9 @@ type CanaryList struct {
}
// CanaryService is used to create ClusterIP services
// and Istio Virtual Service
// and service mesh or ingress routing objects
type CanaryService struct {
Name string `json:"name,omitempty"`
Port int32 `json:"port"`
PortName string `json:"portName,omitempty"`
TargetPort intstr.IntOrString `json:"targetPort,omitempty"`
@@ -126,7 +128,7 @@ type CanaryAnalysis struct {
Iterations int `json:"iterations,omitempty"`
}
// CanaryMetric holds the reference to Istio metrics used for canary analysis
// CanaryMetric holds the reference to metrics used for canary analysis
type CanaryMetric struct {
Name string `json:"name"`
Interval string `json:"interval,omitempty"`
@@ -171,6 +173,17 @@ type CanaryWebhookPayload struct {
Metadata map[string]string `json:"metadata,omitempty"`
}
// GetServiceNames returns the apex, primary and canary Kubernetes service names
func (c *Canary) GetServiceNames() (apexName, primaryName, canaryName string) {
apexName = c.Spec.TargetRef.Name
if c.Spec.Service.Name != "" {
apexName = c.Spec.Service.Name
}
primaryName = fmt.Sprintf("%s-primary", apexName)
canaryName = fmt.Sprintf("%s-canary", apexName)
return
}
// GetProgressDeadlineSeconds returns the progress deadline (default 600s)
func (c *Canary) GetProgressDeadlineSeconds() int {
if c.Spec.ProgressDeadlineSeconds != nil {