Настройка web TLS для Trino в Kubernetes с помощью Helm

Обзор

Вы можете включить HTTPS на веб-эндпойнте координатора Trino (порт 8443), в то время как взаимодействие с worker-подами Trino продолжит осуществляться через HTTP (порт 8080). Для этого используйте группу параметров webTLS, как показано в примере. В отличие от настроек ssl, при которых keystore и truststore монтируются в поды координатора и в worker-поды, webTLS делает координатор Trino TLS-сервером, использующим keystore. Таким образом, worker-поды не получают доступ к приватному ключу.

Trino в Kubernetes поддерживает следующие варианты терминирования TLS (момент дешифрования TLS-соединения):

  • Терминирование TLS на уровне Ingress (по умолчанию). Ingress-контроллер терминирует (расшифровывает) TLS-трафик и перенаправляет запросы координатору по HTTP. Ingress для trino-cluster всегда направляет трафик на HTTP-порт координатора, поэтому настройки webTLS не влияют на поток трафика в этом режиме.

  • HTTPS на координаторе (webTLS). Порт 8443 открывается напрямую (с использованием балансировщика нагрузки или SSL-проброса на Ingress), а терминирование TLS на уровне Ingress не выполняется. webTLS — это альтернатива терминированию TLS на уровне Ingress, а не дополнение к нему.

Одновременное использование обоих вариантов может привести к двойному TLS-терминированию для каждого запроса. Двойное терминирование TLS происходит при использовании повторного шифрования (например, Ingress терминирует TLS-соединение с клиентом, а затем заново шифрует запросы и отправляет их координатору на порт 8443). Для этого необходимо направить бэкенд Ingress на HTTPS-порт и указать соответствующую аннотацию протокола бэкенда.

Требования

  • Кластер Trino, развернутый в Kubernetes согласно инструкции.

  • Keystore, созданный в формате PKCS12:

    $ openssl pkcs12 -export \
      -in <tls.crt> \
      -inkey <tls.key> \
      -out <keystore.p12> \
      -passout pass:<password>

Процедура развертывания

Шаг 1. Создание Secret с keystore

Создайте секрет Kubernetes с keystore-файлом в формате PKCS12. Например:

$ kubectl -n trino create secret generic trino-web-tls --from-file=keystore.p12

Шаг 2. Обновление конфигурации кластера Trino

  1. Отредактируйте Helm values файл trino-cluster.yaml, добавив блок настроек webTLS:

    trino-cluster.yaml
    image:
      registry: "hub.adsw.io"
      repository: "adc-develop-enterprise/trino"
      tag: "481.2-adc-develop-1.5.0"
      ## Specify a pullPolicy
      ## ref: https://kubernetes.io/docs/concepts/containers/images/#pre-pulled-images
      ##
      pullPolicy: "Always"
      ## Existing secret or secret to create to use for image pulling, they must exist in all product namespaces
      ##
      pullSecret:
        name: ""
        credentials: {}
    #      registry: private-docker-registry
    #      username: user
    #      password: pass
    
    ## @param useRanger enabled and disabled ranger.
    ##
    #useRanger: false
    
    ## Uncomment to enable LDAP authentication.
    ##
    #ldap:
    #  enabled: false
    
    ## Uncomment to enable Kerberos authentication.
    ##
    ## `service` defaults to `trino`; override only if clients expect a different service name.
    ##
    ## Keytab settings live under `kerberos.keytab`:
    ##   - Set `keytab.create: true` to let the chart render a Keytab CR; kerberos-operator
    ##     will then create the Secret with the keytab and krb5.conf. In that case you also
    ##     need `keytab.labelSelector` so the KDC host is picked up.
    ##   - If you already have a Secret with the keytab, leave `keytab.create` off and point
    ##     the chart at it with `keytab.secretName`.
    ##   - Use `keytab.additionalPrincipals` to add extra entries to the Keytab CR, for example
    ##     the ingress hostname (`HTTP/<ingress-dns>`) so SPNEGO works.
    ##
    #kerberos:
    #  realm: EXAMPLE.COM
    #  hostname: trino.example.com
    #  service: trino
    #  keytab:
    #    create: true
    #    secretName: ""
    #    labelSelector: {}
    #    rotation:
    #      interval: 720h
    #      checkInterval: 1h
    #    additionalPrincipals: []
    #    #  - HTTP/trino.example.com
    
    ## SSL / truststore and keystore settings.
    ## These are the truststore and keystore files that Trino uses as a client
    ## (for example to reach a TLS-enabled metastore). They are mounted into both
    ## coordinator and worker pods.
    ##
    #ssl:
    #  secretName: "ca-store"
    #  trustStoreKey: "truststore.jks"
    #  keyStoreKey: "keystore.jks"
    
    ## webTLS - HTTPS on the coordinator web endpoint. Rendered on the Cluster CR
    ## when `webTLS.secretName` is set (same as `ssl` above).
    ## Unlike `ssl` above (client truststore/keystore), webTLS terminates TLS on the
    ## coordinator itself: the coordinator serves its web/API endpoint over HTTPS on
    ## port 8443, while workers and internal discovery keep using HTTP 8080.
    ## Use it instead of terminating TLS at the ingress, not in addition to it.
    ##
    webTLS:
      secretName: trino-web-tls (1)
      keystoreKey: keystore.p12 (2)
      keystorePassword: "<password>" (3)
    
    ## Specify the name of configSecret where hadoop/ranger/connector config were stored
    ##
    configsSecretName: ""
    
    catalogs: (4)
      iceberg.properties:
        connector.name: iceberg
        fs.hadoop.enabled: "true"
        hive.config.resources: /opt/trino-server/etc/catalog/core-site.xml
        hive.hdfs.impersonation.enabled: "true"
        hive.metastore.thrift.impersonation.enabled: "true"
        hive.metastore.uri: thrift://ka-adh-k8s-1.ru-central1.internal:9083
    
    ## Controls whether changes to referenced Secrets trigger an automatic pod rollout.
    ## Set enabled: false to update referenced Secrets without restarting the workload;
    ## pods keep running the previous configuration until the policy is re-enabled.
    ## Defaults to enabled.
    ##
    #configurationRollout:
    #  enabled: true
    
    ## Uncomment to enable Trino History Server.
    ## `database` is required. The operator reads the credentials Secret but never
    ## creates it, so create it beforehand in the same namespace. It must contain
    ## the keys `username` and `password`; the JDBC URL is given separately as
    ## `database.url`. `coordinatorUrl` overrides the coordinator address used by
    ## the History Server; `url` overrides the History Server address used by the
    ## coordinator. `tls` turns on mutual TLS between the coordinator and the
    ## History Server; the Secret holds `keystore.p12` and `truststore.p12`, as a
    ## cert-manager Certificate with PKCS12 output writes it.
    ##
    #historyServer:
    #  database:
    #    url: jdbc:postgresql://pg.db:5432/trino_history
    #    credentials:
    #      secretName: trino-history-db
    #  coordinatorUrl: http://trino-coordinator.adh:8080
    #  url: http://trino-history-server.adh:8088
    #  tls:
    #    secretName: trino-history-tls
    #    keyStorePassword: changeit
    #    trustStorePassword: changeit
    #  replicas: 1
    #  args:
    #    ttl.duration: 30d
    
    worker:
    
      ## @param replicas set number of executor replicas
      ##
      replicas: 1
    
      annotations: {}
    
      ## Additional environment variables for the worker container
      ##
      envs: []
      #  - name: JAVA_TOOL_OPTIONS
      #    value: "-Djavax.net.ssl.trustStore=/etc/ssl/truststore.jks"
    
      ## Additional configuration that you want to be added to worker-config
      args: {}
      #  task.max-worker-threads: 8
    
      ## Set container requests and limits for resource like CPU or memory (essential for production workloads)
      ##
      resources: {}
        #limits:
        #  cpu: "2"
        #  memory: "8Gi"
        #requests:
      #  cpu: "2"
      #  memory: "8Gi"
    
      ## Pod-level security context applied to the pod (rendered as spec.<component>.spec.podSecurityContext)
      ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
      ##
      podSecurityContext: {}
      #  runAsUser: 1001
      #  runAsGroup: 1001
      #  fsGroup: 1001
    
      ## Container-level security context applied to the container (rendered as spec.<component>.spec.securityContext)
      ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
      ##
      securityContext: {}
      #  runAsNonRoot: true
      #  readOnlyRootFilesystem: true
      #  allowPrivilegeEscalation: false
      #  capabilities:
      #    drop:
      #      - ALL
    
      ## Request additional PVC for pod
      ##
      persistentVolume: {}
      #  mountPath: "/data/trino"
      #  volumeClaimTemplates:
      #    - metadata:
      #        name: data
      #      spec:
      #        accessModes: ["ReadWriteOnce"]
      #        resources:
      #          requests:
      #            storage: 10Gi
      #        storageClassName: default
    
      ## nodeAffinity: Object defining constraints to place pods on a specific set of Nodes
      ##
      nodeSelector: {}
    
      topologySpreadConstraints: []
    
      ## Allow a Pod to be scheduled onto nodes that have taints.
      ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
      ##
      tolerations: []
        # - key: "example-key"
      #   operator: "Exists"
      #   effect: "NoSchedule"
    
      ## affinity: Object defining soft rules to place pods on a specific set of Nodes or didn't place pod to nodes due to some conditions
      ##
      affinity: {}
      #  nodeAffinity:
      #      requiredDuringSchedulingIgnoredDuringExecution:
      #        nodeSelectorTerms:
      #        - matchExpressions:
      #          - key: topology.kubernetes.io/zone
      #            operator: In
      #            values:
      #            - antarctica-east1
      #            - antarctica-west1
      #      preferredDuringSchedulingIgnoredDuringExecution:
      #      - weight: 1
      #        preference:
      #          matchExpressions:
      #          - key: another-node-label-key
      #            operator: In
      #            values:
      #            - another-node-label-value
    
      startupProbe: {}
      #  httpGet:
      #    path: /v1/info
      #    port: 8080
      #    scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      livenessProbe: {}
      #  httpGet:
      #    path: /v1/info
      #    port: 8080
      #    scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      readinessProbe: {}
      #  exec:
      #    command:
      #      - sh
      #      - -c
      #      - test -f /opt/trino-server/etc/truststore/custom-truststore.jks
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      ## Mount additional secrets into the pod
      ##
      mountSecrets: []
      #  - secretName: my-secret
      #    mountPath: /etc/trino/my-secret
    
      ## Additional container/Service ports.
      ##
      ports: []
      #  - name: http-metrics
      #    containerPort: 9209
      #    servicePort: 9209
      #    protocol: TCP
    
    coordinator:
    
      ## @param replicas set number of executor replicas
      ##
      replicas: 1
    
      annotations: {}
    
      ## Additional environment variables for the coordinator container
      ##
      envs: []
      #  - name: JAVA_TOOL_OPTIONS
      #    value: "-Djavax.net.ssl.trustStore=/etc/ssl/truststore.jks"
    
      ## Additional configuration that you want to be added to coordinator-config
      args: {}
      #  query.max-memory-per-node: 2GB
    
      ## Set container requests and limits for resource like CPU or memory (essential for production workloads)
      ##
      resources: {}
        #limits:
        #  cpu: "2"
        #  memory: "8Gi"
        #requests:
      #  cpu: "2"
      #  memory: "8Gi"
    
      ## Pod-level security context applied to the pod (rendered as spec.<component>.spec.podSecurityContext)
      ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
      ##
      podSecurityContext: {}
      #  runAsUser: 1001
      #  runAsGroup: 1001
      #  fsGroup: 1001
    
      ## Container-level security context applied to the container (rendered as spec.<component>.spec.securityContext)
      ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
      ##
      securityContext: {}
      #  runAsNonRoot: true
      #  readOnlyRootFilesystem: true
      #  allowPrivilegeEscalation: false
      #  capabilities:
      #    drop:
      #      - ALL
    
      ## Request additional PVC for pod
      ##
      persistentVolume: {}
      #  mountPath: "/data/trino"
      #  volumeClaimTemplates:
      #    - metadata:
      #        name: data
      #      spec:
      #        accessModes: ["ReadWriteOnce"]
      #        resources:
      #          requests:
      #            storage: 10Gi
      #        storageClassName: default
    
      ## nodeAffinity: Object defining constraints to place pods on a specific set of Nodes
      ##
      nodeSelector: {}
      #  node.kubernetes.io/worker: "true"
    
      topologySpreadConstraints: []
    
      ## Allow a Pod to be scheduled onto nodes that have taints.
      ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
      ##
      tolerations: []
        # - key: "example-key"
      #   operator: "Exists"
      #   effect: "NoSchedule"
    
      ## affinity: Object defining soft rules to place pods on a specific set of Nodes or didn't place pod to nodes due to some conditions
      ##
      affinity: {}
      #  nodeAffinity:
      #      requiredDuringSchedulingIgnoredDuringExecution:
      #        nodeSelectorTerms:
      #        - matchExpressions:
      #          - key: topology.kubernetes.io/zone
      #            operator: In
      #            values:
      #            - antarctica-east1
      #            - antarctica-west1
      #      preferredDuringSchedulingIgnoredDuringExecution:
      #      - weight: 1
      #        preference:
      #          matchExpressions:
      #          - key: another-node-label-key
      #            operator: In
      #            values:
      #            - another-node-label-value
    
      startupProbe: {}
      #  httpGet:
      #    path: /v1/info
      #    port: 8080
      #    scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      livenessProbe: {}
      #  httpGet:
      #    path: /v1/info
      #    port: 8080
      #    scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      readinessProbe: {}
      #  exec:
      #    command:
      #      - sh
      #      - -c
      #      - test -f /opt/trino-server/etc/truststore/custom-truststore.jks
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      ## Mount additional secrets into the pod
      ##
      mountSecrets: []
      #  - secretName: my-secret
      #    mountPath: /etc/trino/my-secret
    
      ## Additional container/Service ports.
      ##
      ports: []
      #  - name: http-metrics
      #    containerPort: 9209
      #    servicePort: 9209
      #    protocol: TCP
    
    ## Specify an ingress settings
    ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress
    ##
    ingress:
      ## You can choose whether to use ingress or not. If "not" you can create internal loadBalancer with coordinator.serviceAnnotations parameter.
      enabled: false
      ## Specify ingress rule settings
      host:
      path: ""
      pathType: ImplementationSpecific
      ingressClassName: ""
      annotations: {}
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: "true"
      ## Specify tls settings
      tls:
        ## Whether to use tls for ingress or not
        enabled: false
        ## specify secret with tls certificate
        secretName: ""
    1 Имя секрета Kubernetes.
    2 Имя keystore-файла в формате PKCS12, используемого для TLS.
    3 Пароль keystore.
    4 Параметры каталога Iceberg.
  2. Обновите конфигурацию кластера Trino:

    $ helm upgrade --install trino-cluster oci://<registry-address>/adc-enterprise/charts/trino-cluster:<version> -f trino-cluster.yaml --namespace trino --create-namespace
  3. Проверьте работоспособность подов кластера Trino:

    $ kubectl get pods -n trino

    Ожидаемый вывод должен быть похож на следующий:

    NAME                  READY   STATUS    RESTARTS   AGE
    trino-coordinator-0   1/1     Running   0          52s
    trino-worker-0        1/1     Running   0          52s

Шаг 3. Проверка JDBC-соединения

  1. Подключитесь к кластеру Trino через JDBC, например, с помощью DBeaver. После активации web TLS строка подключения JDBC имеет следующий вид:

    jdbc:trino://trino-cloud.ru-central1.internal:8443?SSL=true&SSLTrustStorePath=<truststore_path>&SSLTrustStorePassword=<password>
  2. Установив подключение, выполните тестовую команду для проверки работоспособности кластера:

    SHOW CATALOGS;

    Ожидаемый вывод:

    Catalog   |
    ----------+
    iceberg   |
    system    |
Нашли ошибку? Выделите текст и нажмите Ctrl+Enter чтобы сообщить о ней