Add load balancer created by helm chart to project

Posted June 15, 2020 4.4k views
WordPressLoad BalancingKubernetesTerraformDigitalOcean Volumes

Hi. I have a Terraform project that does the following:
1) creates a VPC
2) provisions a k8s cluster and adds it to the aforementioned VPC
3) creates a project
4) adds the k8s cluster to the project
5) applies a helm chart that installs Wordpress

During the installation, the chart provisions two volumes and a load balancer which I would like to add to the project but can’t see to figure out how to get their data in Terraform to do so.

Does anybody have advice on how to add the volumes and the load balancer to the project?

Or, is there any possibility to create the volumes + PVCs and add them to the project and then make the chart use the resources already provisioned instead of provisioning new ones?

Thanks a lot!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi, I would start with the following steps to make sure that everything is working as expected:

  1. create a project
  2. create a cluster
  3. add the cluster to project
  4. add Wordpress using Helm chart

Note: One should be able to complete steps 2 - 3 within their local development environment.

After you successfully complete the above steps, then you can look at automating the provisions of your cluster using Terraform.

Think different and code well,


  • Hi. Thank you for your answer. I followed your instructions and went on to manually create all the resources in the order you indicated but the result is the same. I added the k8s cluster to the project with doctl before installing the Wordpress chart.

    The load balancer is created in a different project, not in the one containing the k8s cluster and the other resources. It seems to be pointing to the right droplets but it’s in the wrong place.

    Is there a way to get the ID of the load balancer that points to one of the nodes in my k8s cluster and then to identify the project for that droplet? Maybe this way I could write another script that uses doctl, to assign the load balancer to the right project after it’s created.

    • Hi, it seems that you’re creating the load balancer outside the K8s cluster. Next, you should be able to locate the load balancers within the Networking -> Load Balancers section of the DO UI. Next, can you tell me which Helm chart you’re using for Wordpress?

      Think different and code well,


      • Hi. The load balancer is created by the helm chart. Since I have no idea how to personalize the chart, it’s created under the first project in the UI list.

        I know how to locate the load balancer in Networking but I have an automated procedure that creates everything. I’d like to create it directly or move it to the project after creation.

        Regarding the chart, I’m using the bitnami/wordpress helm chart.

        Thank you!

        • Hey servicesShrimp, the Helm chart initiates the creation of the load balancer when creating the wordpress service. The DO infrastructure actually does the creation of the underlying load balancer. Next, you can configure that Wordpress Helm Chart by changing all the settings located here when installing the chart. Finally, the chart doesn’t allow one to configure the underlying load balancer.

          Think different and code well,


      • OK, I was able to get Wordpress up and operational by doing the following:

        1. create a project
        2. create a cluster
        3. add the cluster to project
        4. add Wordpress using Helm chart
        helm repo add bitnami
        helm install my-release \
          --set wordpressUsername=admin \
          --set wordpressPassword=password \
          --set mariadb.mariadbRootPassword=secretpassword \

        In your local terminal, you should see something similar to the following:

        ➜ kubectl get all
        NAME                                        READY   STATUS    RESTARTS   AGE
        pod/my-release-mariadb-0                    1/1     Running   0          2m45s
        pod/my-release-wordpress-55578bc59c-jnlxc   1/1     Running   0          2m45s
        NAME                           TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)                      AGE
        service/kubernetes             ClusterIP      <none>            443/TCP                      36m
        service/my-release-mariadb     ClusterIP   <none>            3306/TCP                     2m46s
        service/my-release-wordpress   LoadBalancer   80:32265/TCP,443:32541/TCP   2m45s
        NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
        deployment.apps/my-release-wordpress   1/1     1            1           2m45s
        NAME                                              DESIRED   CURRENT   READY   AGE
        replicaset.apps/my-release-wordpress-55578bc59c   1         1         1       2m45s
        NAME                                  READY   AGE
        statefulset.apps/my-release-mariadb   1/1     2m45s

        The Wordpress Helm chart will create two services: my-release-mariadb and my-release-wordpress. When creating the my-release-wordpress service, this will take a bit of time because it needs to create an external IP. Furthermore, this Helm chart will tell DO to create a load balancer to support the my-release-wordpress service. Thus, you shouldn’t have to use a load balancer from another project. If you have any additional questions, please do post here. Gotta run and good luck.

        Think different and code well,


        • Hi Conrad. By using the Wordpress Helm chart the load balancer gets created automatically but I can’t specify the project, thus it ends up under a different project than my other resources.

          You said that I don’t need to use a load balancer from another project nor do I want to but it’s how it automatically gets created and I have no idea how to change this. It’s basically what I need, how to create the resource inside my project OR how to identify it after it’s created and move it then.


          • Hey servicesShrimp, the easiest way to do this is as follows:

            1. create a project
            2. set this project as the default (i.e. Project Name -> Settings -> This is my default project
            3. Click the checkbox
            4. Now, when creating any resource(s), they should be associated to your selected default project.

            I would really like to see this process automated a bit so that a user doesn’t have to click a checkbox inside the project’s settings. For example, I create the project and it becomes the default project or I change projects and it becomes the default project. Also, it would be nice if deleting the project would also delete its associated resources.

            Next, if you’re looking to move existing resource(s) to a specific project, then I recommend reading the documentation here.

            Gotta run and I wish the above information helps you to move forward in your project.

            Think different and code well,


This was not sufficiently answered as I understand the question.
@servicesShrimp specifically stated that he was automating the rollout using the terraform helm provider and, while it rolled out wordpress, a DO load balancer was created. His question was simply how he could get a handle on that (it’s URN possibly) so that subsequent terraform code can refer to it.

Asking @servicesShrimp to click buttons in a UI seems to have confused this point.

I’m also experiencing the same issue, although I need the loadbalancer reference to create an A record for it after it’s created.

If anyone has any pointers, please do point!