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

add customizations for apps.krusie.io/v1beta1/StatefulSet #3352

Merged

Conversation

yike21
Copy link
Member

@yike21 yike21 commented Apr 1, 2023

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Add third-party resources apps.krusie.io/v1beta1/StatefulSet into Resource Interpreter framework.
According to Note, we can find that since Kruise v0.7.0, Advanced StatefulSet has been promoted to v1beta1, which is compatible with v1alpha1.

Which issue(s) this PR fixes:
Part of #3331

Special notes for your reviewer:
@Poor12

Does this PR introduce a user-facing change?:
NONE

`Resource Interpreter`: Support `apps.krusie.io/v1beta1/StatefulSet`

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Apr 1, 2023
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 1, 2023
@yike21 yike21 force-pushed the bundle-kruise-resources-statefulset branch 2 times, most recently from 005c5a2 to d4a4fe6 Compare April 10, 2023 07:42
@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2023

Codecov Report

Merging #3352 (85d2030) into master (42bf1bc) will increase coverage by 0.01%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3352      +/-   ##
==========================================
+ Coverage   51.63%   51.64%   +0.01%     
==========================================
  Files         210      210              
  Lines       18926    18926              
==========================================
+ Hits         9773     9775       +2     
+ Misses       8622     8620       -2     
  Partials      531      531              
Flag Coverage Δ
unittests 51.64% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

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

status.updatedReadyReplicas = observedObj.status.updatedReadyReplicas
return status
end
healthInterpretation:
Copy link
Member Author

@yike21 yike21 Apr 13, 2023

Choose a reason for hiding this comment

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

The healthInterpretation rule for statefulset.apps.kruise.io is a reference to the code in pkg/resourceinterpreter/default/native/healthy.go corresponding to native statefulset. The idea is changed from "determine what is healthy" to "determine what is unhealthy/illegal". It allows a member cluster to be considered healthy when the pod is not fully ready, and to be aggregated.

@yike21 yike21 force-pushed the bundle-kruise-resources-statefulset branch 3 times, most recently from 4814750 to 85d2030 Compare April 13, 2023 10:47
Signed-off-by: yike21 <yike21@qq.com>
@yike21 yike21 force-pushed the bundle-kruise-resources-statefulset branch from 85d2030 to 0fc8887 Compare April 13, 2023 16:15
@yike21
Copy link
Member Author

yike21 commented Apr 13, 2023

The test report based on karmadactl interpret is below:

### Check the customizations in file
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --check
I0414 00:09:09.547675 2883113 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:09:09.547820 2883113 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:09:09.559424 2883113 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:09:09.559574 2883113 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
-----------------------------------
SOURCE: declarative-configuration-statefulset
TARGET: apps.kruise.io/v1beta1 StatefulSet   
RULERS:
    Retain:                                  UNSET
    InterpretReplica:                        PASS
    ReviseReplica:                           PASS
    InterpretStatus:                         PASS
    AggregateStatus:                         PASS
    InterpretHealth:                         PASS
    InterpretDependency:                     PASS

### Execute the replicaResource rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation interpretReplica --observed-file testdata/observed-statefulset-nginx.yaml 
I0414 00:10:02.863600 2883168 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:02.863973 2883168 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:02.879819 2883168 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:02.879977 2883168 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/2] replica:
2
---
# [2/2] requires:
null

### Execute the replicaRevision rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation reviseReplica --observed-file testdata/observed-statefulset-nginx.yaml --desired-replica 3
I0414 00:10:29.274876 2883237 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:29.275307 2883237 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:29.296208 2883237 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:10:29.296361 2883237 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/1] revised:
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
    generation: 1
    name: sample
    namespace: test-statefulset
spec:
    podManagementPolicy: Parallel
    replicas: 3
    selector:
        matchLabels:
            app: sample
    serviceName: sample-statefulset-headless-service
    template:
        metadata:
            labels:
                app: sample
        spec:
            containers:
                - env:
                    - name: logData
                      valueFrom:
                        configMapKeyRef:
                            key: log
                            name: mysql-config
                    - name: lowerData
                      valueFrom:
                        configMapKeyRef:
                            key: lower
                            name: mysql-config
                  image: nginx:alpine
                  name: nginx
                  ports:
                    - containerPort: 80
                      name: web
            readinessGates:
                - conditionType: InPlaceUpdateReady
            volumes:
                - configMap:
                    name: my-sample-config
                  name: configmap
    updateStrategy:
        rollingUpdate:
            maxUnavailable: 2
            podUpdatePolicy: InPlaceIfPossible
        type: RollingUpdate
status:
    availableReplicas: 2
    collisionCount: 0
    currentReplicas: 2
    currentRevision: sample-5675547df7
    labelSelector: app=sample
    observedGeneration: 1
    readyReplicas: 2
    replicas: 2
    updateRevision: sample-5675547df7
    updatedReadyReplicas: 2
    updatedReplicas: 2

### Execute the statusReflection rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation interpretStatus --observed-file testdata/observed-statefulset-nginx.yaml 
I0414 00:11:18.459742 2883320 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:18.459982 2883320 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:18.472764 2883320 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:18.472902 2883320 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/1] status:
availableReplicas: 2
currentReplicas: 2
currentRevision: sample-5675547df7
observedGeneration: 1
readyReplicas: 2
replicas: 2
updateRevision: sample-5675547df7
updatedReadyReplicas: 2
updatedReplicas: 2

### Execute the healthInterpretation rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation interpretHealth --observed-file testdata/observed-statefulset-nginx.yaml 
I0414 00:11:39.805301 2883353 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:39.805451 2883353 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:39.814892 2883353 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:39.815246 2883353 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/1] healthy:
true

### Execute the dependencyInterpretation rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation interpretDependency --observed-file testdata/observed-statefulset-nginx.yaml 
I0414 00:11:58.924326 2883388 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:58.924478 2883388 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:58.934625 2883388 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:11:58.934757 2883388 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/1] dependencies:
- apiVersion: v1
  kind: ConfigMap
  name: my-sample-config
  namespace: test-statefulset
- apiVersion: v1
  kind: ConfigMap
  name: mysql-config
  namespace: test-statefulset

### Execute the statusAggregation rule
byk@debian:~/go/src/karmada/pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/apps.kruise.io/v1beta1/StatefulSet$ karmadactl interpret -f customizations.yaml --operation aggregateStatus --observed-file testdata/observed-statefulset-nginx.yaml --status-file testdata/status-file.yaml 
I0414 00:12:28.321241 2883465 deploy.go:75] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:12:28.321371 2883465 enable_option.go:63] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:12:28.331105 2883465 cmdinit.go:149] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
I0414 00:12:28.331350 2883465 register.go:160] No default release version found. build version: version.Info{GitVersion:"", GitCommit:"c8720e81c7f4badb2a2e07ed7218391b3ea7d912", GitTreeState:"dirty", BuildDate:"2023-04-12T09:43:27Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/amd64"}
---
# [1/1] aggregatedStatus:
apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
    generation: 1
    name: sample
    namespace: test-statefulset
spec:
    podManagementPolicy: Parallel
    replicas: 2
    selector:
        matchLabels:
            app: sample
    serviceName: sample-statefulset-headless-service
    template:
        metadata:
            labels:
                app: sample
        spec:
            containers:
                - env:
                    - name: logData
                      valueFrom:
                        configMapKeyRef:
                            key: log
                            name: mysql-config
                    - name: lowerData
                      valueFrom:
                        configMapKeyRef:
                            key: lower
                            name: mysql-config
                  image: nginx:alpine
                  name: nginx
                  ports:
                    - containerPort: 80
                      name: web
            readinessGates:
                - conditionType: InPlaceUpdateReady
            volumes:
                - configMap:
                    name: my-sample-config
                  name: configmap
    updateStrategy:
        rollingUpdate:
            maxUnavailable: 2
            podUpdatePolicy: InPlaceIfPossible
        type: RollingUpdate
status:
    availableReplicas: 4
    collisionCount: 0
    currentReplicas: 4
    currentRevision: sample-5675547df7
    labelSelector: app=sample
    observedGeneration: 1
    readyReplicas: 4
    replicas: 4
    updateRevision: sample-5675547df7
    updatedReadyReplicas: 4
    updatedReplicas: 4

@Poor12
Copy link
Member

Poor12 commented Apr 14, 2023

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2023
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Poor12

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2023
@karmada-bot karmada-bot merged commit c3d54cc into karmada-io:master Apr 14, 2023
@yike21 yike21 deleted the bundle-kruise-resources-statefulset branch April 14, 2023 03:03
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants