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

operator: update operator crd when upgrading chart #4693

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

calvin0327
Copy link

What type of PR is this?
/kind feature

What this PR does / why we need it:
the crd will not be updated when upgrading karmada operator chart.
so, we can support a way, run a job to apply crd resource after installing operator deployment.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
and i have test for this:

$ helm install karmada-operator -n karmada-system --create-namespace ./charts/karmada-operator --dependency-update
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /Users/chenwen/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /Users/chenwen/.kube/config
NAME: karmada-operator
LAST DEPLOYED: Mon Mar 11 15:44:35 2024
NAMESPACE: karmada-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing karmada-operator.

Your release is named karmada-operator.

To learn more about the release, try:

  $ helm status karmada-operator -n karmada-system
  $ helm get all karmada-operator -n karmada-system

---
$ kubectl get po -n karmada-system  -w
NAME                               READY   STATUS    RESTARTS   AGE
karmada-operator-b7cf7f467-rwc9h   0/1     Pending   0          0s
karmada-operator-b7cf7f467-rwc9h   0/1     Pending   0          0s
karmada-operator-b7cf7f467-rwc9h   0/1     ContainerCreating   0          0s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Pending             0          0s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Pending             0          0s
karmada-operator-post-hook-install-crds-2vkn9   0/1     ContainerCreating   0          0s
karmada-operator-b7cf7f467-rwc9h                1/1     Running             0          2s
karmada-operator-post-hook-install-crds-2vkn9   1/1     Running             0          1s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Completed           0          2s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Completed           0          3s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Completed           0          4s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Completed           0          4s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Terminating         0          4s
karmada-operator-post-hook-install-crds-2vkn9   0/1     Terminating         0          4s

Does this PR introduce a user-facing change?:


Signed-off-by: calvin <wen.chen@daocloud.io>
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 11, 2024
@karmada-bot karmada-bot requested review from jrkeen and Poor12 March 11, 2024 07:46
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 11, 2024
@calvin0327 calvin0327 changed the title update operator crd when upgrading chart operator: update operator crd when upgrading chart Mar 11, 2024
@calvin0327
Copy link
Author

@chaosi-zju @RainbowMango PTAL, thanks

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.41%. Comparing base (6fae04e) to head (7b6c87d).

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4693      +/-   ##
==========================================
- Coverage   51.41%   51.41%   -0.01%     
==========================================
  Files         250      250              
  Lines       24979    24979              
==========================================
- Hits        12843    12842       -1     
- Misses      11430    11431       +1     
  Partials      706      706              
Flag Coverage Δ
unittests 51.41% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RainbowMango
Copy link
Member

/assign @chaosi-zju

I wonder if the CRDs can be installed at the first installation?

@chaosi-zju
Copy link
Member

chaosi-zju commented Mar 11, 2024

I wonder if the CRDs can be installed at the first installation?

I didn't get what does at the first installation mean?

The problem seems to be CRDs didn't upgrade when upgrading charts, which way are you considering?

---update---

Notes: the CRDs which calvin0327 refers is charts/karmada-operator/crds/operator.karmada.io_karmadas.yaml, not the karmada crd.

@chaosi-zju
Copy link
Member

Hi @calvin0327, let me try to describe my understanding of your PR.

Before this PR introduced, if I want to install karmada by operator, I should do following steps:

helm install karmada-operator -n karmada-system  --create-namespace --dependency-update ./charts/karmada-operator

kubectl apply -f ./charts/karmada-operator/crds/

cat >/tmp/karmada.yaml<<EOF
apiVersion: operator.karmada.io/v1alpha1
kind: Karmada
metadata:
  name: karmada
  namespace: karmada-system
EOF
kubectl apply -f karmada.yaml

After you this PR introduced, I can omit the second step (kubectl apply -f ./charts/karmada-operator/crds/), it will be automatically done by helm install, am I right?

@calvin0327
Copy link
Author

calvin0327 commented Mar 12, 2024

@chaosi-zju The reason for this pr is because helm does not apply crd resources when upgrading. If the karmada crd resource is updated, we need to update it manually.

So we need to use job in helm to do this, so that we can solve the problem that helm does not update crd.

this is reference: https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#some-caveats-and-explanations

@calvin0327
Copy link
Author

/assign @chaosi-zju

I wonder if the CRDs can be installed at the first installation?

yes, helm will install crds at first installation.

@calvin0327
Copy link
Author

@chaosi-zju any questions?

@chaosi-zju
Copy link
Member

@chaosi-zju any questions?

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 24, 2024
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[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 karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 25, 2024
@karmada-bot karmada-bot merged commit 4105790 into karmada-io:master Apr 25, 2024
13 checks passed
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/feature Categorizes issue or PR as related to a new feature. 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.

5 participants