apiVersion: teiid.io/v1alpha1
kind: VirtualDatabase
metadata:
  name: thrift
spec:
  replicas: 1
  expose: 
    - NodePort
    - Router
  env:
    - name: KEYCLOAK_REALM
      value: dv
    - name: KEYCLOAK_RESOURCE
      value: testing
    - name: KEYCLOAK_AUTH_SERVER_URL
      value: https://keycloak-keycloak.apps.10.0.79.22.nip.io/auth
    - name: KEYCLOAK_DISABLE_TRUST_MANAGER
      value: "true"
  datasources:
    - properties:
        - name: jdbc-url
          value: "jdbc:hive2://172.30.104.131:10000"
        - name: username
          value: "hiveadmin"
        - name: password
          value: "password"
        - name: driver-class-name
          value: "org.apache.hive.jdbc.HiveDriver"
        - name: importer.schemaName
          value: "default"
      name: thriftserver
      type: hive
  build:
    source:
      ddl: >
        CREATE DATABASE thrift OPTIONS (ANNOTATION 'Thrift Server VDB');
        USE DATABASE thrift;

        CREATE SERVER "thriftserver" FOREIGN DATA WRAPPER hive;

        CREATE SCHEMA opendatahub SERVER "thriftserver";

        CREATE ROLE "all" WITH ANY AUTHENTICATED;

        IMPORT FROM SERVER "thriftserver" INTO opendatahub;

        GRANT SELECT ON TABLE opendatahub.sample TO "all";
