Change default ClusterIP to point to primary

- ensures that the routing works without a service mesh
This commit is contained in:
stefanprodan
2019-03-14 01:48:10 +02:00
parent 773094a20d
commit ba1788cbc5
5 changed files with 19 additions and 13 deletions
+1 -7
View File
@@ -23,7 +23,7 @@ spec:
spec:
containers:
- name: podinfod
image: quay.io/stefanprodan/podinfo:1.2.0
image: quay.io/stefanprodan/podinfo:1.4.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9898
@@ -67,9 +67,3 @@ spec:
requests:
cpu: 100m
memory: 16Mi
volumeMounts:
- mountPath: /data
name: data
volumes:
- emptyDir: {}
name: data
+1 -3
View File
@@ -1,10 +1,8 @@
apiVersion: v1
kind: Service
metadata:
name: podinfo
name: podinfo-canary
namespace: test
labels:
app: podinfo
spec:
type: ClusterIP
selector:
+1 -1
View File
@@ -23,7 +23,7 @@ spec:
spec:
containers:
- name: podinfod
image: quay.io/stefanprodan/podinfo:1.1.1
image: quay.io/stefanprodan/podinfo:1.4.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9898
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: podinfo
namespace: test
spec:
type: ClusterIP
selector:
app: podinfo-primary
ports:
- name: http
port: 9898
protocol: TCP
targetPort: http
+2 -2
View File
@@ -20,7 +20,7 @@ type KubernetesRouter struct {
logger *zap.SugaredLogger
}
// Sync creates to updates the primary and canary services
// Sync creates or updates the primary and canary services
func (c *KubernetesRouter) Sync(cd *flaggerv1.Canary) error {
targetName := cd.Spec.TargetRef.Name
primaryName := fmt.Sprintf("%s-primary", targetName)
@@ -40,7 +40,7 @@ func (c *KubernetesRouter) Sync(cd *flaggerv1.Canary) error {
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Selector: map[string]string{"app": targetName},
Selector: map[string]string{"app": primaryName},
Ports: []corev1.ServicePort{
{
Name: "http",