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

feat: add ingressclass from ingress #7813

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AlbeeSo
Copy link
Contributor

@AlbeeSo AlbeeSo commented May 22, 2024

Thank you for contributing to Velero!

Please add a summary of your change

To backup / restore ingressclass if ingress is backuped and spec.ingressClass is not nil.

After PR, ingressclass will be backuped with logs like

time="2024-05-22T17:48:36+08:00" level=info msg="Executing custom action" backup=velero/test-velero-ing logSource="pkg/backup/item_backupper.go:371" name=test-ing namespace=default resource=ingresses.networking.k8s.io
time="2024-05-22T17:48:36+08:00" level=info msg="Executing ingressAction" backup=velero/test-velero-ing cmd=/velero logSource="pkg/backup/actions/ingress_action.go:51" pluginName=velero
time="2024-05-22T17:48:36+08:00" level=info msg="Adding IngressClass nginx to additionalItems" backup=velero/test-velero-ing cmd=/velero logSource="pkg/backup/actions/ingress_action.go:61" pluginName=velero
time="2024-05-22T17:48:36+08:00" level=info msg="Done executing ingressAction" backup=velero/test-velero-ing cmd=/velero logSource="pkg/backup/actions/ingress_action.go:68" pluginName=velero

And will be restored with logs like

time="2024-05-22T17:59:30+08:00" level=info msg="Executing item action for ingresses.networking.k8s.io" logSource="pkg/restore/restore.go:1319" restore=velero/restore-ing
time="2024-05-22T17:59:30+08:00" level=info msg="Executing AddIngressClassFromIngAction" cmd=/velero logSource="pkg/restore/actions/add_ingressclass_from_ing_action.go:44" pluginName=velero restore=velero/restore-ing
time="2024-05-22T17:59:30+08:00" level=info msg="Adding IngressClass nginx as an additional item to restore" cmd=/velero logSource="pkg/restore/actions/add_ingressclass_from_ing_action.go:54" pluginName=velero restore=velero/restore-ing

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

Signed-off-by: AlbeeSo <suyashi1321@163.com>
Signed-off-by: AlbeeSo <suyashi1321@163.com>
Signed-off-by: AlbeeSo <suyashi1321@163.com>
Signed-off-by: AlbeeSo <suyashi1321@163.com>
@AlbeeSo AlbeeSo force-pushed the feat/add-ingclass-from-ing branch from ced78cc to 7bb8c22 Compare May 22, 2024 10:33
Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 59.25926% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 58.65%. Comparing base (49eab81) to head (7bb8c22).
Report is 16 commits behind head on main.

Current head 7bb8c22 differs from pull request most recent head a72ec6a

Please upload reports for the commit a72ec6a to get more accurate results.

Files Patch % Lines
pkg/cmd/server/plugin/plugin.go 0.00% 12 Missing ⚠️
...estore/actions/add_ingressclass_from_ing_action.go 63.63% 7 Missing and 1 partial ⚠️
pkg/backup/actions/ingress_action.go 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7813      +/-   ##
==========================================
- Coverage   58.67%   58.65%   -0.02%     
==========================================
  Files         345      347       +2     
  Lines       28743    28797      +54     
==========================================
+ Hits        16866    16892      +26     
- Misses      10448    10473      +25     
- Partials     1429     1432       +3     

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

@reasonerjt
Copy link
Contributor

IMHO, this should remain an "optional" plugin, b/c there may be other cases, where the same ingress will use a different ingressclass, or the same ingressclass like "default" may have different settings across different clusters.
We should be consistent with the way velero handles storageclass, and currently, we don't add storageclass automatically.

@AlbeeSo
Copy link
Contributor Author

AlbeeSo commented May 27, 2024

IMHO, this should remain an "optional" plugin, b/c there may be other cases, where the same ingress will use a different ingressclass, or the same ingressclass like "default" may have different settings across different clusters. We should be consistent with the way velero handles storageclass, and currently, we don't add storageclass automatically.

'default' may be different, but if 'default' already exists it will skip to restore by default, right?
Im curious why storageclass or ingressclass (which is different with volumesnapshotclass) is not automatically added during backup. As usually not-found errors will occur in such cases if they do not exist in restore cluster. Or the not-found error is expected and users need to adjust it by hand?

Signed-off-by: AlbeeSo <suyashi1321@163.com>
@AlbeeSo AlbeeSo force-pushed the feat/add-ingclass-from-ing branch from 28b63d1 to a72ec6a Compare May 27, 2024 10:08
@sseago
Copy link
Collaborator

sseago commented May 28, 2024

@AlbeeSo As for StorageClass in particular, those are generally configured by the cluster admin. Simply creating a StorageClass kubernetes resource without configuring the storage behind the storageclass wouldn't be helpful. If you are restoring a backup to a cluster where the storageclass for your PVCs doesn't exist, then you'd either need to first get the admin to create and configure that storageclass, or if there's another appropriate storageclass available, then you can use the storageclass mapping feature on restore to use storage already available.

@AlbeeSo
Copy link
Contributor Author

AlbeeSo commented May 30, 2024

@AlbeeSo As for StorageClass in particular, those are generally configured by the cluster admin. Simply creating a StorageClass kubernetes resource without configuring the storage behind the storageclass wouldn't be helpful. If you are restoring a backup to a cluster where the storageclass for your PVCs doesn't exist, then you'd either need to first get the admin to create and configure that storageclass, or if there's another appropriate storageclass available, then you can use the storageclass mapping feature on restore to use storage already available.

@AlbeeSo As for StorageClass in particular, those are generally configured by the cluster admin. Simply creating a StorageClass kubernetes resource without configuring the storage behind the storageclass wouldn't be helpful. If you are restoring a backup to a cluster where the storageclass for your PVCs doesn't exist, then you'd either need to first get the admin to create and configure that storageclass, or if there's another appropriate storageclass available, then you can use the storageclass mapping feature on restore to use storage already available.

Got it. So will action like "velero.io/change-ingress-class" be more suitable for this case, or restoring ingress class directly is enough? @reasonerjt @sseago

@AlbeeSo
Copy link
Contributor Author

AlbeeSo commented May 30, 2024

IMHO, restoring the ingressclass is enough, and I can add the "velero.io/change-ingress-class" to allow users to change it if need.

@reasonerjt
Copy link
Contributor

reasonerjt commented May 31, 2024

"velero.io/change-ingress-class" will not be needed as velero now supports resource modifier to modify restored resources in a more general way:
https://velero.io/docs/v1.14/restore-resource-modifiers/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants