koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

Deployment creation labels #56

Closed wlan0 closed 6 years ago

wlan0 commented 6 years ago

If the user provides no labels for a deployment like so:

deployment:
 name: doctor
 version: extensions/v1beta1
 replicas: 1

Then the resulting kube deployment should have the selector, not the label (like the ouput I get today)

- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    name: doctor
  spec:
    replicas: 1
    strategy:
      type: RollingUpdate
    template:
      metadata:
        creationTimestamp: null
        labels:
          koki.io/selector.name: doctor
      spec:
        containers: null
  status: {}

If a user provides a label, then the label, selector and the podTemplate label all should have the same value.

If the user provides a label and a selector, then the podTemplate should have the value in selector.

ublubu commented 6 years ago

I don't think we should set the Deployment Labels, since those don't affect the behavior of the Deployment.

For extensions/v1beta1 and apps/v1beta1, Deployment Selector defaults to the Template Labels, so the current output is fine. For apps/v1beta2, the Deployment Selector does not default to the Template Labels, so we populate it the same as the Template Labels.

wlan0 commented 6 years ago

It's not just about affecting the behavior of deployments. Users won't get a consistent experience with the current method.

If the deployment selector defaults to template labels, then we might as well add the template label. Explicitly specifying only improves readability.

If the deployment selector does not default, explicitly stating only make the user's experience consistent without worrying about api group nuances.