fleet-docs/0.5/examples.html

17 lines
20 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-0.5 plugin-docs plugin-id-default docs-doc-id-examples">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.3.1">
<title data-rh="true">Examples | Fleet</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:url" content="https://fleet.rancher.io/0.5/examples"><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="0.5"><meta data-rh="true" name="docusaurus_tag" content="docs-default-0.5"><meta data-rh="true" name="docsearch:version" content="0.5"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-0.5"><meta data-rh="true" property="og:title" content="Examples | Fleet"><meta data-rh="true" name="description" content="Lifecycle of a Fleet Bundle"><meta data-rh="true" property="og:description" content="Lifecycle of a Fleet Bundle"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://fleet.rancher.io/0.5/examples"><link data-rh="true" rel="alternate" href="https://fleet.rancher.io/0.5/examples" hreflang="en"><link data-rh="true" rel="alternate" href="https://fleet.rancher.io/0.5/examples" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://5YEVIM7OXD-dsn.algolia.net" crossorigin="anonymous"><link rel="search" type="application/opensearchdescription+xml" title="Fleet" href="/opensearch.xml"><link rel="stylesheet" href="/assets/css/styles.3cf96da7.css">
<link rel="preload" href="/assets/js/runtime~main.3681bad0.js" as="script">
<link rel="preload" href="/assets/js/main.5f6cde4b.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</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"><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/logo.svg" alt="logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/logo.svg" alt="logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Fleet</b></a></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/0.5">0.5</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/">Next 🚧</a></li><li><a class="dropdown__link" href="/0.6">0.6</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/0.5/examples">0.5</a></li><li><a class="dropdown__link" href="/0.4/examples">0.4</a></li></ul></div><a aria-current="page" class="navbar__item navbar__link navbar__docs navbar__link--active" href="/0.5">Docs</a><a href="https://github.com/rancher/fleet" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar__github btn btn-secondary icon-github">GitHub<svg width="13.5" height="13.5" 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><a href="https://rancher-users.slack.com/channels/fleet" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-slack-link" aria-label="Slack Channel"></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/0.5">Overview</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/0.5/quickstart">Quick Start</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/0.5/concepts">Core Concepts</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/0.5/architecture">Architecture</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" href="/0.5/examples">Examples</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/0.5/cluster-overview">Operator Guide</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/0.5/gitrepo-add">User Guide</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/0.5/troubleshooting">Troubleshooting</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/0.5/advanced-users">Advanced Users</a></div></li></ul></nav></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="theme-doc-version-banner alert alert--warning margin-bottom--md" role="alert"><div>This is documentation for <!-- -->Fleet<!-- --> <b>0.5</b>, which is no longer actively maintained.</div><div class="margin-top--md">For up-to-date documentation, see the <b><a href="/">latest version</a></b> (<!-- -->Next 🚧<!-- -->).</div></div><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Examples</span><meta itemprop="position" content="1"></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">Version: 0.5</span><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"><h1>Examples</h1><h3 class="anchor anchorWithStickyNavbar_LWe7" id="lifecycle-of-a-fleet-bundle">Lifecycle of a Fleet Bundle<a href="#lifecycle-of-a-fleet-bundle" class="hash-link" aria-label="Direct link to Lifecycle of a Fleet Bundle" title="Direct link to Lifecycle of a Fleet Bundle"></a></h3><p>To demonstrate the lifecycle of a Fleet bundle, we will use <a href="https://github.com/rancher/fleet-examples/tree/master/multi-cluster/helm" target="_blank" rel="noopener noreferrer">multi-cluster/helm</a> as a case study.</p><ol><li>User will create a <a href="/0.5/gitrepo-add#create-gitrepo-instance">GitRepo</a> that points to the multi-cluster/helm repository.</li><li>The <code>gitjob-controller</code> will sync changes from the GitRepo and detect changes from the polling or <a href="/0.5/webhook">webhook event</a>. With every commit change, the <code>gitjob-controller</code> will create a job that clones the git repository, reads content from the repo such as <code>fleet.yaml</code> and other manifests, and creates the Fleet <a href="/0.5/cluster-bundles-state#bundles">bundle</a>.</li></ol><blockquote><p><strong>Note:</strong> The job pod with the image name <code>rancher/tekton-utils</code> will be under the same namespace as the GitRepo.</p></blockquote><ol start="3"><li>The <code>fleet-controller</code> then syncs changes from the bundle. According to the targets, the <code>fleet-controller</code> will create <code>BundleDeployment</code> resources, which are a combination of a bundle and a target cluster.</li><li>The <code>fleet-agent</code> will then pull the <code>BundleDeployment</code> from the Fleet controlplane. The agent deploys bundle manifests as a <a href="https://helm.sh/docs/intro/install/" target="_blank" rel="noopener noreferrer">Helm chart</a> from the <code>BundleDeployment</code> into the downstream clusters.</li><li>The <code>fleet-agent</code> will continue to monitor the application bundle and report statuses back in the following order: bundledeployment &gt; bundle &gt; GitRepo &gt; cluster.</li></ol><h3 class="anchor anchorWithStickyNavbar_LWe7" id="deploy-kubernetes-manifests-across-clusters-with-customization">Deploy Kubernetes Manifests Across Clusters with Customization<a href="#deploy-kubernetes-manifests-across-clusters-with-customization" class="hash-link" aria-label="Direct link to Deploy Kubernetes Manifests Across Clusters with Customization" title="Direct link to Deploy Kubernetes Manifests Across Clusters with Customization"></a></h3><p><a href="https://rancher.com/docs/rancher/v2.6/en/deploy-across-clusters/fleet/" target="_blank" rel="noopener noreferrer">Fleet in Rancher</a> allows users to manage clusters easily as if they were one cluster. Users can deploy bundles, which can be comprised of deployment manifests or any other Kubernetes resource, across clusters using grouping configuration.</p><p>To demonstrate how to deploy Kubernetes manifests across different clusters using Fleet, we will use <a href="https://github.com/rancher/fleet-examples/blob/master/multi-cluster/helm/fleet.yaml" target="_blank" rel="noopener noreferrer">multi-cluster/helm/fleet.yaml</a> as a case study.</p><p><strong>Situation:</strong> User has three clusters with three different labels: <code>env=dev</code>, <code>env=test</code>, and <code>env=prod</code>. User wants to deploy a frontend application with a backend database across these clusters. </p><p><strong>Expected behavior:</strong> </p><ul><li>After deploying to the <code>dev</code> cluster, database replication is not enabled.</li><li>After deploying to the <code>test</code> cluster, database replication is enabled.</li><li>After deploying to the <code>prod</code> cluster, database replication is enabled and Load balancer services are exposed.</li></ul><p><strong>Advantage of Fleet:</strong></p><p>Instead of deploying the app on each cluster, Fleet allows you to deploy across all clusters following these steps:</p><ol><li>Deploy gitRepo <code>https://github.com/rancher/fleet-examples.git</code> and specify the path <code>multi-cluster/helm</code>.</li><li>Under <code>multi-cluster/helm</code>, a Helm chart will deploy the frontend app service and backend database service.</li><li>The following rule will be defined in <code>fleet.yaml</code>: </li></ol><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"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">targetCustomizations:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">- name: dev</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> helm:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> values:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> replication: false</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> clusterSelector:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> matchLabels:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> env: dev</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">- name: test</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> helm:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> values:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> replicas: 3</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> clusterSelector:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> matchLabels:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> env: test</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">- name: prod</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> helm:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> values:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> serviceType: LoadBalancer</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> replicas: 3</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> clusterSelector:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> matchLabels:</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> env: prod</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 class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path 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 class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p><strong>Result:</strong></p><p>Fleet will deploy the Helm chart with your customized <code>values.yaml</code> to the different clusters.</p><blockquote><p><strong>Note:</strong> Configuration management is not limited to deployments but can be expanded to general configuration management. Fleet is able to apply configuration management through customization among any set of clusters automatically.</p></blockquote><h3 class="anchor anchorWithStickyNavbar_LWe7" id="additional-examples">Additional Examples<a href="#additional-examples" class="hash-link" aria-label="Direct link to Additional Examples" title="Direct link to Additional Examples"></a></h3><p>Examples using raw Kubernetes YAML, Helm charts, Kustomize, and combinations
of the three are in the <a href="https://github.com/rancher/fleet-examples/" target="_blank" rel="noopener noreferrer">Fleet Examples repo</a>.</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/rancher/fleet-docs/edit/main/versioned_docs/version-0.5/examples.md" target="_blank" rel="noreferrer noopener" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_vwxv"><span class="theme-last-updated">Last updated<!-- --> on <b><time datetime="2023-05-15T14:46:52.000Z">May 15, 2023</time></b></span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><a class="pagination-nav__link pagination-nav__link--prev" href="/0.5/architecture"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Architecture</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/0.5/cluster-overview"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Overview</div></a></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="#lifecycle-of-a-fleet-bundle" class="table-of-contents__link toc-highlight">Lifecycle of a Fleet Bundle</a></li><li><a href="#deploy-kubernetes-manifests-across-clusters-with-customization" class="table-of-contents__link toc-highlight">Deploy Kubernetes Manifests Across Clusters with Customization</a></li><li><a href="#additional-examples" class="table-of-contents__link toc-highlight">Additional Examples</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2023 SUSE Rancher. All Rights Reserved.</div></div></div></footer></div>
<script src="/assets/js/runtime~main.3681bad0.js"></script>
<script src="/assets/js/main.5f6cde4b.js"></script>
</body>
</html>