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

Feature/helm pr deployment demo #9690

Closed
wants to merge 11 commits into from

Conversation

kliwniloc
Copy link

@kliwniloc kliwniloc commented Nov 6, 2024

Demo please ignore

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new test server entry for Kubernetes deployment.
    • Updated GitHub deployment instructions with new steps for Kubernetes.
    • Introduced a new section in the Helm chart NOTES.txt providing users with access instructions based on service type.
  • Chores

    • Updated .gitignore to exclude the charts directory from version control.
  • Refactor

    • Added template helper functions to enhance the Helm chart's templating capabilities.

Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Bump versions for Chart and appVersion.

Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Add url for k8s env

Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Add condition to check if delpoy:k8s tag exists for the PR

Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Set cancel-in-progress to true so that in scenarios where commits are
pushed fast or multiple tags are added at once we only run the most
recent pipeline.

Signed-off-by: Colin Wilk <colin.wilk@tum.de>
Copy link

coderabbitai bot commented Nov 6, 2024

Walkthrough

The pull request introduces several updates across different files. The docs/dev/testservers.rst document now includes a new test server entry for Kubernetes deployment and expanded GitHub deployment instructions. The .gitignore file has been modified to exclude the charts directory from version control. Additionally, the Helm chart's NOTES.txt file has been updated with instructions for accessing the application based on the service type. Finally, new template helper functions have been added to helm/artemis/templates/_helpers.tpl to enhance the Helm chart's configurability.

Changes

File Path Change Summary
docs/dev/testservers.rst Added new test server entry for Kubernetes deployment and updated GitHub deployment instructions.
helm/.gitignore Added charts directory to .gitignore to prevent it from being tracked by Git.
helm/artemis/templates/NOTES.txt Introduced instructions for accessing the application based on service type in the Helm chart.
helm/artemis/templates/_helpers.tpl Added multiple template helper functions to enhance name and label generation for Kubernetes resources.

Possibly related PRs

  • Development: Update test server documentation #8790: This PR updates the documentation in docs/dev/testservers.rst, which is directly related to the changes made in the main PR that also modifies this file to include new test server entries and deployment instructions.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (3)
helm/artemis/templates/NOTES.txt (1)

8-11: Consider adding a note about multi-node clusters

The current implementation gets the IP address of the first node, which might not be the correct node to access in a multi-node cluster. Consider adding a note to inform users they should use the IP address of the specific node they want to access.

  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "artemis.fullname" . }})
  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
+ echo "NOTE: In a multi-node cluster, you may need to use the IP address of the specific node you want to access"
🧰 Tools
🪛 LanguageTool

[uncategorized] ~9-~9: Loose punctuation mark.
Context: ...ervices {{ include "artemis.fullname" . }}) export NODE_IP=$(kubectl get nodes ...

(UNLIKELY_OPENING_PUNCTUATION)

helm/artemis/templates/_helpers.tpl (2)

33-43: Consider adding recommended Kubernetes label.

The implementation follows Kubernetes labeling conventions. Consider adding the recommended app.kubernetes.io/part-of label to better identify the application component.

 {{- define "artemis.labels" -}}
 helm.sh/chart: {{ include "artemis.chart" . }}
 {{ include "artemis.selectorLabels" . }}
 {{- if .Chart.AppVersion }}
 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
 {{- end }}
 app.kubernetes.io/managed-by: {{ .Release.Service }}
+app.kubernetes.io/part-of: artemis
 {{- end }}

53-64: Remove unnecessary empty line.

The implementation is correct, but there's an unnecessary empty line at the end of the function.

 {{- define "artemis.serviceAccountName" -}}
 {{- if .Values.serviceAccount.create }}
 {{- default (include "artemis.fullname" .) .Values.serviceAccount.name }}
 {{- else }}
 {{- default "default" .Values.serviceAccount.name }}
 {{- end }}
 {{- end }}
-
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fdc2501 and 505d447.

⛔ Files ignored due to path filters (37)
  • .github/workflows/build.yml is excluded by !**/*.yml
  • .github/workflows/helm_pr_deployment.yml is excluded by !**/*.yml
  • .github/workflows/helm_pr_deployment_delete.yml is excluded by !**/*.yml
  • docs/dev/testservers/github/k8s-deploy-complete.png is excluded by !**/*.png, !**/*.png
  • helm/artemis/Chart.lock is excluded by !**/*.lock, !**/*.lock
  • helm/artemis/Chart.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/autoscaler/horizontal-pod-autoscaler.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/activemq-broker-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/artemis-ci-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/artemis-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/artemis-mysql-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/artemis-usermanagement-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/artemis-vcs-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/jhipster-registry-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/configmaps/jhipster-registry-env-configmap.yml is excluded by !**/*.yml
  • helm/artemis/templates/deployments/_artemis-deployment.yml is excluded by !**/*.yml
  • helm/artemis/templates/deployments/activemq-broker.yml is excluded by !**/*.yml
  • helm/artemis/templates/deployments/artemis-deployment-profile.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/deployments/artemis-deployment.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/ingresses/ingress.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/monitors/podmonitor.yml is excluded by !**/*.yml
  • helm/artemis/templates/pvc/artemis-mysql.yml is excluded by !**/*.yml
  • helm/artemis/templates/pvc/artemis.yml is excluded by !**/*.yml
  • helm/artemis/templates/secrets/activemq-broker-secrets.yml is excluded by !**/*.yml
  • helm/artemis/templates/secrets/artemis-secrets.yml is excluded by !**/*.yml
  • helm/artemis/templates/secrets/artemis-usermanagement-secrets.yml is excluded by !**/*.yml
  • helm/artemis/templates/secrets/jhipster-registry-secrets.yml is excluded by !**/*.yml
  • helm/artemis/templates/services/activemq-broker-service.yml is excluded by !**/*.yml
  • helm/artemis/templates/services/artemis-service-profile.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/services/artemis-service.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/services/jhipster-registry-service.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/services/mysql-service.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/statefulsets/artemis-mysql.yml is excluded by !**/*.yml
  • helm/artemis/templates/statefulsets/artemis-statefulset.yaml is excluded by !**/*.yaml
  • helm/artemis/templates/statefulsets/jhipster-registry.yml is excluded by !**/*.yml
  • helm/artemis/templates/tests/test-connection.yaml is excluded by !**/*.yaml
  • helm/artemis/values.yaml is excluded by !**/*.yaml
📒 Files selected for processing (4)
  • docs/dev/testservers.rst (2 hunks)
  • helm/.gitignore (1 hunks)
  • helm/artemis/templates/NOTES.txt (1 hunks)
  • helm/artemis/templates/_helpers.tpl (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • helm/.gitignore
🧰 Additional context used
🪛 LanguageTool
helm/artemis/templates/NOTES.txt

[uncategorized] ~9-~9: Loose punctuation mark.
Context: ...ervices {{ include "artemis.fullname" . }}) export NODE_IP=$(kubectl get nodes ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~14-~14: Loose punctuation mark.
Context: ... svc -w {{ include "artemis.fullname" . }}' export SERVICE_IP=$(kubectl get svc...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~15-~15: Loose punctuation mark.
Context: ...pace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~18-~18: Loose punctuation mark.
Context: ...tes.io/name={{ include "artemis.name" . }},app.kubernetes.io/instance={{ .Release...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (7)
helm/artemis/templates/NOTES.txt (1)

2-7: LGTM: Ingress configuration is well-implemented

The Ingress URL construction properly handles multiple hosts, paths, and TLS configuration.

helm/artemis/templates/_helpers.tpl (5)

1-6: LGTM! Follows Helm best practices for name generation.

The implementation correctly handles name overrides and follows DNS naming conventions with proper truncation.


8-24: LGTM! Comprehensive implementation of fully qualified name generation.

The function properly handles all naming scenarios and follows Kubernetes naming conventions.


26-31: LGTM! Proper chart label generation.

Correctly handles version string sanitization for Kubernetes label compatibility.


45-51: LGTM! Proper selector labels implementation.

Correctly implements the minimum required labels for Kubernetes selectors.


65-82: 🛠️ Refactor suggestion

Improve Spring profiles string generation.

The current implementation has several potential issues:

  1. No spaces after commas makes the profile string less readable
  2. Could generate invalid profile strings with double commas if values are empty
  3. No validation of provider values

Consider this improved implementation:

 {{- define "artemis.springprofiles" -}}
-prod,artemis,decoupling
-{{- if .Values.application.userManagement.provider -}}
-,{{ .Values.application.userManagement.provider }}
-{{- end }}
-{{- if .Values.application.userManagement.ldap.enabled -}}
-,ldap
-{{- end }}
-{{- if .Values.application.versioncontrol.provider -}}
-,{{ .Values.application.versioncontrol.provider }}
-{{- end }}
-{{- if .Values.application.continuousintegration.provider -}}
-,{{ .Values.application.continuousintegration.provider }}
-{{- end }}
+{{- $profiles := list "prod" "artemis" "decoupling" -}}
+{{- if .Values.application.userManagement.provider -}}
+  {{- $profiles = append $profiles .Values.application.userManagement.provider -}}
+{{- end -}}
+{{- if .Values.application.userManagement.ldap.enabled -}}
+  {{- $profiles = append $profiles "ldap" -}}
+{{- end -}}
+{{- if .Values.application.versioncontrol.provider -}}
+  {{- $profiles = append $profiles .Values.application.versioncontrol.provider -}}
+{{- end -}}
+{{- if .Values.application.continuousintegration.provider -}}
+  {{- $profiles = append $profiles .Values.application.continuousintegration.provider -}}
+{{- end -}}
+{{- join "," $profiles -}}
 {{- end }}

This improved version:

  • Uses Helm's list and join functions for better string generation
  • Avoids potential double commas
  • Is more maintainable and easier to extend
docs/dev/testservers.rst (1)

56-58: Verify the test server configuration details.

The new Kubernetes test server entry introduces some differences from other entries:

  1. The URL uses a wildcard pattern (pr*) suggesting dynamic PR-based deployments
  2. Admin accounts are set to "Always" instead of "On Demand" like other servers

Could you clarify:

  • The reasoning behind having "Always" admin accounts?
  • Whether there are any security implications of this configuration?

Comment on lines +17 to +21
{{- else if contains "ClusterIP" .Values.artemis.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "artemis.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve ClusterIP configuration robustness

Two improvements are suggested:

  1. The local port (8080) should be configurable to avoid conflicts
  2. Pod selection should handle multiple replicas gracefully
  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "artemis.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
  export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
- echo "Visit http://127.0.0.1:8080 to use your application"
- kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+ export LOCAL_PORT={{ .Values.artemis.service.localPort | default "8080" }}
+ echo "Visit http://127.0.0.1:${LOCAL_PORT} to use your application"
+ echo "NOTE: If the application has multiple replicas, you might need to specify a different pod"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME ${LOCAL_PORT}:$CONTAINER_PORT

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~18-~18: Loose punctuation mark.
Context: ...tes.io/name={{ include "artemis.name" . }},app.kubernetes.io/instance={{ .Release...

(UNLIKELY_OPENING_PUNCTUATION)

Comment on lines +12 to +16
{{- else if contains "LoadBalancer" .Values.artemis.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "artemis.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.artemis.service.port }}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance cloud provider compatibility for LoadBalancer IP retrieval

The current implementation might not work correctly with all cloud providers, as some return a hostname instead of an IP address in the LoadBalancer ingress field.

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "artemis.fullname" . }}'
- export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ with index .status.loadBalancer.ingress 0 }}{{or .ip .hostname}}{{end}}")
  echo http://$SERVICE_IP:{{ .Values.artemis.service.port }}
+ echo "NOTE: Some cloud providers may return a hostname instead of an IP address"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- else if contains "LoadBalancer" .Values.artemis.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "artemis.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.artemis.service.port }}
{{- else if contains "LoadBalancer" .Values.artemis.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "artemis.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ with index .status.loadBalancer.ingress 0 }}{{or .ip .hostname}}{{end}}")
echo http://$SERVICE_IP:{{ .Values.artemis.service.port }}
echo "NOTE: Some cloud providers may return a hostname instead of an IP address"
🧰 Tools
🪛 LanguageTool

[uncategorized] ~14-~14: Loose punctuation mark.
Context: ... svc -w {{ include "artemis.fullname" . }}' export SERVICE_IP=$(kubectl get svc...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~15-~15: Loose punctuation mark.
Context: ...pace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status...

(UNLIKELY_OPENING_PUNCTUATION)

Comment on lines +117 to +131
GitHub Deployment
-----------------

1. Label your PR with deploy:k8s to initialize a deployment to Kubernetes.

2. Once the server is deployed you get a message from GitHub Actions

.. figure:: testservers/github/k8s-deploy-complete.png
:alt: GitHub Actions Comment: successful deployment

2. Perform your testing

a) For logs, log in to Rancher: https://rancher.ase.cit.tum.de

3. As soon as you're done with this PR, close or merge it and the deployment will be destroyed. Don't remove the label!
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Documentation needs improvements for clarity and completeness.

The Kubernetes deployment instructions could be enhanced:

  1. Fix step numbering (step 2 appears twice)
  2. Add a screenshot showing where to find and apply the deploy:k8s label
  3. Include expected deployment duration
  4. Add a troubleshooting section
  5. Explain what to do if deployment fails

Consider this structure:

 GitHub Deployment
 -----------------

 1. Label your PR with deploy:k8s to initialize a deployment to Kubernetes.
+    .. figure:: testservers/github/k8s-label-location.png
+        :alt: GitHub UI: Location of deploy:k8s label
+
+    Note: Deployment typically takes 5-10 minutes.

 2. Once the server is deployed you get a message from GitHub Actions

     .. figure:: testservers/github/k8s-deploy-complete.png
         :alt: GitHub Actions Comment: successful deployment

-2. Perform your testing
+3. Perform your testing

     a) For logs, log in to Rancher: https://rancher.ase.cit.tum.de

-3. As soon as you're done with this PR, close or merge it and the deployment will be destroyed. Don't remove the label!
+4. As soon as you're done with this PR, close or merge it and the deployment will be destroyed. Don't remove the label!
+
+Troubleshooting
+---------------
+
+If deployment fails:
+1. Check the GitHub Actions logs for error messages
+2. Ensure your PR branch is up to date with the main branch
+3. Contact the DevOps team if issues persist

Committable suggestion skipped: line range outside the PR's diff.

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

Successfully merging this pull request may close these issues.

1 participant