Configure Ranger for StarRocks on Kubernetes using CLI

Prerequisites

  • An ADPS cluster (2.0.0 or later) is installed and running.

  • An ADH cluster is installed and running (if interaction between StarRocks and ADH is required). The ADH version should be compatible with ADH Cloud.

  • StarRocks is installed according to the instruction.

Step 1. Create a service in Ranger

This guide describes how to create a service via Ranger REST API. Alternatively, you can create a service in the Ranger web UI.

  1. Define a service in a JSON file:

    ranger-starrocks-k8s.json
    {
      "isEnabled": true,
      "type": "starrocks",
      "name": "starrocks_k8s", (1)
      "displayName": "starrocks_k8s",
      "description": "Service for Kubernetes StarRocks",
      "configs": {
        "username": "service_user", (2)
        "password": "bigdata", (3)
        "ranger.plugin.audit.filters": "[{'accessResult':'DENIED','isAudited':true},{'isAudited':false,'resources':{'queryid':{'values':['*']}},'accessTypes':['execute']},{'isAudited':false,'resources':{'trinouser':{'values':['{USER}']}},'accessTypes':['impersonate']}]",
        "jdbc.driverClassName": "com.mysql.cj.jdbc.Driver",
        "jdbc.url": "jdbc:mysql://<external_ip>:9030" (4)
      }
    }
    1 A name of the StarRocks service in Ranger. Must be unique.
    2 A username for the service.
    3 A password for the service.
    4 A JDBC string for connecting to StarRocks, where <external_ip> is exposed by Ingress or load balancer.
  2. Push the defined service to Ranger:

    $ curl -u admin:<admin_pwd> -H "Content-Type: application/json" -X POST -d @ranger-starrocks-k8s.json http://<ranger-admin>:6080/service/public/v2/api/service

Step 2. Update the StarRocks cluster configuration

  1. Edit the starrocks-cluster.yaml configuration file by specifying the parameters in the spec.ranger section:

    starrocks-cluster.yaml
    apiVersion: adc.arenadata.io/v1alpha1
    kind: StarrocksCluster
    metadata:
      name: starrocks
      namespace: starrocks (1)
    spec:
      ## Image pull secret for a private registry.
      ## Set 'externalSecretName' to reference an existing Secret,
      ## or set 'credentials' and optionally 'secretName' to let the CLI create one.
      #imagePullSecret:
      #  # Use a Secret managed outside ADC.
      #  externalSecretName: existing-registry-secret
      #
      #  ## Or let ADC create the Secret.
      #  #secretName: custom-registry-secret
      #
      #  #credentials:
      #  #  registry: registry.example.com
      #  #  username: user
      #  #  password: pass
    
      #hadoop:
      #  core:
      #    fs.defaultFS: ""
      #  hdfs:
      #    dfs.encrypt.data.transfer.cipher.suites: AES/CTR/NoPadding
      #  ozone:
      #    ozone.om.service.ids: ""
    
      ## Kerberos configuration for authentication.
      #kerberos:
      #  realm: EXAMPLE.COM
      #
      #  # Service name in the Kerberos principal. Defaults to the product name.
      #  service: starrocks
      #
      #  # Hostname in the Kerberos principal.
      #  # Required for a fixed service principal; leave it empty only to derive one principal per pod from the cluster domain.
      #  hostname: kerberos.example.com
      #  keytab:
      #    # true - kerberos-operator creates the keytab Secret.
      #    # false (default) - reference an existing keytab Secret with name keytab.secretName.
      #    create: false
      #
      #    # Name of the keytab Secret.
      #    # Optional when create: true - names the generated Secret (default: <name>-keytab).
      #    # Required when create: false - must reference an existing Secret.
      #    secretName: kerberos-secret
      #
      #    # Label selector for the Pod that generates the keytab.
      #    # Required when create: true; ignored when create: false.
      #    labelSelector:
      #      env: prod
      #    #additionalPrincipals:
      #    #  - HTTP/kerberos.example.com
      #
      #    rotation:
      #      interval: 24h
      #      checkInterval: 1h
    
      ## Ranger plugin configuration.
      ## Uncomment and fill the lines below. adc apply derives the rest.
      ranger: (2)
      #  # fill ranger.plugin.starrocks.policy.rest.url below with Ranger endpoint, e.g. https://adps-adc.ru-central1.internal:6182
      #  # fill ranger.plugin.starrocks.service.name below with Ranger service name you want to use for product, e.g. adc_starrocks_id_1
        security:
          ranger.plugin.starrocks.policy.rest.url: "http://tsn-adps-1.vm.develop.vk.adsw.io:6080"
          ranger.plugin.starrocks.service.name: "starrocks_k8s"
      #
      #  # fill xasecure.audit.destination.solr.zookeepers below with Zookeepers endpoints to resolve solr service, e.g. adps-adc.ru-central1.internal:2181/Arenadata.Hadoop-2.solr.server
        audit:
          xasecure.audit.destination.solr.zookeepers: "tsn-adps-1.vm.develop.vk.adsw.io:2181/Arenadata.Hadoop-2.solr.server"
      #
      #  # Local Ranger files 'adc apply' writes into the configs Secret.
      #  # Relative paths are resolved against the config file.
        files:
          jceksStorePath: /etc/starrocks/ranger-starrocks.jceks (3)
    
      ## Java KeyStore/TrustStore certificate configuration.
      ## Set externalSecretName to reference an existing Secret,
      ## or set files and optional secretName to have ADC create it.
      #ssl:
      #  ## Name of the Secret containing Java keystores.
      #  #secretName: custom-ssl-secret
      #  externalSecretName: existing-ssl-secret
      #
      #  # Key in the Secret containing the truststore file.
      #  trustStoreKey: truststore.jks
      #
      #  ## Password for the truststore (optional).
      #  #trustStorePassword: bigdata
      #
      #  ## Key in the Secret containing the keystore file (optional).
      #  #keyStoreKey: keystore.jks
      #
      #  ## Password for the keystore (optional).
      #  #keyStorePassword: bigdata
      #
      #  ## Local files 'adc apply' puts into the Secret named by ssl.secretName.
      #  ## Relative paths are resolved against the config file.
      #  #files:
      #  #  trustStorePath: /path/to/truststore.jks
      #  #  #keyStorePath: /path/to/keystore.jks
    
      fe:
        replicas: 1
        #resources:
        #  limits:
        #    cpu: 500m
        #    memory: 512Mi
        #  requests:
        #    cpu: 250m
        #    memory: 256Mi
        persistentVolume:
          volumeClaimTemplate:
            storageClassName: <storage-class-name>
            resources:
              requests:
                storage: 10Gi
    
        image: hub.arenadata.io/adc-enterprise/starrocks:<version> (4)
    
        ## Use an external Secret with the complete component configuration (the whole
        ## fe.conf or cn.conf) instead of the Secret ADC renders. ADC creates the Secret
        ## as <cluster-name>-fe-conf or <cluster-name>-cn-conf.
        #configsSecret:
        #  # Use a Secret managed outside ADC.
        #  externalSecretName: existing-fe-conf
        #
        #  ## Or let ADC create the Secret.
        #  #secretName: custom-fe-conf
    
        ## Component configuration rendered into <component>.conf.
        ## ADC delivers it as a Secret mounted over the conf directory, so it replaces the whole directory.
        #config:
        #  cloud_native_meta_port: "6090"
        #  enable_fqdn_mode: "true"
        #  enable_load_volume_from_conf: "false"
        #  min_graceful_exit_time_second: "25"
        #  run_mode: shared_data
      cn:
        replicas: 1
        #resources:
        #  limits:
        #    cpu: 500m
        #    memory: 512Mi
        #  requests:
        #    cpu: 250m
        #    memory: 256Mi
    
        ## Environment variables passed to the component container.
        #envs:
        #  - name: SSL_CERT_FILE
        #    value: /etc/ssl/outbound/ca-certificates.crt
    
        ## Existing Secrets mounted into the component container.
        #mountSecrets:
        #  - mountPath: /etc/ssl/outbound/ca-certificates.crt
        #    options:
        #      subPath: ca-certificates.crt
        #    secretName: existing-outbound-ca
    
        image: hub.arenadata.io/adc-enterprise/starrocks:<version> (5)
    
        ## Use an external Secret with the complete component configuration (the whole
        ## fe.conf or cn.conf) instead of the Secret ADC renders. ADC creates the Secret
        ## as <cluster-name>-fe-conf or <cluster-name>-cn-conf.
        #configsSecret:
        #  # Use a Secret managed outside ADC.
        #  externalSecretName: existing-cn-conf
        #
        #  ## Or let ADC create the Secret.
        #  #secretName: custom-cn-conf
    
        ## Component configuration rendered into <component>.conf.
        ## ADC delivers it as a Secret mounted over the conf directory, so it replaces the whole directory.
        #config:
        #  sys_log_level: INFO
    
      ## CA certificate configuration.
      ## Set externalSecretName, or let ADC create a Secret from files.
      #ca:
      #  ## Optional name of the Secret ADC creates from a local file.
      #  #secretName: custom-ca-secret
      #  externalSecretName: existing-ca-secret
      #
      #  # Key in the Secret containing the CA certificate.
      #  certificateKey: ca.crt
    
      ## HTTPS on the CN metrics port. ADC renders be_metrics_port = 8045,
      ## be_metrics_enable_https and the PEM certificate and key paths into cn.conf,
      ## unless cn.config sets them, and mounts the Secret at /opt/starrocks/cn/conf/metrics-tls.
      ## monitoring.scrape then scrapes CN on metrics-port (Service port metrics) over https.
      ## Set externalSecretName to reference an existing Secret,
      ## or set files and optional secretName to have ADC create it.
      #webTLS:
      #  ## Optional name of the Secret ADC creates from local files.
      #  #secretName: custom-starrocks-web-tls
      #  externalSecretName: existing-starrocks-web-tls
      #
      #  # Key in the Secret containing the web TLS certificate.
      #  certificateKey: tls.crt
      #
      #  # Key in the Secret containing the web TLS private key.
      #  privateKey: tls.key
      #
      #  ## Local files 'adc apply' puts into the Secret named by webTLS.secretName.
      #  ## Relative paths are resolved against the config file.
      #  #files:
      #  #  certificatePath: /path/to/tls.crt
      #  #  privateKeyPath: /path/to/tls.key
    
      ## Monitoring configuration.
      #monitoring:
      #  # Enables Prometheus metrics export from this product's pods.
      #  exportMetrics: true
    
      ## Root password of the StarRocks cluster.
      ## Set externalSecretName to use an existing Secret, or password to have ADC create one.
      ## Without this section root keeps the empty password of a fresh installation.
      rootPassword: (6)
      #  # Use a Secret managed outside ADC.
      #  externalSecretName: existing-starrocks-root
      #
      #  ## Or let ADC create the Secret.
        secretName: custom-starrocks-root
        password: root
    
      ## LDAP authentication of FE (authentication_ldap_simple).
      ## Direct bind: give the DN on the user with CREATE USER ... AS '<dn>' and set only url.
      ## DN pattern: set userBindPattern.
      ## Search: set bindBaseDN and externalSecretName.
      ## For ldaps:// the trust store of the ssl section verifies the server, otherwise the JVM default one.
      #ldap:
      #  # LDAP service url.
      #  url: ldaps://ldap.example.com:636
      #
      #  ## DN pattern: the DN of the user is built from the login, #UID is replaced by the login.
      #  ## Several patterns are separated by ; and tried in order; each must contain #UID and be a DN.
      #  ## Excludes bindBaseDN: with a pattern FE skips the search.
      #  #userBindPattern: uid=#UID,ou=people,dc=example,dc=com
      #
      #  ## Subtree the users are searched in with the service account.
      #  #bindBaseDN: ou=people,dc=example,dc=com
      #
      #  ## Attribute that carries the user name for the search (FE defaults to uid).
      #  #userSearchAttr: uid
      #
      #  ## Existing Secret with the service account of the search, keys bind-root-dn and bind-root-password.
      #  ## It reaches FE as environment variables, never the CR or fe.conf.
      #  #externalSecretName: existing-starrocks-ldap
    
      ## Use an external Hadoop configs Secret instead of the one rendered by ADC.
      #hadoopConfigsSecret:
      #  # Use a Secret managed outside ADC.
      #  externalSecretName: existing-starrocks-hadoop-configs
      #
      #  ## Or let ADC create the Secret.
      #  #secretName: custom-starrocks-hadoop-configs
    
      ## Use an external Ranger configs Secret instead of the Secret ADC renders.
      #rangerConfigsSecret:
      #  # Use a Secret managed outside ADC.
      #  externalSecretName: existing-starrocks-ranger
      #
      #  ## Or let ADC create the Secret.
      #  #secretName: custom-starrocks-ranger
    
      ## Controls whether Secret/ConfigMap changes restart pods.
      ## 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: false
    1 Namespace that the StarRocks cluster will use.
    2 Ranger settings.
    3 Additional JCEKS file if Ranger is used along with SSL.
    4 URL for pulling the StarRocks frontend image.
    5 URL for pulling the StarRocks compute node image.
    6 Root password secret configuration.

    To generate the JCEKS file, run the following command on a host with Ranger Admin:

    $ java -cp "/usr/lib/ranger-admin/cred/lib/*" org.apache.ranger.credentialapi.buildks create sslTrustStore -value bigdata -provider jceks://file$(pwd)/ranger-starrocks.jceks
  2. Apply the configuration and deploy the StarRocks cluster:

    $ ./adc apply -f starrocks-cluster.yaml

    The expected output contains a confirmation of success:

    time="20261126012059UTC" level="info" msg="cluster starrocks applied to namespace starrocks"
  3. Delete old pods so that Trino operator creates new ones from an updated config:

    $ kubectl delete pods -n starrocks -l app.kubernetes.io/instance=starrocks-cluster
  4. Verify the StarRocks cluster pods:

    $ kubectl get pods -n starrocks

    The expected output is:

    NAME                      READY   STATUS      RESTARTS   AGE
    starrocks-cn-0            1/1     Running     0          9m42s
    starrocks-fe-0            1/1     Running     0          10m
    starrocks-initpwd-cvjfd   0/1     Completed   0          10m
Found a mistake? Seleсt text and press Ctrl+Enter to report it