wangzhigang1999 commented on code in PR #7846: URL: https://github.com/apache/kyuubi/pull/7846#discussion_r4594545025
########## docs/deployment/high_availability_guide.md: ########## @@ -64,6 +64,133 @@ But it doesn't have any availability to being highly available. For production deployment purpose, an external zookeeper cluster is required for `kyuubi.ha.addresses`. In this mode, multiple `k.i.`s can be registered to the same ServerSpace configured by `kyuubi.ha.namespace` and serve together. +### etcd for server and engine discovery + +Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of +ZooKeeper. Set the following on every Kyuubi server (for example via a shared +`kyuubi-defaults.conf`): + +```text +kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient +# endpoint URLs must include a scheme: http://, or https:// when TLS is enabled +kyuubi.ha.addresses=http://etcd1:2379,http://etcd2:2379,http://etcd3:2379 +# optional, defaults to "kyuubi" +kyuubi.ha.namespace=kyuubi +# optional, defaults to PT10S +kyuubi.ha.etcd.lease.timeout=PT10S +``` + +If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the +ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`, +`kyuubi.ha.etcd.ssl.client.certificate.path`, +`kyuubi.ha.etcd.ssl.client.key.path`, and use `https://` endpoint URLs in +`kyuubi.ha.addresses`. + +Notes: + +- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo + mode. etcd must run as a service, either inside the Kubernetes cluster + (for example a dedicated StatefulSet) or outside it. +- `kyuubi.ha.addresses` is a comma-separated list of endpoint URLs that + include a scheme: `http://host:port`, or `https://host:port` when TLS is + enabled. Bare `host:port` addresses will not connect. +- The etcd discovery client has no authentication other than mTLS; secure etcd + with TLS or a network boundary. +- Server registrations and engine registrations both use the same namespace. The + engine registration prefix is derived from that namespace as + `<namespace>_<kyuubi version>_<share level>_<engine type>`, followed by the + routing user and the engine subdomain, for example + `/kyuubi_1.13.0-SNAPSHOT_USER_SPARK_SQL/<user>/default` for the default + `kyuubi.ha.namespace=kyuubi`. +- The JDBC driver does not support etcd service discovery; + `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used + between Kyuubi servers and engines, not from the JDBC client. + +## High Availability on Kubernetes (with etcd) + +A production Kubernetes deployment of Kyuubi has three moving parts: the +Kyuubi servers, their engines (Spark applications), and the discovery store +they share. A Kubernetes Service can balance new connections across the +servers, but it does not make engines discoverable or sessions portable, so a +discovery store is required for a real HA setup. + +1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi + pods works, for example a dedicated StatefulSet in the same namespace, or an + etcd cluster running outside Kubernetes. Kyuubi does *not* use the + Kubernetes cluster's own etcd automatically; you must pass the endpoints to + Kyuubi with `kyuubi.ha.addresses`. +2. **Configure every server with the same options.** All server replicas must + use the same `kyuubi.ha.client.class` and `kyuubi.ha.namespace`. Engines + inherit their discovery configuration from the server that starts them, so + engine driver pods must also be able to reach etcd; server-only + connectivity is not enough and engine startup fails without it. When TLS + is enabled, the driver pods also need the configured certificate files at + the inherited paths, because forwarding the configuration does not copy + them. Mount a shared `kyuubi-defaults.conf` (or inject it into the Helm + chart values) so this is identical on every pod. + The driver pod is created in the namespace given by + `spark.kubernetes.namespace`, or, when the submission does not set it, in + the namespace the server uses for engine pods, + `kyuubi.kubernetes.namespace`, which defaults to `default`. It runs under + the ServiceAccount named by + `spark.kubernetes.authenticate.driver.serviceAccountName`. A driver pod + that lands in a namespace whose ServiceAccount may not create pods makes + the first query fail while the pod is being created, so point both at the + namespace Kyuubi runs in. See + [Deploy Kyuubi engines on Kubernetes](engine_on_kubernetes.md#serviceaccount) + for the ServiceAccount setup. Review Comment: I retested this in a Kubernetes test cluster with separate ServiceAccounts for the Kyuubi submitter and the Spark driver. - I set `kyuubi.kubernetes.namespace` to the test namespace and left `spark.kubernetes.namespace` unset. Spark tried to create the driver pod in `default`, and the submitter's ServiceAccount received `403`. - After I set `spark.kubernetes.namespace`, the driver started in the test namespace. Its ServiceAccount then received `403` when it tried to create executor pods. Once I granted that account permission to create pods, `SELECT sum(id) FROM range(1000)` returned `499500`. ```suggestion Set `spark.kubernetes.namespace` to the namespace where Spark should create the driver and executor pods. Spark defaults to `default` when this property is unset. `kyuubi.kubernetes.namespace` sets the default namespace for Kyuubi's own Kubernetes client to discover and manage engine pods. The credentials used to submit the Spark application need permission to create the driver pod in the target namespace. Set `spark.kubernetes.authenticate.driver.serviceAccountName` to a ServiceAccount in that namespace with permission to create and watch executor pods. See [Deploy Kyuubi engines on Kubernetes](engine_on_kubernetes.md#serviceaccount) for the ServiceAccount setup. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
