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

Solution #33

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

Solution #33

wants to merge 25 commits into from

Conversation

Andr1yK
Copy link

@Andr1yK Andr1yK commented Dec 8, 2024

No description provided.

All Kubernetes resources were migrated to a Helm chart structure, promoting better management and scalability. The resources now utilize Helm templating, allowing for dynamic namespace assignment and consistent naming conventions. Additionally, a Helm ignore file and chart metadata were added to support the deployment process.
Moved database and application secrets from hardcoded base64 encoded values in the secret.yml template to dynamically reading them from values.yaml with base64 encoding. This enhances maintainability and centralizes the configuration for better scalability and security management.
Updated RBAC and Deployment configurations to use Helm template syntax for better parameterization and reusability. Changed static names and namespaces to use Helm variables, enabling dynamic naming based on chart values. This enhances flexibility and maintains consistency across different environments.
Streamlined the deployment configuration by using a loop to handle secret environment variables. This change enhances maintainability and reduces the risk of manual errors by dynamically iterating over secret keys defined in the values file.
Updated the values.yaml file to enable configuration of CPU and memory resource limits and requests for the application through Helm chart values. This change ensures that resource constraints are consistent across different environments by using templated values in the deployment configuration.
This update centralizes rolling update settings and resource specifications by referencing values from the values.yaml file. The changes enhance maintainability and readability by enabling the flexibility to adjust parameters without modifying the deployment template. The code uses the "with" directive to streamline resource definitions and ensure consistency within the Helm chart.
This update externalizes the image repository and tag settings into the values.yaml file, allowing for easier modifications without changing the deployment template. The deployment template now dynamically pulls these values, enhancing flexibility and maintainability of the Helm chart configuration.
Introduced node affinity configuration in the `values.yaml` to allow dynamic assignment in the deployment template. This enhancement provides greater flexibility in scheduling pods on preferred nodes based on label "app".
Updated the Helm chart to dynamically configure the Horizontal Pod Autoscaler (HPA) using the `values.yaml` file. This change allows for more flexible scaling of the application by adjusting `minReplicas` and `maxReplicas` through configuration values.
Added support for customizable CPU and memory utilization targets in the HPA configuration by referencing values from the Helm chart's values.yaml file. This allows for flexibility in scaling behavior directly through Helm values, enhancing deployment customization. Updated the deployment name reference in the HPA template to use chart naming conventions.
Updated the Persistent Volume claim to use chart naming conventions, promoting consistency and avoiding name clashes. Introduced dynamic storage capacity in `values.yaml` to allow for flexible resource allocation. These changes enhance the configurability and reliability of the deployment process.
Updated the Helm chart to dynamically set PVC storage requests and service account names through values.yaml. This change improves flexibility and maintainability by centralizing configuration properties. Additionally, simplified deployment naming convention for consistency.
Renamed and refactored the Ingress resource to utilize Helm chart templating for better scalability and reusability. The Ingress name, service name, and namespace now use template expressions to dynamically adjust based on Helm values. This change simplifies configuration management and enhances adaptability across different environments.
This commit introduces a MySQL subchart to the Helm chart under the 'todoapp' directory, enhancing the application's database management capabilities. A new .helmignore file is added to prevent unnecessary files from being packaged. Additionally, the version of the main todoapp Chart.yaml is updated to 1.0.0 to mark this significant enhancement.
This commit moves MySQL Kubernetes resource files within the Helm chart directory structure to improve organization. It also updates these resources to use Helm's templating feature by parameterizing the namespace with `{{ .Values.namespace }}` to support configuration flexibility via `values.yaml`.
Replaced hardcoded resource names with templated names using the chart's name, enhancing flexibility and reusability across different environments. This change impacts StatefulSet, ConfigMap, Secret, and Service YAML configurations, aligning with Helm best practices. The update helps prevent naming collisions and simplifies deployment management.
This change updates the secret template to dynamically generate secrets using values from values.yaml. It enhances security and maintainability by removing hard-coded secrets and allows for easier configuration through Helm.
Replace hardcoded replica count with a values.yaml reference in the MySQL StatefulSet template. This change allows for easier configuration and management of the replica count according to deployment needs.
Updated the StatefulSet template to use a parameterized MySQL image repository and tag, allowing for more flexible image configuration. Corresponding values have been added to the values.yaml file to specify default image details. This change enhances the customization capabilities of the Helm chart.
Updated the MySQL StatefulSet template to use a variable for PVC storage size, allowing customization through values.yaml. This change improves flexibility by enabling users to define the storage size according to their requirements.
Refactored the MySQL StatefulSet template to allow customizable tolerations, node affinity, and pod anti-affinity settings using values from the Helm chart's values.yaml. This change enhances the deployability in different environments by supporting dynamic configuration of key affinity parameters.
This change allows customization of CPU and memory resource requests for the MySQL StatefulSet through values.yaml. It enhances flexibility in resource allocation for different deployment environments. The hard-coded values have been replaced with variables to improve maintainability.
Switch the deployment process to Helm by introducing a Helm release for the todoapp chart, including a dependency on MySQL. Update configuration details such as the DB_HOST, and ensure consistency with resource names by changing configMap and adding a mysql-service. Remove manual Kubernetes apply commands from the bootstrap script in favor of using Helm for deployment and management.
This commit introduces a new Helm chart template for deploying the Ingress-NGINX controller on Kubernetes. The configuration includes roles, service accounts, deployments, and related resources required for its operation. Additionally, an output.log file is added to log resource states and events in the namespaces.
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this pull request! While you've made great progress, there are a few critical issues that need to be addressed before we can approve the changes:

  1. Security Concerns with Secrets: Storing plaintext secrets in values.yaml is a significant security risk. Please consider using Kubernetes Secrets or a secret management tool to handle sensitive data securely.

  2. Namespace Configuration: The namespace value in .Values.namespace is not consistently defined in the values.yaml file. This could lead to deployment issues. Please ensure this value is set correctly, or provide a default to avoid potential problems.

  3. ServiceAccount Configuration: Ensure that the serviceAccountName in .Values.todoapp.rbac.serviceAccountName is correctly defined. Missing this could lead to issues with ServiceAccount creation.

  4. PersistentVolume Binding: The volumeName field is set to a specific value, which requires an existing PersistentVolume. If dynamic provisioning is intended, consider removing this field.

  5. Service Type: The Service is using NodePort. Verify if this is intentional, as it exposes the service on each node's port. Consider LoadBalancer or ClusterIP if this is not desired.

  6. ConfigMap Data: The ConfigMap data is set to null. Ensure this is intentional and update it if it should contain configuration data.

  7. Chart Dependencies: The dependencies section lacks the repository URL for the mysql chart. Please add this unless it's a local chart.

  8. Taint Command Syntax: The kubectl taint command in your script seems to have incorrect syntax. Please correct it to ensure proper node tainting.

Once these issues are resolved, your pull request will be in great shape! Keep up the good work, and don't hesitate to reach out if you need any help. 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

kubectl apply -f .infrastructure/app/nodeport.yml
kubectl apply -f .infrastructure/app/hpa.yml
kubectl apply -f .infrastructure/app/deployment.yml
kubectl taint nodes -l app=mysql app=mysql:NoSchedule

Choose a reason for hiding this comment

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

The kubectl taint command seems to have an incorrect syntax. The correct format should be kubectl taint nodes <node-name> <key>=<value>:<effect>. Ensure that you specify the node name or label correctly and provide the key, value, and effect in the correct format.

Copy link
Author

Choose a reason for hiding this comment

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

it works :)

Comment on lines 15 to 17
dependencies:
- name: mysql
version: 0.1.0

Choose a reason for hiding this comment

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

The dependencies section specifies a dependency on mysql, but it lacks the repository URL from where this dependency should be fetched. Consider adding a repository field to specify the source of the mysql chart, unless it's a local chart.

Copy link
Author

Choose a reason for hiding this comment

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

it's local dependency

kind: Secret
metadata:
name: {{ .Chart.Name }}-secrets
namespace: {{ .Values.namespace }}

Choose a reason for hiding this comment

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

Ensure that the namespace value in .Values.namespace is correctly defined in the values.yaml file. If it's not set, this could lead to deployment issues. Consider providing a default value or handling the case where it might be undefined.

Comment on lines 5 to 7
MYSQL_ROOT_PASSWORD: "1234"
MYSQL_USER: "app_user"
MYSQL_PASSWORD: "1234"

Choose a reason for hiding this comment

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

Storing plaintext passwords in values.yaml is a security risk. Consider using a more secure method to manage sensitive data, such as using Kubernetes Secrets or a secret management tool to inject these values securely.

kind: ConfigMap
metadata:
name: {{ .Chart.Name }}-config
namespace: {{ .Values.namespace }}

Choose a reason for hiding this comment

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

Ensure that the namespace value in .Values.namespace is correctly defined in the values.yaml file. If it's not set, this could lead to deployment issues. Consider providing a default value or handling the case where it might be undefined.

apiVersion: v1
metadata:
name: {{ .Values.todoapp.rbac.serviceAccountName }}
namespace: {{ .Values.namespace }}

Choose a reason for hiding this comment

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

Ensure that the namespace value in .Values.namespace is correctly defined in the values.yaml file. If it's not set, this could lead to deployment issues. Consider providing a default value or handling the case where it might be undefined.

kind: ServiceAccount
apiVersion: v1
metadata:
name: {{ .Values.todoapp.rbac.serviceAccountName }}

Choose a reason for hiding this comment

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

Ensure that the serviceAccountName value in .Values.todoapp.rbac.serviceAccountName is correctly defined in the values.yaml file. If it's not set, this could lead to issues with the ServiceAccount creation.

kind: Secret
metadata:
name: {{ .Chart.Name }}-secret
namespace: {{ .Values.namespace }}

Choose a reason for hiding this comment

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

Ensure that the namespace value in .Values.namespace is correctly defined in the values.yaml file. If it's not set, this could lead to deployment issues. Consider providing a default value or handling the case where it might be undefined.

type: Opaque
data:
{{- range $key, $value := .Values.todoapp.secrets }}
{{ $key }}: {{ $value | b64enc | quote }}

Choose a reason for hiding this comment

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

Ensure that the secrets values in .Values.todoapp.secrets are correctly defined in the values.yaml file. If they are not set, this could result in an empty Secret being created.

Comment on lines 9 to 13
SECRET_KEY: "@e2(yx)v&tgh3_s=0yja-i!dpebxsz^dg47x)-k&kq_3zf*9e*"
DB_NAME: "app_db"
DB_USER: "app_user"
DB_PASSWORD: "1234"
DB_HOST: "mysql-0.mysql-service.mysql.svc.cluster.local"

Choose a reason for hiding this comment

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

Storing plaintext secrets in values.yaml is a security risk. Consider using a more secure method to manage sensitive data, such as using Kubernetes Secrets or a secret management tool to inject these values securely.

Relocated the Helm chart for 'todoapp' from 'helm-chart' to '.infrastructure/helm-chart' for improved organization and clarity. Updated the bootstrap script to reflect the new Helm chart path. This change is intended to maintain consistency with the project’s directory naming conventions.
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great effort on your submission! 🎉 While your code is on the right track, there are a few critical issues that need attention to ensure full compliance with the task requirements:

  1. Security Concerns with Secrets: The task requires secrets to be managed via a values.yaml file using a range function. Unfortunately, the absence of this file prevents us from verifying this requirement.

  2. Namespace Configuration: Similarly, the namespace name should be controlled from a values.yaml file, which is missing.

  3. ServiceAccount Configuration: The Service Account Name in both Deployment and all RBAC objects should be controlled from a values.yaml file, which we cannot verify due to the missing file.

  4. PersistentVolume Binding: The pv capacity and pvc requests storage should also be controlled from a values.yaml file.

  5. Chart Dependencies: Explicit dependencies between todoapp and mysql charts should be defined in the Chart.yaml file, which is also missing.

  6. Taint Command Syntax: The kubectl taint command in bootstrap.sh needs to be reviewed for correct syntax. The correct format is kubectl taint nodes <node-name> <key>=<value>:<effect>.

Despite these issues, the decision to APPROVE your Pull Request is made to help you move forward with your learning journey. Please review the comments and address these critical issues in future submissions to avoid similar problems. Keep up the good work, and continue to improve your code! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

kubectl apply -f .infrastructure/app/nodeport.yml
kubectl apply -f .infrastructure/app/hpa.yml
kubectl apply -f .infrastructure/app/deployment.yml
kubectl taint nodes -l app=mysql app=mysql:NoSchedule

Choose a reason for hiding this comment

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

The kubectl taint command seems to have incorrect syntax. The correct format should be kubectl taint nodes <node-name> <key>=<value>:<effect>. Ensure that the node selector and taint key-value pair are correctly specified.

Copy link

@Alkaponees Alkaponees left a comment

Choose a reason for hiding this comment

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

LGMT!

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

Successfully merging this pull request may close these issues.

3 participants