karmada icon indicating copy to clipboard operation
karmada copied to clipboard

Feature: karmadactl init supports deployment through configuration files

Open tiansuo114 opened this issue 1 year ago • 16 comments
trafficstars

What type of PR is this? /kind feature

What this PR does / why we need it: Increased karmadactl's ability to init by reading configuration files From

user@virtual-machine:karmada/_output/bin/linux/amd64# karmadactl init --karmada-apiserver-image registry.k8s.io/kube-apiserver:v1.30.0 --karmada-kube-controller-manager-image registry.k8s.io/kube-controller-manager:v1.30.0 --etcd-image registry.k8s.io/etcd:3.5.13-0 --etcd-init-image docker.io/library/alpine:3.19.1 --karmada-aggregated-apiserver-image docker.io/karmada/karmada-aggregated-apiserver:v1.10.3 --karmada-controller-manager-image docker.io/karmada/karmada-controller-manager:v1.10.3 --karmada-scheduler-image docker.io/karmada/karmada-scheduler:v1.10.3 --karmada-webhook-image docker.io/karmada/karmada-webhook:v1.10.3 --crds /home/tiansuo/Downloads/crds.tar.gz ....

Turn into

user@virtual-machine:karmada/_output/bin/linux/amd64# karmadactl init --config config.yaml

Example of config.yaml

apiVersion: config.karmada.io/v1alpha1
kind: KarmadaInitConfig
metadata:
  name: karmada-init
spec:
  karmadaCrds: "https://github.com/karmada-io/karmada/releases/download/v1.10.3/crds.tar.gz"
  etcd:
    local:
      imageRepository: "registry.k8s.io/etcd"
      imageTag: "3.5.13-0"
      initImage:
        imageRepository: "docker.io/library/alpine"
        imageTag: "3.19.1"
  components:
    karmadaAPIServer:
      imageRepository: "registry.k8s.io/kube-apiserver"
      imageTag: "v1.30.0"
    karmadaAggregatedAPIServer:
      imageRepository: "docker.io/karmada/karmada-aggregated-apiserver"
      imageTag: "v1.10.3"
    kubeControllerManager:
      imageRepository: "registry.k8s.io/kube-controller-manager"
      imageTag: "v1.30.0"
    karmadaControllerManager:
      imageRepository: "docker.io/karmada/karmada-controller-manager"
      imageTag: "v1.10.3"
    karmadaScheduler:
      imageRepository: "docker.io/karmada/karmada-scheduler"
      imageTag: "v1.10.3"
    karmadaWebhook:
      imageRepository: "docker.io/karmada/karmada-webhook"
      imageTag: "v1.10.3"

Which issue(s) this PR fixes: Fixes #3464 This PR is related to the documentation PR: https://github.com/karmada-io/karmada/pull/5277 Special notes for your reviewer: @liangyuanpeng Does this PR introduce a user-facing change?:


tiansuo114 avatar Aug 12 '24 13:08 tiansuo114

Hi, this is a bot comment, just put the label of ok-to-test here, you can comment /retest to rerun github workflow if github workflow is failing and it's not releated with this PR.

/ok-to-test

liangyuanpeng avatar Aug 12 '24 13:08 liangyuanpeng

please link to the proposal at PR describe.

releated #5277

liangyuanpeng avatar Aug 12 '24 13:08 liangyuanpeng

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 79.72973% with 45 lines in your changes missing coverage. Please review.

Project coverage is 41.53%. Comparing base (f7d6da3) to head (9b9847e).

Files with missing lines Patch % Lines
pkg/karmadactl/cmdinit/kubernetes/deploy.go 78.61% 29 Missing and 5 partials :warning:
pkg/karmadactl/cmdinit/config/config.go 89.28% 4 Missing and 2 partials :warning:
pkg/karmadactl/cmdinit/config/types.go 0.00% 5 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5357      +/-   ##
==========================================
+ Coverage   41.37%   41.53%   +0.16%     
==========================================
  Files         651      653       +2     
  Lines       55265    55484     +219     
==========================================
+ Hits        22868    23048     +180     
- Misses      30917    30949      +32     
- Partials     1480     1487       +7     
Flag Coverage Δ
unittests 41.53% <79.72%> (+0.16%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 12 '24 13:08 codecov-commenter

This PR is related to the documentation PR: #5277

tiansuo114 avatar Aug 12 '24 13:08 tiansuo114

please link to the proposal at PR describe.请链接到 PR 描述中的提案。

releated #5277

Ok, I've now connected all three related PRS to document pr

tiansuo114 avatar Aug 12 '24 13:08 tiansuo114

Can we start the review of this pr first, or do we still need to wait for the merge of https://github.com/karmada-io/karmada/pull/5277 before we can conduct the review of this pr @liangyuanpeng

tiansuo114 avatar Sep 21 '24 13:09 tiansuo114

I think we need to merge proposal first

liangyuanpeng avatar Sep 23 '24 10:09 liangyuanpeng

The code in this branch has been modified to use the configuration file format from the existing proposal for deployment, and it has been verified that the deployment works correctly. Additionally, the proposal has already been merged into the master branch. Can we start the review now? @liangyuanpeng

Furthermore, I have some questions in another PR, and we might need to discuss them further.

tiansuo114 avatar Oct 11 '24 09:10 tiansuo114

This PR first reads the configuration file and then convert to CommandInitOption, which is compatible with the legacy code unless you refactor the legacy code logic. Do you agree?

Yeah, I agree.

RainbowMango avatar Oct 21 '24 09:10 RainbowMango

This PR first reads the configuration file and then convert to CommandInitOption, which is compatible with the legacy code unless you refactor the legacy code logic. Do you agree?

agree

zhzhuang-zju avatar Oct 21 '24 09:10 zhzhuang-zju

This PR first reads the configuration file and then convert to CommandInitOption, which is compatible with the legacy code unless you refactor the legacy code logic. Do you agree?

cc @zhzhuang-zju @RainbowMango

Yes, the code here should be fully compatible with the previous code because the CommandInitOption structure is still being used in the actual deployment, while the KarmadaInitConfig structure is only used for reading the configuration file.

tiansuo114 avatar Oct 21 '24 09:10 tiansuo114

@tiansuo114 Please help to squash commits, and here is the guide line: https://karmada.io/docs/contributor/github-workflow/#squash-commits. I can help to take a look tomorrow.

RainbowMango avatar Oct 21 '24 12:10 RainbowMango

@tiansuo114 Please help to squash commits, and here is the guide line: https://karmada.io/docs/contributor/github-workflow/#squash-commits.请帮助压缩提交,这里是指导方针: https ://karmada.io/docs/contributor/github-workflow/#squash-commits。 I can help to take a look tomorrow.明天我可以帮忙看看。

At first, I wasn't sure whether to squash commits as I go or to keep each stage's commits and squash them all after the review to make it easier to track changes at different stages. I will start by doing a squash and wait for everyone's review.

tiansuo114 avatar Oct 21 '24 12:10 tiansuo114

Generally looks good to me after a quick go-through. Just some nits about naming convention. @liangyuanpeng do you have any further comments? @tiansuo114 Have you tested it? Can you share the test report here?

I conducted some tests using kind cluster in a virtual machine on my local machine. I also attempted to add a test task in the CLI section of Karmada's GitHub CI workflow to verify whether the karmadactl init --init-config command runs correctly. (The detailed testing process can first be observed in this link)Following the guidance of my mentor, I plan to submit a separate PR to merge the test process into the main branch after the current PR is merged.

tiansuo114 avatar Oct 22 '24 08:10 tiansuo114

OK. /approve Leave LGTM to @liangyuanpeng for final decision.

RainbowMango avatar Oct 22 '24 08:10 RainbowMango

/retest

tiansuo114 avatar Oct 25 '24 08:10 tiansuo114

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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 avatar Oct 26 '24 02:10 karmada-bot

Hi, this is a bot comment, just put the label of ok-to-test here, you can comment /retest to rerun github workflow if github workflow is failing and it's not releated with this PR.

/ok-to-test

liangyuanpeng avatar Oct 26 '24 02:10 liangyuanpeng