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 wordpress-microservice app into this repo #25

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

Conversation

5hubh49
Copy link
Member

@5hubh49 5hubh49 commented Dec 29, 2024

Build this wordpress app as part of a CRE task. This demo app consist of a frontend wordpress app, backend mariadb db and for custom metrics reporting I have used CronJob.

Shortcut: sc-118281

@5hubh49 5hubh49 changed the title WIP: demo wordpress-microservice app feat: add wordpress-microservice app into this repo Jan 10, 2025
Copy link
Member

@xavpaice xavpaice left a comment

Choose a reason for hiding this comment

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

  1. there's some commented sections that don't serve any purpose, I'd prefer to see them cleaned out.
  2. I'd like Diamon to review the chart and patterns, but an idea for the future improvements is to have a database be available either as part of this application (embedded) or as a separate, external, db with values we need to fill in. If the db is embedded, let's automate the password etc so folks don't need to fill it in, but can access that info later on.

Copy link
Member

@diamonwiggins diamonwiggins left a comment

Choose a reason for hiding this comment

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

Left you some feedback

dependencies:
- name: replicated
repository: oci://registry.replicated.com/library
version: 1.0.0-beta.31
Copy link
Member

Choose a reason for hiding this comment

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

Consider using Semver's version constraints to keep this up to date - https://github.com/Masterminds/semver#checking-version-constraints

@@ -0,0 +1,17 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
Copy link
Member

Choose a reason for hiding this comment

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

A few things to consider in this resource.

  1. Keep in mind to support airgap deployments or deployments using the registry proxy that you'll need additional templating for the images to make that work. Something that you can follow up on in a future story or decide to add in this PR. I'd say generally give a look at the documenation for configuring this resource - https://docs.replicated.com/vendor/helm-native-v2-using

  2. It's also a good practice to use helmUpgradeFlags to specify a timeout and/or the --wait flag for the charts that you install. See - https://docs.replicated.com/reference/custom-resource-helmchart-v2#helmupgradeflags

spec:
containers:
- name: metrics-reporter
image: "{{ .Values.cronjob.image }}"
Copy link
Member

Choose a reason for hiding this comment

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

It's a best practice to give users the flexibility to override different parts of the image. For example, someone may need to change the registry that's used, but might want to use the default tag that you specify in the chart.

spec:
containers:
- name: mariadb
image: mariadb:10.5
Copy link
Member

Choose a reason for hiding this comment

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

It's a best practice to give users the flexibility to override different parts of the image. For example, someone may need to change the registry that's used, but might want to use the default tag that you specify in the chart.

@@ -0,0 +1,44 @@
{{- if .Values.database.embedded }}
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

A few things to mention here:

  1. Keep in mind that you don't have much templated today. It's common for people to have use cases where they might need to modify affinity, tolerations, securityContext etc. I'm not saying you need to template out the entire Deployment API, but there's some low level things you're missing here in my opinion that you should consider adding.

  2. One thing to keep in mind is how will you ensure that as the values in the secret change, which you referencing with secretKeyRef in the environment variables, how will you make sure the Deployments is rolled out to use those new changes. This doesn't happen by default in Kubernetes. See - https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments for how to handle this.

  3. Any particular reason you are templating the namespace for this resource? By default the namespace specified with helm install will be applied to all non cluster scoped resources, so i'd say reconsider if you need to do this at all.

- port: {{ .Values.mariadb.service.port }}
targetPort: 3306
selector:
app: mariadb
Copy link
Member

Choose a reason for hiding this comment

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

You should probably be using a helper function to reference a label here instead of hardcoding

Comment on lines +10 to +11
password: {{ .Values.database.password | default (randAlphaNum 16) | b64enc }}
root-password: {{ .Values.database.rootPassword | default (randAlphaNum 16) | b64enc }}
Copy link
Member

Choose a reason for hiding this comment

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

In the case that the passwords are not specified via Values, i think this will generate random passwords each time the chart is rendered which would cause some issues if you aren't finding out how to also rotate these passwords each time in the database. This pattern can work, but you'll need to look into things like using the lookup function in helm to see if you can reuse an existing password that you've generated.

https://stackoverflow.com/questions/56170052/how-not-to-overwrite-randomly-generated-secrets-in-helm-templates

@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

The same feedback i gave on the other Deployment objects applies here as well.

targetPort: 80
nodePort: {{ .Values.wordpress.service.nodePort }}
selector:
app: wordpress
Copy link
Member

Choose a reason for hiding this comment

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

Use a helper function instead of hardcoding

maxActiveUsers: 100 # Maximum value for activeUsers

database:
embedded: true # Set to false to use an external database
Copy link
Member

Choose a reason for hiding this comment

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

I see you have the conditional for embedded vs. external but i don't see any option to provide a URI or an existing secret for connecting to that external database?

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