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

Allow to set TopologySpreadConstraints via spec.deployments.topologySpreadConstraints #1305

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

kahirokunn
Copy link
Member

@kahirokunn kahirokunn commented Jan 5, 2023

Part of #1304

This patch adds spec.deployments.topologySpreadConstraints to set topologySpreadConstraints on each deployment.

For example, when the following CR is created,

apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller

The webhook deployment has spec.template.spec.topologySpreadConstraints.

$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 5, 2023
@knative-prow
Copy link

knative-prow bot commented Jan 5, 2023

Welcome @kahirokunn! It looks like this is your first PR to knative/operator 🎉

@knative-prow knative-prow bot requested review from jcrossley3 and trshafer January 5, 2023 11:57
@knative-prow knative-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 5, 2023
@knative-prow
Copy link

knative-prow bot commented Jan 5, 2023

Hi @kahirokunn. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kahirokunn: 0 warnings.

In response to this:

Part of #1304

This patch adds spec.deployments.topologySpreadConstraints to set topologySpreadConstraints on each deployment.

For example, when the following CR is created,

apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
 name: ks
 namespace: knative-serving
spec:
 high-availability:
   replicas: 1

 deployments:
 - name: webhook
   topologySpreadConstraints:
   - maxSkew: 1
     topologyKey: topology.kubernetes.io/zone
     whenUnsatisfiable: DoNotSchedule
     labelSelector:
       matchLabels:
         app: controller

The webhook deployment has spec.template.spec.topologySpreadConstraints.

$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]

Signed-off-by: kahirokunn okinakahiro@gmail.com

Fixes #

Proposed Changes

Release Note


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 5, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 5, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 5, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn
Copy link
Member Author

Which command updates config/*.yaml? 👀

@houshengbo
Copy link
Contributor

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 6, 2023
kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 17, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@houshengbo
Copy link
Contributor

houshengbo commented Jan 17, 2023

@kahirokunn Try to fix the unit test issues. Make sure your code logic works.
Regarding the CRD changes, I will point for you later.

kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 18, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 18, 2023
kahirokunn added a commit to kahirokunn/knative-operator that referenced this pull request Jan 18, 2023
…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@kahirokunn
Copy link
Member Author

kahirokunn commented Jan 18, 2023

@houshengbo I have accomplished everything you said.
I am ready to take a Review.

@codecov
Copy link

codecov bot commented Jan 18, 2023

Codecov Report

Base: 79.61% // Head: 79.57% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (3ae4a70) compared to base (4e69fa4).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 3ae4a70 differs from pull request most recent head 2862831. Consider uploading reports for the commit 2862831 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1305      +/-   ##
==========================================
- Coverage   79.61%   79.57%   -0.04%     
==========================================
  Files          36       38       +2     
  Lines        1653     1738      +85     
==========================================
+ Hits         1316     1383      +67     
- Misses        244      257      +13     
- Partials       93       98       +5     
Impacted Files Coverage Δ
pkg/reconciler/common/workload_override.go 86.36% <100.00%> (+0.53%) ⬆️
...econciler/knativeserving/security/securityguard.go 73.07% <0.00%> (ø)
pkg/reconciler/knativeserving/security/security.go 79.62% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

…SpreadConstraints` (knative#1305)

Part of knative#1304

This patch adds `spec.deployments.topologySpreadConstraints` to set topologySpreadConstraints on
each deployment.

For example, when the following CR is created,
```
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: ks
  namespace: knative-serving
spec:
  high-availability:
    replicas: 1

  deployments:
  - name: webhook
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: DoNotSchedule
      labelSelector:
        matchLabels:
          app: controller
```

The webhook deployment has `spec.template.spec.topologySpreadConstraints`.

```
$ kubectl get deploy webhook -o jsonpath={.spec.template.spec.topologySpreadConstraints}
[{"labelSelector":{"matchLabels":{"app":"controller"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"DoNotSchedule"}]
```

Signed-off-by: kahirokunn <okinakahiro@gmail.com>
@knative-prow knative-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 18, 2023
@kahirokunn
Copy link
Member Author

@houshengbo Thx for your review.
How about now?
Thx.

@houshengbo
Copy link
Contributor

/test serving-upgrade-tests
/test eventing-upgrade-tests

@houshengbo
Copy link
Contributor

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2023
@knative-prow
Copy link

knative-prow bot commented Jan 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: houshengbo, kahirokunn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2023
@knative-prow knative-prow bot merged commit 23c2bc7 into knative:main Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants