blob: db4e83314168d4eecf7eabeacef9cf2626e386e4 [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-development/extensions-core/kubernetes" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.7.0">
<title data-rh="true">Kubernetes | Apache® Druid</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" property="og:url" content="https://druid.apache.org/docs/latest/development/extensions-core/kubernetes"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Kubernetes | Apache® Druid"><meta data-rh="true" name="description" content="&lt;!--"><meta data-rh="true" property="og:description" content="&lt;!--"><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/latest/development/extensions-core/kubernetes"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/development/extensions-core/kubernetes" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/latest/development/extensions-core/kubernetes" hreflang="x-default"><link rel="stylesheet" href="/css/all.css">
<script src="/js/clipboard.min.js"></script><link rel="stylesheet" href="/assets/css/styles.f3140859.css">
<script src="/assets/js/runtime~main.12e85305.js" defer="defer"></script>
<script src="/assets/js/main.2e3800ac.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const n=new URLSearchParams(window.location.search).entries();for(var[t,e]of n)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/technology">Technology</a><a class="navbar__item navbar__link" href="/use-cases">Use Cases</a><a class="navbar__item navbar__link" href="/druid-powered">Powered By</a><a class="navbar__item navbar__link" href="/docs/latest/design/">Docs</a><a class="navbar__item navbar__link" href="/community/">Community</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache®</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://apachecon.com/?ref=druid.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/downloads/">Download</a><div class="navbarSearchContainer_Bca1"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input id="search_input_react" type="search" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0"><div class="docsWrapper_hBAB"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docRoot_UBD9"><main class="docMainContainer_TBSr docMainContainerEnhanced_lQrH"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Kubernetes</h1></header><p>Consider this an <a href="/docs/latest/development/experimental">EXPERIMENTAL</a> feature mostly because it has not been tested yet on a wide variety of long running Druid clusters.</p>
<p>Apache Druid Extension to enable using Kubernetes API Server for node discovery and leader election. This extension allows Druid cluster deployment on Kubernetes without Zookeeper. It allows running multiple Druid clusters within same Kubernetes Cluster, See <code>clusterIdentifier</code> config below.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="configuration">Configuration<a href="#configuration" class="hash-link" aria-label="Direct link to Configuration" title="Direct link to Configuration"></a></h2>
<p>To use this extension please make sure to <a href="/docs/latest/configuration/extensions#loading-extensions">include</a> <code>druid-kubernetes-extensions</code> in the extensions load list.</p>
<p>This extension works together with HTTP-based segment and task management in Druid. Consequently, following configurations must be set on all Druid nodes.</p>
<p><code>druid.zk.service.enabled=false</code>
<code>druid.serverview.type=http</code>
<code>druid.indexer.runner.type=httpRemote</code>
<code>druid.discovery.type=k8s</code></p>
<p>For Node Discovery, Each Druid process running inside a pod &quot;announces&quot; itself by adding few &quot;labels&quot; and &quot;annotations&quot; in the pod spec. Druid process needs to be aware of pod name and namespace which it reads from environment variables <code>POD_NAME</code> and <code>POD_NAMESPACE</code>. These variable names can be changed, see configuration below. But in the end, each pod needs to have self pod name and namespace added as environment variables.</p>
<p>Additionally, this extension has following configuration.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="properties">Properties<a href="#properties" class="hash-link" aria-label="Direct link to Properties" title="Direct link to Properties"></a></h3>
<table><thead><tr><th>Property</th><th>Possible Values</th><th>Description</th><th>Default</th><th>required</th></tr></thead><tbody><tr><td><code>druid.discovery.k8s.clusterIdentifier</code></td><td><code>string that matches [a-z0-9][a-z0-9-]*[a-z0-9]</code></td><td>Unique identifier for this Druid cluster in Kubernetes e.g. us-west-prod-druid.</td><td>None</td><td>Yes</td></tr><tr><td><code>druid.discovery.k8s.podNameEnvKey</code></td><td><code>Pod Env Variable</code></td><td>Pod Env variable whose value is that pod&#x27;s name.</td><td>POD_NAME</td><td>No</td></tr><tr><td><code>druid.discovery.k8s.podNamespaceEnvKey</code></td><td><code>Pod Env Variable</code></td><td>Pod Env variable whose value is that pod&#x27;s kubernetes namespace.</td><td>POD_NAMESPACE</td><td>No</td></tr><tr><td><code>druid.discovery.k8s.leaseDuration</code></td><td><code>Duration</code></td><td>Lease duration used by Leader Election algorithm. Candidates wait for this time before taking over previous Leader.</td><td>PT60S</td><td>No</td></tr><tr><td><code>druid.discovery.k8s.renewDeadline</code></td><td><code>Duration</code></td><td>Lease renewal period used by Leader.</td><td>PT17S</td><td>No</td></tr><tr><td><code>druid.discovery.k8s.retryPeriod</code></td><td><code>Duration</code></td><td>Retry wait used by Leader Election algorithm on failed operations.</td><td>PT5S</td><td>No</td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="gotchas">Gotchas<a href="#gotchas" class="hash-link" aria-label="Direct link to Gotchas" title="Direct link to Gotchas"></a></h3>
<ul>
<li>Label/Annotation path in each pod spec MUST EXIST, which is easily satisfied if there is at least one label/annotation in the pod spec already.</li>
<li>All Druid Pods belonging to one Druid cluster must be inside same kubernetes namespace.</li>
<li>All Druid Pods need permissions to be able to add labels to self-pod, List and Watch other Pods, create and read ConfigMap for leader election. Assuming, &quot;default&quot; service account is used by Druid pods, you might need to add following or something similar Kubernetes Role and Role Binding.</li>
</ul>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">apiVersion: rbac.authorization.k8s.io/v1</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">kind: Role</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">metadata:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> name: druid-cluster</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">rules:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">- apiGroups:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> - &quot;&quot;</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> resources:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> - pods</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> - configmaps</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> verbs:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> - &#x27;*&#x27;</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">---</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">kind: RoleBinding</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">apiVersion: rbac.authorization.k8s.io/v1</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">metadata:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> name: druid-cluster</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">subjects:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">- kind: ServiceAccount</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> name: default</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">roleRef:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> kind: Role</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> name: druid-cluster</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> apiGroup: rbac.authorization.k8s.io</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#configuration" class="table-of-contents__link toc-highlight">Configuration</a><ul><li><a href="#properties" class="table-of-contents__link toc-highlight">Properties</a></li><li><a href="#gotchas" class="table-of-contents__link toc-highlight">Gotchas</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="margin-bottom--sm"><img src="/img/favicon.png" class="footer__logo themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/favicon.png" class="footer__logo themedComponent_mlkZ themedComponent--dark_xIcU"></div><div class="footer__copyright">Copyright © 2025 Apache Software Foundation. Except where otherwise noted, licensed under CC BY-SA 4.0. Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></div></footer></div>
</body>
</html>