Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

[Feature] Propagate labels of non-core workloads to pod template #184

Open
zzxwill opened this issue Aug 26, 2020 · 5 comments
Open

[Feature] Propagate labels of non-core workloads to pod template #184

zzxwill opened this issue Aug 26, 2020 · 5 comments

Comments

@zzxwill
Copy link
Member

zzxwill commented Aug 26, 2020

Is your feature request related to a problem? Please describe.

In order to implement feature #174, not only could labels of ContainerizedWorkloads be propagated to its pods (implemented in #175), but also should work for non-core workloads, like Deployment.

Deployment workload's customized labels like component.oam.dev/name: example-deployment could be automatically generated for its pods.

  • component yaml
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
  name: example-deployment
spec:
  workload:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
      labels:
        app: nginx
        component.oam.dev/name: example-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.17
            ports:
            - containerPort: 80
  • appconfig yaml
apiVersion: core.oam.dev/v1alpha2
kind: ApplicationConfiguration
metadata:
  name: example-deployment-appconfig
spec:
  components:
    - componentName: example-deployment

The pod haven't get the customized label.

✗ k describe pod nginx-deployment-5d85b5fb59-vmkdz
Name:         nginx-deployment-5d85b5fb59-vmkdz
Namespace:    default
Priority:     0
Node:         kind-control-plane/172.18.0.2
Start Time:   Wed, 26 Aug 2020 14:59:02 +0800
Labels:       app=nginx
              pod-template-hash=5d85b5fb59
Annotations:  <none>
Status:       Running
IP:           10.244.0.9
IPs:
  IP:           10.244.0.9
Controlled By:  ReplicaSet/nginx-deployment-5d85b5fb59
@wonderflow
Copy link
Member

This should not be an issue as user can fulfill their config if they use non-core workloads.

In this case, you could write component like this:

apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
  name: example-deployment
spec:
  workload:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
      labels:
        app: nginx
    spec:
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            component.oam.dev/name: example-deployment
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.17
            ports:
            - containerPort: 80

@zzxwill
Copy link
Member Author

zzxwill commented Aug 26, 2020

Cool, you are right. Thanks.

@resouer
Copy link
Contributor

resouer commented Aug 26, 2020

@wonderflow Note that for non-core workload it still need revision labels to be automatically patched (not propagation).

@zzxwill
Copy link
Member Author

zzxwill commented Aug 27, 2020

@wonderflow Note that for non-core workload it still need revision labels to be automatically patched (not propagation).

Then let's automatically patch those labels including component.oam.dev/name. Users will be happy with less inputs.

@resouer
Copy link
Contributor

resouer commented Aug 31, 2020

@zzxwill I agree. OAM Runtime should always patch exactly same label to PodTemplate as long as it exist.

That's also why I proposed a characteristic named podspecable in oam-dev/spec#392 to WorkloadDefinition.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants