argoproj / argo-rollouts

Progressive Delivery for Kubernetes
https://argo-rollouts.readthedocs.io/
Apache License 2.0
2.77k stars 867 forks source link

Rollout is not dynamic labels aware #1658

Open kandeshvari opened 2 years ago

kandeshvari commented 2 years ago

Summary

I use dynamic labeling to pass traffic to leader pod. Definition is

apiVersion: v1
kind: Service
metadata:
    name: xxx
spec:
    ports:
        -   name: xxx
            port: 8080
            protocol: TCP
            targetPort: 8080
    selector:
        app: xxx
        role: leader

Label role: leader is added to pod by a sidecar container after a complex leader check.

I do not use label role in Rollout and get this error

status:
  conditions:
  - lastTransitionTime: "2021-11-14T16:13:51Z"
    lastUpdateTime: "2021-11-14T16:13:51Z"
    message: 'The Rollout "xxx" is invalid: spec.strategy.canary.stableService:
      Invalid value: "xxx": Service "xxx" has unmatch
      lable "role" in rollout'
    reason: InvalidSpec

Is there possibility to use argo rollout in such cases?

argo rollouts: master from 13 Nov '21 k8s: 1.22.3


Message from the maintainers:

Impacted by this bug? Give it a πŸ‘. We prioritize the issues with the most πŸ‘.

huikang commented 2 years ago

@kandeshvari , if the match label is added to the pod template as well, I think it should work. Could you verify if the pod label matches the service label?

kandeshvari commented 2 years ago

@huikang, if I set role: foo it doesn't work - error is the same. If I set role: leader - all works fine. But it is not a behaviour that I need. I want to set role: leader dynamically. Only one pod can be leader, but if I set role: leader in the Rollout - all the pods have this label. It is wrong.

huikang commented 2 years ago

The rollout's podTemplate likes Deployment, where all pods have the same labels. The behavior you described sounds a statefulset.

So I don't think dynamic labels will be supported for rollout CR.

kandeshvari commented 2 years ago

Dynamic labels are not for Rollout. They are for Pod. As I understand - Rollout cr is an extension of a Deployment and must act as a Deployment. If I use plain Deployment - everything works fine, if I "translate" it to Rollout - I'm getting the error. So, I may conclude - the problem is in the Rollout cr and excessive label checks, that are not present in the Deployment.

huikang commented 2 years ago

The rollout controller checks if the service's label matches the pods label

apiVersion: v1
kind: Service
metadata:
    name: xxx
spec:
    selector:
        L1: K1
        L2: K2

Then the rollout must have labels L1: K1 and L2: K2 in the its selector's label.

piVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollouts-test
spec:
  selector:
    matchLabels:
        L1: K1    # --------- > match service's label
        L2: K2  

Could you illustrate what you use cases?

kandeshvari commented 2 years ago

My case

                                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                          β”‚Pod (active)   β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚               β”‚
              β”‚                           β”‚ labels:       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”                        β”‚   role: leaderβ”‚
β”‚Service         β”‚                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚                β”‚
β”‚  selector:     β”‚
β”‚    role: leaderβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                          β”‚Pod (standby)  β”‚
                                          β”‚               β”‚
                                          β”‚ labels: []    β”‚
                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

role: leader is a dynamically added to Pod label. Service is always static and points to active pod.

I want to use canary deployment without any traffic shaper. So I await that argo rollouts just will create separate deployment for me, which in my case will be one more standby pod. I will test it manually, switch the leader to this node, and promote it to complete the deployment.

huikang commented 2 years ago

Looks like rollout is missing in the picture. Are the two pods belong to the same rollout? What is the selector label of the rollout?

odorT commented 2 years ago

I also have the same problem. Are there any workarounds?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity.