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

support to promote dependency resources automatically by using '-d=true' #1863

Closed
wants to merge 1 commit into from

Conversation

duanmengkk
Copy link
Member

@duanmengkk duanmengkk commented May 22, 2022

Signed-off-by: duanmeng [email protected]

What type of PR is this?
support to promote dependency resources automatically by using '-d=true'

What this PR does / why we need it:

If users use promote resource from member cluster to control plane,he may need promote relevant resources automatically.

Which issue(s) this PR fixes:
Fixes #1862

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Support to use '--deps=true' or '-d true' to promote the relevant resources automatically`
example:
  kubectl karmada  promote deployments test -d=true  -c member1

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign kevin-wangzefeng after the PR has been reviewed.
You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

The full list of commands accepted by this bot can be found 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

@duanmengkk duanmengkk changed the title support to promote dependency resources automatically by using '-d true' WIP:support to promote dependency resources automatically by using '-d true' May 22, 2022
@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 22, 2022
@duanmengkk duanmengkk force-pushed the feature_promotedeps branch from 72eff5f to 1b8f541 Compare May 22, 2022 11:12
@duanmengkk duanmengkk changed the title WIP:support to promote dependency resources automatically by using '-d true' support to promote dependency resources automatically by using '-d true' May 22, 2022
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 22, 2022
@duanmengkk duanmengkk changed the title support to promote dependency resources automatically by using '-d true' WIP:support to promote dependency resources automatically by using '-d true' May 22, 2022
@karmada-bot karmada-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 May 22, 2022
@duanmengkk duanmengkk force-pushed the feature_promotedeps branch from dd2d000 to acc0861 Compare May 23, 2022 01:06
@duanmengkk duanmengkk changed the title WIP:support to promote dependency resources automatically by using '-d true' support to promote dependency resources automatically by using '-d true' May 23, 2022
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 23, 2022
@duanmengkk duanmengkk changed the title support to promote dependency resources automatically by using '-d true' support to promote dependency resources automatically by using '-d=true' May 23, 2022
@duanmengkk
Copy link
Member Author

/assign @lonelyCZ

@lonelyCZ
Copy link
Member

Thanks @duanmengkk , I will review it ASAP. Could you give a sample of workflow including yaml and result? Perhaps, we can talk it in meeting tomorrow.

@duanmengkk
Copy link
Member Author

1.Firstly,apply a deploy and config in membercluster. kubectl apply -f test-promote.yaml --context cluster30

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: test
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s.kuboard.cn/name: test
  template:
    metadata:
      labels:
        k8s.kuboard.cn/name: test
    spec:
      volumes:
        - name: volume-2t8ic
          configMap:
            name: configdeps
      containers:
        - name: nginx
          image: 'nexus.cmss.com:8086/cnp/nginx:1.20.2'
          volumeMounts:
            - name: volume-2t8ic
              mountPath: /apps
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: configdeps
  namespace: default
data:
  description: "test-config"

deploy and config is in member cluster now
image
image
2.Secondly,promote deploy to control plane with '-d=true', kubectl karmada promote deploy test -c cluster30 -d=true
the result is
image
and RB and works is applied fine.
image
image

3.Now deploy has been promoted into control plane,when delete deploy in control plane,kubectl delete -f test-promote.yaml,the deploy will be deleted in member cluster either.
image

pkg/karmadactl/promote.go Show resolved Hide resolved
pkg/karmadactl/promote.go Outdated Show resolved Hide resolved
@duanmengkk duanmengkk force-pushed the feature_promotedeps branch from acc0861 to db38cb1 Compare May 29, 2022 07:07
@duanmengkk duanmengkk force-pushed the feature_promotedeps branch from 95df015 to 71b44f4 Compare May 29, 2022 07:13
@duanmengkk duanmengkk requested review from lonelyCZ May 31, 2022 01:00
@duanmengkk
Copy link
Member Author

Any problems with this PR? @lonelyCZ

@lonelyCZ
Copy link
Member

lonelyCZ commented Jun 7, 2022

Thanks, I will review it ASAP.

return promote(controlPlaneRestConfig, obj, gvr, opts)
}

func promoteDeps(obj *unstructured.Unstructured, opts CommandPromoteOption, mapper meta.RESTMapper, gvr schema.GroupVersionResource, controlPlaneRestConfig *rest.Config) error {
interpreter := defaultinterpreter.NewDefaultInterpreter()
Copy link
Member

Choose a reason for hiding this comment

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

Is it limited if we only use defaultinterpreter?

return promote(controlPlaneRestConfig, obj, gvr, opts)
}

func promoteDeps(obj *unstructured.Unstructured, opts CommandPromoteOption, mapper meta.RESTMapper, gvr schema.GroupVersionResource, controlPlaneRestConfig *rest.Config) error {
interpreter := defaultinterpreter.NewDefaultInterpreter()
Copy link
Member

Choose a reason for hiding this comment

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

Is it limited if we only use defaultinterpreter?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think ? should we support customizedInterpreter in promote?

Copy link
Member

Choose a reason for hiding this comment

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

I think it is necessary because we can promote any resource, especially support CRD/CR.

Perhaps, we can listen some suggestions form @RainbowMango @mrlihanbo @GitHubxsy

Copy link
Member Author

@duanmengkk duanmengkk Jun 7, 2022

Choose a reason for hiding this comment

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

I think it is necessary because we can promote any resource, especially support CRD/CR.

Agree,But it looks a little difficult. As webhook handles resource in control plane,but promote handles resources in member cluster.
Let me doing some research on it.

Choose a reason for hiding this comment

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

I think it is necessary because we can promote any resource, especially support CRD/CR.

Agree,But it looks a little difficult. As webhook handles resource in control plane,but promote handles resources in member cluster. Let me doing some research on it.

Hey @duanmengkk I was looking into the issue could you give a little bit more context on the above comment you made. Thanks already

@ikaven1024
Copy link
Member

One question, when a CR is promoted, shall it's CRD to be promoted together?

@lonelyCZ
Copy link
Member

One question, when a CR is promoted, shall it's CRD to be promoted together?

Perhaps, we should promote CRD firstly.

@lonelyCZ
Copy link
Member

Hi @duanmengkk , Is there any progress on this PR?

@duanmengkk
Copy link
Member Author

No,We can close this pr first. I have no idea about it yet,unless we introduce a webhook to member cluster.

@duanmengkk duanmengkk closed this Jul 26, 2022
@duanmengkk duanmengkk deleted the feature_promotedeps branch September 16, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

support to promote dependency resources automatically
5 participants