Skip to content

Commit 58ba924

Browse files
committed
update info and move multi-tenancy to conceptual topic
1 parent 59325d1 commit 58ba924

File tree

2 files changed

+118
-417
lines changed

2 files changed

+118
-417
lines changed

articles/azure-arc/kubernetes/conceptual-gitops-flux2.md

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "GitOps Flux v2 configurations with AKS and Azure Arc-enabled Kubernetes"
33
description: "This article provides a conceptual overview of GitOps in Azure for use in Azure Arc-enabled Kubernetes and Azure Kubernetes Service (AKS) clusters."
4-
ms.date: 10/24/2022
4+
ms.date: 11/29/2022
55
ms.topic: conceptual
66
---
77

@@ -17,7 +17,7 @@ With GitOps, you declare the desired state of your Kubernetes clusters in files
1717

1818
Because these files are stored in a Git repository, they're versioned, and changes between versions are easily tracked. Kubernetes controllers run in the clusters and continually reconcile the cluster state with the desired state declared in the Git repository. These operators pull the files from the Git repositories and apply the desired state to the clusters. The operators also continuously assure that the cluster remains in the desired state.
1919

20-
GitOps on Azure Arc-enabled Kubernetes or Azure Kubernetes Service uses [Flux](https://fluxcd.io/docs/), a popular open-source tool set. Flux provides support for common file sources (Git and Helm repositories, Buckets, Azure Blob Storage) and template types (YAML, Helm, and Kustomize). Flux also supports multi-tenancy and deployment dependency management, among [other features](https://fluxcd.io/docs/).
20+
GitOps on Azure Arc-enabled Kubernetes or Azure Kubernetes Service uses [Flux](https://fluxcd.io/docs/), a popular open-source tool set. Flux provides support for common file sources (Git and Helm repositories, Buckets, Azure Blob Storage) and template types (YAML, Helm, and Kustomize). Flux also supports [multi-tenancy](#multi-tenancy) and deployment dependency management, among [other features](https://fluxcd.io/docs/).
2121

2222
## Flux cluster extension
2323

@@ -498,6 +498,114 @@ Examples
498498
--kustomization-name my-kustomization-2 --path ./my/path --prune --force
499499
```
500500

501+
## Multi-tenancy
502+
503+
Flux v2 supports [multi-tenancy](https://github.com/fluxcd/flux2-multi-tenancy) in [version 0.26](https://fluxcd.io/blog/2022/01/january-update/#flux-v026-more-secure-by-default). This capability has been integrated into Azure GitOps with Flux v2.
504+
505+
>[ !NOTE]
506+
> For the multi-tenancy feature, you need to know if your manifests contain any cross-namespace sourceRef for HelmRelease, Kustomization, ImagePolicy, or other objects, or [if you use a Kubernetes version less than 1.20.6](https://fluxcd.io/blog/2022/01/january-update/#flux-v026-more-secure-by-default). To prepare, take these actions:
507+
>
508+
> * Upgrade to Kubernetes version 1.20.6 or greater.
509+
> * In your Kubernetes manifests, assure that all `sourceRef` are to objects within the same namespace as the GitOps configuration.
510+
> * If you need time to update your manifests, you can [opt out of multi-tenancy](#opt-out-of-multi-tenancy). However, you still need to upgrade your Kubernetes version.
511+
512+
### Update manifests for multi-tenancy
513+
514+
Let’s say you deploy a `fluxConfiguration` to one of our Kubernetes clusters in the **cluster-config** namespace with cluster scope. You configure the source to sync the `https://github.com/fluxcd/flux2-kustomize-helm-example` repo. This is the same sample Git repo used in the [Deploy applications using GitOps with Flux v2 tutorial](tutorial-use-gitops-flux2.md). After Flux syncs the repo, it will deploy the resources described in the manifests (YAML files). Two of the manifests describe HelmRelease and HelmRepository objects.
515+
516+
```yaml
517+
apiVersion: helm.toolkit.fluxcd.io/v2beta1
518+
kind: HelmRelease
519+
metadata:
520+
name: nginx
521+
namespace: nginx
522+
spec:
523+
releaseName: nginx-ingress-controller
524+
chart:
525+
spec:
526+
chart: nginx-ingress-controller
527+
sourceRef:
528+
kind: HelmRepository
529+
name: bitnami
530+
namespace: flux-system
531+
version: "5.6.14"
532+
interval: 1h0m0s
533+
install:
534+
remediation:
535+
retries: 3
536+
# Default values
537+
# https://github.com/bitnami/charts/blob/master/bitnami/nginx-ingress-controller/values.yaml
538+
values:
539+
service:
540+
type: NodePort
541+
```
542+
543+
```yaml
544+
apiVersion: source.toolkit.fluxcd.io/v1beta1
545+
kind: HelmRepository
546+
metadata:
547+
name: bitnami
548+
namespace: flux-system
549+
spec:
550+
interval: 30m
551+
url: https://charts.bitnami.com/bitnami
552+
```
553+
554+
By default, the Flux extension will deploy the `fluxConfigurations` by impersonating the **flux-applier** service account that is deployed only in the **cluster-config** namespace. Using the above manifests, when multi-tenancy is enabled the HelmRelease would be blocked. This is because the HelmRelease is in the **nginx** namespace and is referencing a HelmRepository in the **flux-system** namespace. Also, the Flux helm-controller cannot apply the HelmRelease, because there is no **flux-applier** service account in the **nginx** namespace.
555+
556+
To work with multi-tenancy, the correct approach is to deploy all Flux objects into the same namespace as the `fluxConfigurations`. This avoids the cross-namespace reference issue, and allows the Flux controllers to get the permissions to apply the objects. Thus, for a GitOps configuration created in the **cluster-config** namespace, the above manifests would change to these:
557+
558+
```yaml
559+
apiVersion: helm.toolkit.fluxcd.io/v2beta1
560+
kind: HelmRelease
561+
metadata:
562+
name: nginx
563+
namespace: cluster-config
564+
spec:
565+
releaseName: nginx-ingress-controller
566+
targetNamespace: nginx
567+
chart:
568+
spec:
569+
chart: nginx-ingress-controller
570+
sourceRef:
571+
kind: HelmRepository
572+
name: bitnami
573+
namespace: cluster-config
574+
version: "5.6.14"
575+
interval: 1h0m0s
576+
install:
577+
remediation:
578+
retries: 3
579+
# Default values
580+
# https://github.com/bitnami/charts/blob/master/bitnami/nginx-ingress-controller/values.yaml
581+
values:
582+
service:
583+
type: NodePort
584+
```
585+
586+
```yaml
587+
apiVersion: source.toolkit.fluxcd.io/v1beta1
588+
kind: HelmRepository
589+
metadata:
590+
name: bitnami
591+
namespace: cluster-config
592+
spec:
593+
interval: 30m
594+
url: https://charts.bitnami.com/bitnami
595+
```
596+
597+
### Opt out of multi-tenancy
598+
599+
When the `microsoft.flux` extension is installed, multi-tenancy is enabled by default to assure security by default in your clusters. However, if you need to disable multi-tenancy, you can opt out by creating or updating the `microsoft.flux` extension in your clusters with "--configuration-settings multiTenancy.enforce=false":
600+
601+
```azurecli
602+
az k8s-extension create --extension-type microsoft.flux --configuration-settings multiTenancy.enforce=false -c CLUSTER_NAME -g RESOURCE_GROUP -n flux -t <managedClusters or connectedClusters>
603+
```
604+
605+
```azurecli
606+
az k8s-extension update --configuration-settings multiTenancy.enforce=false -c CLUSTER_NAME -g RESOURCE_GROUP -n flux -t <managedClusters or connectedClusters>
607+
```
608+
501609
## Next steps
502610

503611
* Use our tutorial to learn how to [enable GitOps on your AKS or Azure Arc-enabled Kubernetes clusters](tutorial-use-gitops-flux2.md).

0 commit comments

Comments
 (0)