Установка StarRocks в Kubernetes с помощью CLI

В данной статье описан процесс развертывания StarRocks в Kubernetes с помощью CLI-утилиты adc. Настройки безопасности для StarRocks в Kubernetes описаны в отдельных статьях:

Требования

Для развертывания StarRocks в Kubernetes с помощью CLI необходимы:

  • Кластер Kubernetes (версии 1.32 - 1.34) с настроенным доступом через kubectl.

  • Установленный и функционирующий кластер ADH (если предполагается взаимодействие StarRocks c ADH). Версия ADH должна быть совместима с ADH Cloud.

  • CLI-утилита, извлеченная из offline-пакета.

  • Извлеченные и загруженные в ваш репозиторий образы:

    • hub.arenadata.io/adc-enterprise/starrocks-operator:<version>

    • hub.arenadata.io/adh-enterprise/starrocks:<version>

    Эти артефакты присутствуют в offline-пакете, который можно запросить у службы поддержки Arenadata.

Шаг 1. Установка оператора StarRocks

  1. Инициализируйте оператор StarRocks:

    $ ./adc init --starrocks-operator -o starrocks-operator.yaml

    Данная команда создаст файл starrocks-operator.yaml с шаблоном конфигурации.

  2. Отредактируйте конфигурационный файл:

    starrocks-operator.yaml
    apiVersion: adc.arenadata.io/v1alpha1
    kind: StarrocksOperator
    metadata:
      name: starrocks-operator
      namespace: starrocks-operator (1)
    spec:
      image: hub.arenadata.io/adc-enterprise/starrocks-operator:<version> (2)
    
      ## 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
    
      # Number of replicas
      # replicas: 1
    
      resources:
        limits:
          cpu: 500m
          memory: 256Mi
    
      # Operator ServiceAccount. create: true (default) also creates the manager and per-payload-namespace Role/RoleBinding bound to it; create: false skips all three - name then refers to a ServiceAccount (and RBAC) managed entirely outside the CLI.
      serviceAccount: (3)
        create: true
        name: ""
    
      # Whether the CLI creates the product namespace.
      # The namespace name is set in metadata.namespace.
      namespace:
        create: true
    
      # Create namespaces to run the payload.
      createPayloadNamespaces: true
    
      # List of namespaces to run the payload in.
      payloadNamespaces: (4)
        - starrocks
    
      ## Operator monitoring configuration. Supports product-specific metrics export and optional vmagent delivery to an external ADM.
      #monitoring:
      #  # Renders a namespace-scoped vmagent that sends metrics to an external ADM.
      #  vmagent:
      #    remoteWrite:
      #      url: http://vminsert.example.com/insert/0/prometheus/api/v1/write
      #    scrapeInterval: 15s
      #    image: hub.arenadata.io/adm-enterprise/vmagent:1.136.0-adm-5.0.0-x86_64
      #
      #    ## HTTPS settings used by vmagent when scraping product metrics.
      #    #tls:
      #    #  ## CA certificate source used to verify the metrics endpoint.
      #    #  #ca:
      #    #  #  # Use a Secret managed outside ADC.
      #    #  #  externalSecretName: existing-product-metrics-ca
      #    #  #
      #    #  #  ## Or let ADC create the Secret.
      #    #  #  #secretName: product-metrics-ca
      #    #  #
      #    #  #  # Key containing the CA certificate in the referenced Secret.
      #    #  #  certificateKey: ca.crt
      #    #  #
      #    #  #  ## Local CA certificate read by ADC to create the configured Secret.
      #    #  #  #files:
      #    #  #  #  certificatePath: /path/to/ca.crt
      #    #
      #    #  ## Server name used to verify the metrics endpoint certificate hostname.
      #    #  #serverName: metrics.example.com
      #    #
      #    #  # Skip verification of the metrics endpoint certificate. Do not use together with ca.
      #    #  insecureSkipVerify: true
    1 Настройки пространства имен.
    2 URL образа оператора StarRocks в вашем репозитории.
    3 Настройки сервисного аккаунта.
    4 Список пространств имен, доступных оператору StarRocks.
  3. Вы можете проверить конфигурацию перед ее применением, выполнив команду apply с флагом --dry-run:

    $ ./adc apply -f starrocks-operator.yaml --dry-run > starrocks-operator-render.yaml
    starrocks-operator-render.yaml
    ---
    apiVersion: v1
    kind: Namespace
    metadata:
      name: starrocks-operator
    spec: {}
    status: {}
    ---
    apiVersion: v1
    kind: Namespace
    metadata:
      name: starrocks
    spec: {}
    status: {}
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: starrocks-operator
      namespace: starrocks-operator
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: starrocks-operator-starrocks-operator-manager
      namespace: starrocks-operator
    rules:
    - apiGroups:
      - ""
      - events.k8s.io
      resources:
      - events
      verbs:
      - create
      - patch
    - apiGroups:
      - coordination.k8s.io
      resources:
      - leases
      verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
    - apiGroups:
      - starrocks.arenadata.io
      resources:
      - clusters
      - warehouses
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - starrocks.arenadata.io
      resources:
      - clusters/status
      - warehouses/status
      verbs:
      - get
      - patch
      - update
    - apiGroups:
      - ""
      resources:
      - pods
      - endpoints
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - autoscaling
      resources:
      - horizontalpodautoscalers
      verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: starrocks-operator-starrocks-operator-manager
      namespace: starrocks-operator
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: starrocks-operator-starrocks-operator-manager
    subjects:
    - kind: ServiceAccount
      name: starrocks-operator
      namespace: starrocks-operator
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: starrocks-operator-starrocks-operator-payload
      namespace: starrocks
    rules:
    - apiGroups:
      - events.k8s.io
      resources:
      - events
      verbs:
      - create
      - patch
    - apiGroups:
      - ""
      resources:
      - secrets
      - services
      - serviceaccounts
      verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
    - apiGroups:
      - apps
      resources:
      - deployments
      - statefulsets
      verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
    - apiGroups:
      - starrocks.arenadata.io
      resources:
      - clusters
      - warehouses
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - starrocks.arenadata.io
      resources:
      - clusters/status
      - warehouses/status
      verbs:
      - get
      - patch
      - update
    - apiGroups:
      - ""
      resources:
      - pods
      - endpoints
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - autoscaling
      resources:
      - horizontalpodautoscalers
      verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: starrocks-operator-starrocks-operator-payload
      namespace: starrocks
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: starrocks-operator-starrocks-operator-payload
    subjects:
    - kind: ServiceAccount
      name: starrocks-operator
      namespace: starrocks-operator
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app.kubernetes.io/component: operator
        app.kubernetes.io/managed-by: adc-cli
        arenadata.io/operator-type: starrocks
      name: starrocks-operator-starrocks-operator
      namespace: starrocks-operator
    spec:
      selector:
        matchLabels:
          app.kubernetes.io/component: operator
          app.kubernetes.io/managed-by: adc-cli
          app.kubernetes.io/name: starrocks-operator-starrocks-operator
      strategy: {}
      template:
        metadata:
          labels:
            app.kubernetes.io/component: operator
            app.kubernetes.io/managed-by: adc-cli
            app.kubernetes.io/name: starrocks-operator-starrocks-operator
        spec:
          containers:
          - args:
            - -ns=starrocks
            image: hub.arenadata.io/adc-enterprise/starrocks-operator:<version>
            imagePullPolicy: Always
            livenessProbe:
              httpGet:
                path: /healthz
                port: 8081
              initialDelaySeconds: 5
              periodSeconds: 10
            name: app
            readinessProbe:
              httpGet:
                path: /readyz
                port: 8081
              initialDelaySeconds: 5
              periodSeconds: 10
            resources:
              limits:
                cpu: 500m
                memory: 256Mi
              requests:
                cpu: 500m
                memory: 256Mi
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                drop:
                - ALL
              readOnlyRootFilesystem: true
              runAsGroup: 10001
              runAsNonRoot: true
              runAsUser: 10001
          securityContext:
            fsGroup: 10001
            runAsGroup: 10001
            runAsNonRoot: true
            runAsUser: 10001
          serviceAccountName: starrocks-operator
          terminationGracePeriodSeconds: 10
    status: {}
  4. Если манифест корректный, примените конфигурацию и разверните оператор StarRocks:

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

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

    time="20261123085122UTC" level="info" msg="operator starrocks/starrocks-operator applied to namespace starrocks-operator"
  5. Проверьте работоспособность подов оператора StarRocks:

    $ kubectl get pods -n starrocks-operator

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

    NAME                                                     READY   STATUS    RESTARTS   AGE
    starrocks-operator-starrocks-operator-849c95b64f-9j9l7   1/1     Running   0          4m30s

Шаг 2. Установка кластера StarRocks

  1. Инициализируйте кластер StarRocks:

    $ ./adc init --starrocks-cluster -o starrocks-cluster.yaml

    Данная команда создаст файл starrocks-cluster.yaml с шаблоном конфигурации.

  2. Отредактируйте конфигурационный файл:

    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:
      #  # 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: ""
      #    ranger.plugin.starrocks.service.name: ""
      #
      #  # 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: ""
      #
      #  # Local Ranger files 'adc apply' writes into the configs Secret.
      #  # Relative paths are resolved against the config file.
      #  files:
      #    jceksStorePath: /path/to/ranger.jceks
    
      ## 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> (2)
    
        ## 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> (3)
    
        ## 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: (4)
      #  # 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 Пространство имен, используемое кластером StarRocks.
    2 URL образа компонента StarRocks Frontend (FE) в вашем репозитории.
    3 URL образа компонента StarRocks Compute Node (CN) в вашем репозитории.
    4 Настройки секрета пароля для пользователя root.
  3. Проверьте, что конфигурация создает корректный манифест, выполнив команду apply с флагом --dry-run:

    $ ./adc apply -f starrocks-cluster.yaml --dry-run > starrocks-cluster-render.yaml
    starrocks-cluster-render.yaml
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: starrocks-fe-conf
      namespace: starrocks
    stringData:
      fe.conf: |
        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
    type: Opaque
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: starrocks-cn-conf
      namespace: starrocks
    stringData:
      cn.conf: |
        sys_log_level = INFO
    type: Opaque
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: custom-starrocks-root
      namespace: starrocks
    stringData:
      password: bigdata
    type: Opaque
    ---
    apiVersion: v1
    kind: Secret
    metadata:
      name: starrocks-initpwd-shell
      namespace: starrocks
    stringData:
      fe_initpwd.sh: |
        #!/bin/bash
    
        init_pwd_sql="SET PASSWORD = PASSWORD('$INIT_PWD');"
        deadline=$((SECONDS + 120))
        while true; do
          success=$(mysql --connect-timeout 5 -h "$1" -P "$2" -u root --skip-column-names --batch -e "$init_pwd_sql" 2>&1)
          if [ $? -eq 0 ] ; then
            echo "successfully modified password"
            exit 0
          fi
          echo "$success"
          errcode=$(echo "$success" | awk -F " " '{print $2}')
          echo "error code: $errcode"
          if [[ $errcode = '1045' || $errcode = '1064' ]] ; then
            echo "password already set, nothing to do"
            exit 0
          fi
          if [[ $errcode = '2002' || $errcode = '2003' || $errcode = '2005' || $errcode = '2013' ]] && [ $SECONDS -lt $deadline ] ; then
            echo "FE is not reachable yet, retrying"
            sleep 5
            continue
          fi
          exit 1
        done
    type: Opaque
    ---
    apiVersion: starrocks.arenadata.io/v1alpha1
    kind: Cluster
    metadata:
      name: starrocks
      namespace: starrocks
    spec:
      cn:
        metadata: {}
        replicas: 1
        spec:
          envs:
          - name: MYSQL_PWD
            valueFrom:
              secretKeyRef:
                key: password
                name: custom-starrocks-root
          image: hub.arenadata.io/adc-enterprise/starrocks:<version>
          imagePullPolicy: Always
          secrets:
          - mountPath: /opt/starrocks/cn/conf
            name: starrocks-cn-conf
      fe:
        metadata: {}
        replicas: 1
        spec:
          envs:
          - name: MYSQL_PWD
            valueFrom:
              secretKeyRef:
                key: password
                name: custom-starrocks-root
          image: hub.arenadata.io/adc-enterprise/starrocks:<version>
          imagePullPolicy: Always
          secrets:
          - mountPath: /opt/starrocks/fe/conf
            name: starrocks-fe-conf
          storageVolumes:
          - mountPath: /opt/starrocks/fe/meta
            name: fe-meta
            storageClassName: <storage-class-name>
            storageSize: 10Gi
    ---
    apiVersion: batch/v1
    kind: Job
    metadata:
      labels:
        cluster: starrocks
      name: starrocks-initpwd
      namespace: starrocks
    spec:
      backoffLimit: 10
      template:
        metadata: {}
        spec:
          containers:
          - args:
            - /opt/starrocks/fe_initpwd.sh
            - starrocks-fe-0.starrocks-fe-search
            - "9030"
            command:
            - /bin/bash
            env:
            - name: INIT_PWD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: custom-starrocks-root
            image: hub.arenadata.io/adc-enterprise/starrocks:<version>
            name: starrocks-initpwd
            resources: {}
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                drop:
                - ALL
              readOnlyRootFilesystem: true
              runAsGroup: 1000
              runAsNonRoot: true
              runAsUser: 1000
              seccompProfile:
                type: RuntimeDefault
            volumeMounts:
            - mountPath: /opt/starrocks/fe_initpwd.sh
              name: initpwd-shell
              subPath: fe_initpwd.sh
          restartPolicy: OnFailure
          securityContext:
            fsGroup: 1000
          volumes:
          - name: initpwd-shell
            secret:
              defaultMode: 360
              items:
              - key: fe_initpwd.sh
                path: fe_initpwd.sh
              secretName: starrocks-initpwd-shell
    status: {}
  4. . Если манифест корректный, примените конфигурацию и разверните кластер StarRocks:

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

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

    time="20261123090429UTC" level="info" msg="cluster starrocks applied to namespace starrocks"
  5. Проверьте работоспособность подов кластера StarRocks:

    $ kubectl get pods -n starrocks

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

    NAME                      READY   STATUS      RESTARTS   AGE
    starrocks-cn-0            1/1     Running     0          46m
    starrocks-fe-0            1/1     Running     0          47m
    starrocks-initpwd-bm5ds   0/1     Completed   0          47m

Шаг 3. Предоставление доступа к StarRocks через JDBC

Для внешнего доступа к кластеру StarRocks необходимо открыть HTTP/SQL-эндпойнты сервиса, например, используя LoadBalancer или Ingress-контроллер. Все настройки, связанные с публикацией сервиса, включая DNS, аннотации, параметры Ingress/LoadBalancer и прочие, должны быть указаны в соответствии с вашей инфраструктурой Kubernetes.

В следующем примере показано подключение JDBC-клиента (DBeaver) к контейнеру StarRocks FE через LoadBalancer.

  1. Получите внешний IP-адрес балансировщика. Например:

    NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                                        AGE
    starrocks-lb           LoadBalancer   10.254.154.174   10.111.39.142   9030:31545/TCP,8030:30404/TCP,8443:31255/TCP   33m   107

    Скопируйте IP-адрес EXTERNAL-IP для дальнейших шагов.

  2. Подключитесь к кластеру StarRocks по JDBC, например, с помощью DBeaver. Строка JDBC-подключения имеет следующий вид:

    jdbc:mysql://<external-ip>:9030/

    где <external-ip> — IP-адрес балансировщика из предыдущего шага.

  3. Установив подключение, выполните тестовую команду для проверки работоспособности кластера:

    SHOW CATALOGS;

    Вывод:

    Catalog        |Type    |Comment                                                         |
    ---------------+--------+----------------------------------------------------------------+
    default_catalog|Internal|An internal catalog contains this cluster's self-managed tables.|

Удаление инстансов

ВАЖНО

Удалять оператор следует только после удаления всех управляемых им ресурсов.

Чтобы удалить кластер StarRocks, запустите следующую команду:

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

Чтобы удалить оператор StarRocks, запустите следующую команду:

$ ./adc delete -f starrocks-operator.yaml
Нашли ошибку? Выделите текст и нажмите Ctrl+Enter чтобы сообщить о ней