Fixing the Auto-Generated Helm Chart
In this lesson, we will fix the auto-generated Helm chart by adding dependencies for MongoDB. Moreover, we will perform checks to confirm that the application is running.
Even though the code of the application is small, I will save you from going through it. Instead, I’ll let you know right away what’s missing and what parts of the chart need to be added or modified.
Adding DB
environment variable
First of all, the application requires an environment variable called DB
. The code is using it to obtain the address of the database. That brings us to the first thing missing in the chart generated by Jenkins X; there is no definition for MongoDB.
The first step is to open charts/go-demo-6/templates/deployment.yaml in your favorite editor. That’s where the Deployment for the application is defined, and that’s where we need to add the variable.
Please locate the code that follows.
...imagePullPolicy: {{ .Values.image.pullPolicy }}env:...
Now, add the env
section with the name
set to DB
and the value {{ template "fullname" . }}-db
. The final version of the snippet listed above should be as follows.
...imagePullPolicy: {{ .Values.image.pullPolicy }}env:- name: DBvalue: {{ template "fullname" . }}-db...
Save the file.
Adding MongoDB to the Helm chart
Next, we need to add MongoDB to the Helm chart that was created for us. Now, we could start writing Helm templates for the MongoDB StatefulSet and a Service. We could spend time trying to figure out how to replicate data between its replicas, and probably a few other things that might not be obvious from the start. ...