# Custom Values for Flink SQL Gateway Helm Chart
# Configuration for external Python client access with resource settings

global:
  namespace: flink-sql-test
  image:
    repository: wbsong111/flink-sql
    tag: 2.0.1
    pullPolicy: IfNotPresent


# Flink Session Cluster resource configuration
sessionCluster:
  flinkVersion: v2_0
  jobManager:
    resources:
      memory: 2048m  # Increased from default 1024m
      cpu: 1         # Increased from default 0.5
  taskManager:
    resources:
      memory: 4096m  # Increased from default 2048m
      cpu: 2         # Increased from default 1
  flinkConfiguration:
    taskmanager.numberOfTaskSlots: "4"  # Increased from default "2"
    # SSL/TLS Configuration for truststore
    # security.ssl.internal.enabled: "true"
    # security.ssl.internal.truststore: "/opt/flink/certs/ca.p12"
    # security.ssl.internal.truststore-type: "PKCS12"
    # JVM SSL system properties for JobManager and TaskManager
    env.java.opts.jobmanager: "-Djavax.net.ssl.trustStore=/opt/flink/certs/ca.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=YOUR_TRUSTSTORE_PASSWORD"
    env.java.opts.taskmanager: "-Djavax.net.ssl.trustStore=/opt/flink/certs/ca.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=YOUR_TRUSTSTORE_PASSWORD"
    # Iceberg REST Catalog SSL Configuration
    table.exec.resource.default-parallelism: "2"
    
    # [추가] s3 스키마를 Hadoop S3AFileSystem으로 처리하도록 매핑
    fs.s3.impl: org.apache.hadoop.fs.s3a.S3AFileSystem
    fs.s3a.impl: org.apache.hadoop.fs.s3a.S3AFileSystem
    
    # [추가] MinIO 사용 시 Path Style Access 필수
    fs.s3a.endpoint: "https://minio.example.org"
    fs.s3a.path.style.access: "true"

  env:
    - name: TRUSTSTORE_PASSWORD
      valueFrom:
        secretKeyRef:
          name: truststore-secret
          key: ca.password
  volumeMounts:
    - name: truststore-certs
      mountPath: /opt/flink/certs
      readOnly: true
  volumes:
    - name: truststore-certs
      secret:
        secretName: truststore-secret

# SQL Gateway resource configuration
sqlGateway:
  resources:
    requests:
      memory: 1Gi    # Increased from default 512Mi
      cpu: 0.5       # Increased from default 0.25
    limits:
      memory: 2Gi    # Increased from default 1Gi
      cpu: 1         # Increased from default 0.5
  flinkConfiguration:
    # JVM SSL system properties for SQL Gateway
    # env.java.opts.all: "-Djavax.net.ssl.trustStore=/opt/flink/certs/ca.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
    env.java.opts: "-Djavax.net.ssl.trustStore=/opt/flink/certs/ca.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=YOUR_TRUSTSTORE_PASSWORD"
  env:
    - name: TRUSTSTORE_PASSWORD
      valueFrom:
        secretKeyRef:
          name: truststore-secret
          key: ca.password
  volumeMounts:
    - name: truststore-certs
      mountPath: /opt/flink/certs
      readOnly: true
  volumes:
    - name: truststore-certs
      secret:
        secretName: truststore-secret

sqlClient:
   enabled: true
   env:
     - name: TRUSTSTORE_PASSWORD
       valueFrom:
         secretKeyRef:
           name: truststore-secret
           key: ca.password
   volumeMounts:
     - name: truststore-certs
       mountPath: /opt/flink/certs
       readOnly: true
   volumes:
     - name: truststore-certs
       secret:
         secretName: truststore-secret
# Optional: Enable Ingress for external access
# ingress:
#   enabled: true
#   hosts:
#     - host: flink-sql-gateway.example.com
#       paths:
#         - path: /
#           pathType: Prefix
