Hello <@ULVA73B9P>. For this helm chart I am feedi...
# ask-marvin
a
Hello @Marvin. For this helm chart I am feeding the values into a templatefile in terraform, but there seems to be no way to feed in the portNumber for the service in the ingress. https://github.com/PrefectHQ/prefect-helm/blob/main/charts/prefect-server/values.yaml My terraform code looks like this:
Copy code
resource "helm_release" "prefect_server" {
  name       = "prefect-server"
  namespace  = "${var.environment}-prefect"
  chart      = "prefect-server"
  repository = "<https://prefecthq.github.io/prefect-helm>"
  version    = "2024.5.23194919"



  values = [templatefile("${path.module}/values.yaml", {
    PREFECT_API_URL = "prefect.${var.product_name}-${var.environment}.********:4200/api"
    EXISTING_SECRET = kubernetes_secret.db_secret.metadata[0].name
    EXTERNAL_HOST = data.aws_db_instance.selected.address
    HOST_NAME = "${var.product_name}-${var.environment}.*******.com"
    CERTIFICATE_ARN = data.aws_acm_certificate.env.arn
    HOST_NAME = "prefect.${var.product_name}-${var.environment}.*****.com"
  })]



}
m
It appears that the official documentation and GitHub issues don't directly address how to set the
portNumber
for the service in the ingress for the Prefect Helm chart. However, based on standard Helm chart configurations, you can specify such settings via the
values.yaml
file. Here's a potential way to include the port settings in your
values.yaml
file:
Copy code
yaml
ingress:
  enabled: true
  hosts:
    - host: "prefect.${var.product_name}-${var.environment}.*******.com"
      paths:
        - path: /
          pathType: Prefix
          service:
            name: prefect-server
            port:
              number: 4200
  annotations:
    # Add your ingress annotations here
  tls:
    - hosts:
        - "prefect.${var.product_name}-${var.environment}.*******.com"
      secretName: "${var.product_name}-${var.environment}-tls"
You can then reference this
values.yaml
file in your Terraform code:
Copy code
hcl
resource "helm_release" "prefect_server" {
  name       = "prefect-server"
  namespace  = "${var.environment}-prefect"
  chart      = "prefect-server"
  repository = "<https://prefecthq.github.io/prefect-helm>"
  version    = "2024.5.23194919"

  values = [templatefile("${path.module}/values.yaml", {
    PREFECT_API_URL = "prefect.${var.product_name}-${var.environment}.********:4200/api"
    EXISTING_SECRET = kubernetes_secret.db_secret.metadata[0].name
    EXTERNAL_HOST = data.aws_db_instance.selected.address
    HOST_NAME = "${var.product_name}-${var.environment}.*******.com"
    CERTIFICATE_ARN = data.aws_acm_certificate.env.arn
    # No need to set HOST_NAME again, it's already defined above
  })]
}
Adjust the
name
,
namespace
, and other variables accordingly to fit your setup. For further details or if you encounter issues, consider checking out the Prefect Helm chart repository and their GitHub documentation for any updates or community advice.
a
@Marvin That's not at all what I asked.. For the values in the chart here, please tell me which one sets the service port number for the ingress:
Copy code
ingress:
  # -- enable ingress record generation for server
  enabled: true

  # -- port for the ingress' main path
  #servicePort: 4200

  ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .
  ## ref: <https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/>
  # -- IngressClass that will be used to implement the Ingress (Kubernetes 1.18+)
  className: ""
  host:
    # -- default host for the ingress record
    hostname: ${HOST_NAME}
    # -- default path for the ingress record
    path: /

    # -- ingress path type
    pathType: Prefix
m
By examining the provided
values.yaml
snippet, it appears that the field responsible for setting the service port number for the ingress is commented out:
Copy code
yaml
# -- port for the ingress' main path
#servicePort: 4200
You need to uncomment and set the
servicePort
to the desired value. Here's the adjusted configuration:
Copy code
yaml
ingress:
  # -- enable ingress record generation for server
  enabled: true

  # -- port for the ingress' main path
  servicePort: 4200

  # This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .
  # ref: <https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/>
  # -- IngressClass that will be used to implement the Ingress (Kubernetes 1.18+)
  className: ""
  host:
    # -- default host for the ingress record
    hostname: ${HOST_NAME}
    # -- default path for the ingress record
    path: /

    # -- ingress path type
    pathType: Prefix
Make sure to modify your
values.yaml
to include
servicePort: 4200
and adjust the port number as required for your service.
a
@Marvin when I terraform the helm chart, I get the following error:
Copy code
module.prefect.helm_release.prefect_server: Modifying... [id=prefect-server]
╷
│ Error: values don't meet the specifications of the schema(s) in the following chart(s):
│ prefect-server:
│ - ingress: Additional property servicePort is not allowed
│ 
│ 
│   with module.prefect.helm_release.prefect_server,
│   on ../../tfmodules/prefect/main.tf line 1, in resource "helm_release" "prefect_server":
│    1: resource "helm_release" "prefect_server" {
│ 
╵
m
The error message indicates that the
servicePort
property is not recognized by the Helm chart's schema for the
ingress
section, suggesting that this field may not be used or supported in the
values.yaml
file for the Prefect Helm chart. Let's re-examine the values in the Helm chart and review the official Prefect Helm chart's `values.yaml` file directly for how ports are typically configured. To set the service port for ingress, we should configure the
service
section instead:
Copy code
yaml
ingress:
  # Enable ingress record generation for server
  enabled: true

  # This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .
  # ref: <https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/>
  # IngressClass that will be used to implement the Ingress (Kubernetes 1.18+)
  className: ""
  host:
    # Default host for the ingress record
    hostname: ${HOST_NAME}
    # Default path for the ingress record
    path: /
    # Ingress path type
    pathType: Prefix

service:
  # type of service
  type: ClusterIP
  # Commented out: port and targetPort for the ingress
  ports:
    - name: http
      port: 80
      targetPort: 4200
In the above configuration, the
service.ports[0].targetPort
should be set to the desired port, which in your case is
4200
. Ensure your Terraform template file reflects this correctly:
Copy code
hcl
resource "helm_release" "prefect_server" {
  name       = "prefect-server"
  namespace  = "${var.environment}-prefect"
  chart      = "prefect-server"
  repository = "<https://prefecthq.github.io/prefect-helm>"
  version    = "2024.5.23194919"

  values = [templatefile("${path.module}/values.yaml", {
    PREFECT_API_URL = "prefect.${var.product_name}-${var.environment}.********:4200/api"
    EXISTING_SECRET = kubernetes_secret.db_secret.metadata[0].name
    EXTERNAL_HOST = data.aws_db_instance.selected.address
    HOST_NAME = "${var.product_name}-${var.environment}.*******.com"
    CERTIFICATE_ARN = data.aws_acm_certificate.env.arn
  })]
}
Ensure your
values.yaml
file has the correct
service
configuration. If you encounter issues, check for an updated or more detailed example from the official repository.