Hi, Let us understand about Dependency. As we discussed earlier as a part of helm I'll be maintaining a chart and within chart
I can maintain n number of sub charts and I can manually go ahead and create the sub chart and maintain
the charts as modules so that I will be having the separation of the concern.
Now, having the subchart being maintained as a part of the main chart is going to be little tedious.
when I'm going to have more number of subcharts.
Rather, I can maintain the subchart as another chart and maintain that as a separate project and
add that as a dependency so I can add another chart as a dependency
Something like depends on chart a version 1.0 on the chart
It can be managed as a separate master chart.
So when that is being managed the chart itself can be managed as a separate project that can be added within
the repository and different versions can be managed and maintained.
And I can add the dependency of that particular chart within the main chart and automatically helm can
import those charts. This is what will be handled within the dependency.
Let's go ahead and see a small demo. I'm going to create a sample chart.
Let me create a chart with the name dependencytest.
I can install this particular chart
This time I'm going to set the service type as nodeport
So what will happen it'll attach the
service port to the nodeport so that I will be in a position to access that specific service.
And the name of the install is mydeptestinstall and by default the sample
It's going to create an nginx and it will get deployed in the nodeport.
So this particular service is deployed as a part of node port.
And it is serving in port 32021.
And it is running in this specific machine.
And this is the port I will be in a position to access nginx.
Now, let me go ahead and update the values file.
I'm getting into the chart. I'm updating the values file as a part of repository
Let me go ahead and change the repository to my own project and tag as
1.0.0 as a part of my docker hub repository
I do have this particular application to do. Lets assume
This particular application depends on another image.
Say mariadb I need to add the dependency as a part of the charts yaml file.
Now I have this particular repository.
Let me go ahead and update the charts.yaml file. Here
I need to add the dependency.
So I have added the dependencies and the name of the dependency is mariadb the version
And it will be picking from this specific repository. Like this
I can have n number of dependency.
Now I can go ahead and deploy this particular chart.
And before that, I need to do the build of this particular dependency so that it can import this
required dependent charts. Let me go ahead and do the build helm dependency build ./name of the chart.
So it's going to do the update of the repository and all the dependency chart as well.
It identified it depends on mariadb
so it's going to pull the mariadb dependent chart and any outdated charts which are there in the cache will
also get deleted. Now, if I get into this particular folder within charts, I should have the mariadb imported.
This way I will be in a position to maintain the subchart as a separate project and that can follow its own lifecycle.
And in case, if I feel any of the versions or any change happen to the charts.yaml file or
on the dependent charts I can go ahead and do the update using the command helm dependency update ./
And then the chart folder, it will keep itself up to date.
Now using this particular chart, I can go ahead and do the deployment.
Let me go ahead and list the deployments available.
This one was created with the basic example that got created automatically.
Now I'm going to do another deployment with the same chart.
helm install name of the deployment and the folder where I do have the resources.
Then I will set the service type equal to nodeport.
Let me go ahead and list the pods that got deployed kubectl get all
So as a part of the pods I should have this particular pod depwithmaria here I do have the
mariadb that is getting deployed, master and slave the same way I will be having the
required services and the required components.
So this is biggest advantage of maintaining the dependency, I can maintain all the dependent projects
and automatically helm
going to import that specific chart and deploy them together so that the maintenance of the subchart will
also be much easier and it can follow its own lifecycle
And the main project can follow its own lifecycle.
And the dependency command of build and update will facilitate to keep the dependent charts up to date.
Now let me go ahead and delete those installations helm uninstall
name of the deployment, the other one that we did for testing that also I'm removing it.
We do not have any installation. Let me check the kubernetes cluster as well. Here also the services, pods and
other components are removed.
So in a quick summary we learnt about how to maintain the dependency and how to add the dependency details
as a part of the chart.yaml file and how to add the dependency as a part of the charts.yaml
file and how to keep the dependency up to date using the update command and build it in the
beginning using the built command.