Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AntiAffinity values are not updated for canaries #923

Closed
divanikus opened this issue May 31, 2021 · 9 comments
Closed

AntiAffinity values are not updated for canaries #923

divanikus opened this issue May 31, 2021 · 9 comments

Comments

@divanikus
Copy link

divanikus commented May 31, 2021

Describe the bug

I can't make the Canary to update antiaffinity setting for a deployment. My deployment is set to have one replica per host. I have 5 hosts and 3 replicas on them. But then I try to release a new version, promoted production Deployment have the same anitaffinity key as the Canary one. So I end up with failed releases because I do not have 6 hosts for now (3 for canary, 3 for production replicas).

Deployment is the following:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: mc
    app.kubernetes.io/component: api
    app.kubernetes.io/instance: mc-master
    app.kubernetes.io/name: mc
    app.kubernetes.io/version: "7.1"
    branch: master
  name: mc-master-api
  namespace: production
spec:
  replicas: 3
  selector:
    matchLabels:
      app.kubernetes.io/component: api
      app.kubernetes.io/instance: mc-master
      app.kubernetes.io/name: mc-api
  strategy:
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: mc
        app.kubernetes.io/component: api
        app.kubernetes.io/instance: mc-master
        app.kubernetes.io/name: mc-api
        branch: master
        component: api
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app.kubernetes.io/name
                operator: In
                values:
                - mc-api
            topologyKey: kubernetes.io/hostname
      containers:
      - image: reducted/mc/mc:7.1
        imagePullPolicy: IfNotPresent
        name: mc
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: regcred
      restartPolicy: Always

And Canary for it:

apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
  labels:
    app: mc
    app.kubernetes.io/component: api
    app.kubernetes.io/instance: mc-master
    app.kubernetes.io/name: mc
    app.kubernetes.io/version: "7.1"
    branch: master
  name: mc-master-api
  namespace: production
spec:
  analysis:
    interval: 1m
    maxWeight: 100
    metrics:
    - interval: 1m
      name: request-success-rate
      thresholdRange:
        min: 95
    stepWeight: 20
    threshold: 20
  service:
    port: 8080
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: mc-master-api

Expected AntiAffinity block for mc-master-api-primary is the following:

      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app.kubernetes.io/name
                operator: In
                values:
                - mc-api-primary
            topologyKey: kubernetes.io/hostname

But in reality it is always just mc-api.

I've tried to rephrase the affinity verse, but without any luck.

Additional context

  • Flagger version: 1.9.0
  • Kubernetes version: 1.18.0
  • Service Mesh provider: Linkerd 2.10.1
  • Ingress provider: nginx
@stefanprodan
Copy link
Member

stefanprodan commented May 31, 2021

Does it work if you remove the app: mc from your deployment template labels?

@divanikus
Copy link
Author

Just checked. Nope, same thing.

@stefanprodan
Copy link
Member

Have you deleted the deployments? the pod labels are immutable

@divanikus
Copy link
Author

divanikus commented May 31, 2021

No, I've edited them. Also, you've said about template spec labels, and there they are mutable.

@stefanprodan
Copy link
Member

Ok I've found the issue, here #805

So for Flagger to be able to patch the values you need to use the same name as your deployment mc-master-api.

@divanikus
Copy link
Author

I think you should include that into the docs. It's not very intuitive right now.

@stefanprodan
Copy link
Member

@divanikus from docs here https://docs.flagger.app/faq#is-pod-affinity-and-anti-affinity-supported

The value must match the name of the target deployment.

@stefanprodan
Copy link
Member

Feel free to open a PR and improve the docs, thank you!

@divanikus
Copy link
Author

Damn, I've read that section for several times and still missed it. Thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants