Repository navigation
[kubernetes] show Service and Ingress resources for kubernetes app in… - #1912
Conversation
… dashboard Signed-off-by: Kirill Ilin <[email protected]>
Summary of ChangesHello Kirill Ilin (@sircthulhu), I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the visibility of Kubernetes Service and Ingress resources within the dashboard for the Kubernetes application. By introducing standardized labels to these resources and updating the resource definition to correctly identify them, the changes ensure that users can now view and manage these critical networking components directly from the dashboard interface, enhancing the overall user experience and operational clarity. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughAdds metadata labels for application identification and tenant resource marking across Kubernetes templates, and extends resource configuration to include nginx ingress components in the ApplicationDefinition wiring for Kubernetes resources. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request aims to make Service and Ingress resources for Kubernetes applications visible in the dashboard. This is achieved by adding identifying labels to the resources and updating the ApplicationDefinition to include them. While the changes appear to be functionally correct, I've identified a couple of areas where maintainability can be improved. Specifically, there's some duplication of labels that could be centralized into a Helm helper template, and the resource selection in the ApplicationDefinition could be made more robust by using label selectors instead of hardcoded resource names.
| labels: | ||
| apps.cozystack.io/application.group: apps.cozystack.io | ||
| apps.cozystack.io/application.kind: Kubernetes | ||
| apps.cozystack.io/application.name: {{ .Release.Name | trimPrefix "kubernetes-" }} | ||
| internal.cozystack.io/tenantresource: "true" |
There was a problem hiding this comment.
These labels are duplicated in multiple places: here for the Ingress, for the Service in this same file (lines 49-53), and in packages/apps/kubernetes/templates/cloud-config.yaml for infraLabels (lines 13-17).
To improve maintainability and prevent inconsistencies, I recommend defining these common labels in a helper template within _helpers.tpl.
For example, you could add a kubernetes.cozy.app.labels template:
{{- define "kubernetes.cozy.app.labels" -}}
apps.cozystack.io/application.group: apps.cozystack.io
apps.cozystack.io/application.kind: Kubernetes
apps.cozystack.io/application.name: {{ .Release.Name | trimPrefix "kubernetes-" }}
internal.cozystack.io/tenantresource: "true"
{{- end -}}And then include it in your resources:
labels:
{{- include "kubernetes.cozy.app.labels" . | nindent 4 }}This would centralize the label definitions, making them easier to manage.
| include: | ||
| - resourceNames: | ||
| - kubernetes-{{ .name }} | ||
| - kubernetes-{{ .name }}-ingress-nginx | ||
| - matchLabels: | ||
| cluster.x-k8s.io/cluster-name: kubernetes-{{ .name }} | ||
| ingresses: | ||
| exclude: [] | ||
| include: | ||
| - resourceNames: | ||
| - kubernetes-{{ .name }} | ||
| - kubernetes-{{ .name }}-ingress-nginx |
There was a problem hiding this comment.
Instead of hardcoding the resource name kubernetes-{{ .name }}-ingress-nginx, it's more robust and idiomatic in Kubernetes to use labels for resource selection. Since you're adding labels to the Service and Ingress resources, you can leverage them here for discovery. This makes the configuration more maintainable and less brittle to potential resource name changes.
I suggest using a matchLabels selector for the new application labels, for both services and ingresses, instead of extending the resourceNames list.
include:
- resourceNames:
- kubernetes-{{ .name }}
- matchLabels:
cluster.x-k8s.io/cluster-name: kubernetes-{{ .name }}
- matchLabels:
apps.cozystack.io/application.group: apps.cozystack.io
apps.cozystack.io/application.kind: Kubernetes
apps.cozystack.io/application.name: {{ .name }}
ingresses:
exclude: []
include:
- resourceNames:
- kubernetes-{{ .name }}
- matchLabels:
apps.cozystack.io/application.group: apps.cozystack.io
apps.cozystack.io/application.kind: Kubernetes
apps.cozystack.io/application.name: {{ .name }}|
Successfully created backport PR for |
What this PR does
Add labels and selectors for Service and Ingress resources to correctly show them in corresponding tabs for Kubernetes app in dashboard
Release note
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.