File tree 6 files changed +35
-14
lines changed
6 files changed +35
-14
lines changed Original file line number Diff line number Diff line change 23
23
spec :
24
24
containers :
25
25
- name : podinfod
26
- image : quay.io/stefanprodan/podinfo:1.2 .0
26
+ image : quay.io/stefanprodan/podinfo:1.4 .0
27
27
imagePullPolicy : IfNotPresent
28
28
ports :
29
29
- containerPort : 9898
67
67
requests :
68
68
cpu : 100m
69
69
memory : 16Mi
70
- volumeMounts :
71
- - mountPath : /data
72
- name : data
73
- volumes :
74
- - emptyDir : {}
75
- name : data
Original file line number Diff line number Diff line change 1
1
apiVersion : v1
2
2
kind : Service
3
3
metadata :
4
- name : podinfo
4
+ name : podinfo-canary
5
5
namespace : test
6
- labels :
7
- app : podinfo
8
6
spec :
9
7
type : ClusterIP
10
8
selector :
Original file line number Diff line number Diff line change 23
23
spec :
24
24
containers :
25
25
- name : podinfod
26
- image : quay.io/stefanprodan/podinfo:1.1 .1
26
+ image : quay.io/stefanprodan/podinfo:1.4 .1
27
27
imagePullPolicy : IfNotPresent
28
28
ports :
29
29
- containerPort : 9898
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Service
3
+ metadata :
4
+ name : podinfo
5
+ namespace : test
6
+ spec :
7
+ type : ClusterIP
8
+ selector :
9
+ app : podinfo-primary
10
+ ports :
11
+ - name : http
12
+ port : 9898
13
+ protocol : TCP
14
+ targetPort : http
Original file line number Diff line number Diff line change @@ -77,6 +77,8 @@ func (c *CanaryDeployer) Promote(cd *flaggerv1.Canary) error {
77
77
}
78
78
primaryCopy .Spec .Template .Annotations = annotations
79
79
80
+ primaryCopy .Spec .Template .Labels = makePrimaryLabels (canary .Spec .Template .Labels , primaryName )
81
+
80
82
_ , err = c .kubeClient .AppsV1 ().Deployments (cd .Namespace ).Update (primaryCopy )
81
83
if err != nil {
82
84
return fmt .Errorf ("updating deployment %s.%s template spec failed: %v" ,
@@ -403,7 +405,7 @@ func (c *CanaryDeployer) createPrimaryDeployment(cd *flaggerv1.Canary) error {
403
405
},
404
406
Template : corev1.PodTemplateSpec {
405
407
ObjectMeta : metav1.ObjectMeta {
406
- Labels : map [ string ] string { "app" : primaryName } ,
408
+ Labels : makePrimaryLabels ( canaryDep . Spec . Template . Labels , primaryName ) ,
407
409
Annotations : annotations ,
408
410
},
409
411
// update spec with the primary secrets and config maps
@@ -544,3 +546,16 @@ func (c *CanaryDeployer) makeAnnotations(annotations map[string]string) (map[str
544
546
545
547
return res , nil
546
548
}
549
+
550
+ func makePrimaryLabels (labels map [string ]string , primaryName string ) map [string ]string {
551
+ idKey := "app"
552
+ res := make (map [string ]string )
553
+ for k , v := range labels {
554
+ if k != idKey {
555
+ res [k ] = v
556
+ }
557
+ }
558
+ res [idKey ] = primaryName
559
+
560
+ return res
561
+ }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ type KubernetesRouter struct {
20
20
logger * zap.SugaredLogger
21
21
}
22
22
23
- // Sync creates to updates the primary and canary services
23
+ // Sync creates or updates the primary and canary services
24
24
func (c * KubernetesRouter ) Sync (cd * flaggerv1.Canary ) error {
25
25
targetName := cd .Spec .TargetRef .Name
26
26
primaryName := fmt .Sprintf ("%s-primary" , targetName )
@@ -40,7 +40,7 @@ func (c *KubernetesRouter) Sync(cd *flaggerv1.Canary) error {
40
40
},
41
41
Spec : corev1.ServiceSpec {
42
42
Type : corev1 .ServiceTypeClusterIP ,
43
- Selector : map [string ]string {"app" : targetName },
43
+ Selector : map [string ]string {"app" : primaryName },
44
44
Ports : []corev1.ServicePort {
45
45
{
46
46
Name : "http" ,
You can’t perform that action at this time.
0 commit comments