@@ -791,14 +791,43 @@ with:
791
791
kustomize.toolkit.fluxcd.io/force: enabled
792
792
` ` `
793
793
794
- # ## KubeConfig reference
794
+ # ## KubeConfig (Remote clusters)
795
+
796
+ With the `.spec.kubeConfig` field a Kustomization
797
+ can apply and manage resources on a remote cluster.
798
+
799
+ The field `.spec.kubeConfig.provider` determines the type of remote cluster
800
+ and the authentication method used to connect to it. The following providers
801
+ are supported :
802
+
803
+ - `generic` : The default. Uses a KubeConfig stored in the Kubernetes Secret
804
+ referenced by `.spec.kubeConfig.secretRef`.
805
+ - `aws` : Secret-less authentication for remote EKS clusters with IAM Roles.
806
+ - `azure` : Secret-less authentication for remote AKS clusters with Managed
807
+ Identities.
808
+ - `gcp` : Secret-less authentication for remote GKE clusters with GCP Service
809
+ Accounts or Workload Identity Federation.
810
+
811
+ When both `.spec.kubeConfig` and
812
+ [`.spec.serviceAccountName`](#service-account-reference) are specified,
813
+ the controller will impersonate the ServiceAccount on the target cluster,
814
+ i.e. a ServiceAccount with name `.spec.serviceAccountName` must exist in
815
+ the target cluster inside a namespace with the same name as the namespace
816
+ of the Kustomization. For example, if the Kustomization is in the namespace
817
+ ` apps` of the cluster where Flux is running, then the ServiceAccount
818
+ must be in the `apps` namespace of the target remote cluster, and have the
819
+ name `.spec.serviceAccountName`. In other words, the namespace of the
820
+ Kustomization must exist both in the cluster where Flux is running
821
+ and in the target remote cluster where Flux will apply resources.
822
+
823
+ # ### Secret-based authentication
795
824
796
825
` .spec.kubeConfig.secretRef.Name` is an optional field to specify the name of
797
826
the secret containing a KubeConfig. If specified, objects will be applied,
798
827
health-checked, pruned, and deleted for the default cluster specified in that
799
828
KubeConfig instead of using the in-cluster ServiceAccount.
800
829
801
- The secret defined in the `kubeConfig.SecretRef ` must exist in the same
830
+ The secret defined in the `.spec. kubeConfig.secretRef ` must exist in the same
802
831
namespace as the Kustomization. On every reconciliation, the KubeConfig bytes
803
832
will be loaded from the `.secretRef.key` key (default : ` value` or `value.yaml`)
804
833
of the Secret’s data , and the Secret can thus be regularly updated if
@@ -822,12 +851,62 @@ stringData:
822
851
environment, or credential files from the kustomize-controller Pod.
823
852
This matches the constraints of KubeConfigs from current Cluster API providers.
824
853
KubeConfigs with `cmd-path` in them likely won't work without a custom,
825
- per-provider installation of kustomize-controller.
854
+ per-provider installation of kustomize-controller. For more information, see
855
+ [remote clusters/Cluster-API](#remote-cluster-api-clusters).
826
856
827
- When both `.spec.kubeConfig` and `.spec.ServiceAccountName` are specified,
828
- the controller will impersonate the service account on the target cluster.
857
+ # ### Secret-less authentication
829
858
830
- For more information, see [remote clusters/Cluster-API](#remote-clusterscluster-api).
859
+ For the `aws`, `azure` and `gcp` providers, the controller supports
860
+ secret-less authentication to remote EKS, AKS and GKE clusters
861
+ respectively.
862
+
863
+ When `.spec.kubeConfig.provider` is set to `aws`, `azure` or `gcp`,
864
+ the field `.spec.kubeConfig.cluster` becomes required and must be
865
+ set to the fully qualified name of the cluster resource in the
866
+ respective cloud provider :
867
+
868
+ * `aws`: `arn:<partition>:eks:<region>:<account-id>:cluster/<cluster-name>`
869
+ * `azure`: `/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ContainerService/managedClusters/<cluster-name>`
870
+ * `gcp`: `projects/<project-id>/locations/<location>/clusters/<cluster-name>`
871
+
872
+ Users can also optionally specify the address of the remote cluster
873
+ API server with the `.spec.kubeConfig.address` field. This field is
874
+ necessary in case the remote cluster has multiple addresses, e.g.
875
+ public and private addresses. If not specified, the controller will
876
+ select the first address available. If specified, the address has
877
+ to match at least one of the addresses of the remote cluster,
878
+ otherwise the controller will return an error.
879
+
880
+ The optional `.spec.kubeConfig.serviceAccountName` field can be used to
881
+ specify a ServiceAccount in the same namespace as the Kustomization for
882
+ object-level workload identity. Leaving this field empty will cause the
883
+ controller to use its own identity (ServiceAccount) for getting access
884
+ to the remote cluster.
885
+
886
+ For complete guides on workload identity and setting up permissions for
887
+ this feature, see the following docs :
888
+
889
+ * [EKS](/flux/integrations/aws/#for-amazon-elastic-kubernetes-service)
890
+ * [AKS](/flux/integrations/azure/#for-azure-kubernetes-service)
891
+ * [GKE](/flux/integrations/gcp/#for-google-kubernetes-engine)
892
+
893
+ Example for an EKS cluster :
894
+
895
+ ` ` ` yaml
896
+ apiVersion: kustomize.toolkit.fluxcd.io/v1
897
+ kind: Kustomization
898
+ metadata:
899
+ name: apps
900
+ namespace: flux-system
901
+ spec:
902
+ ... # other fields omitted for brevity
903
+ kubeConfig:
904
+ provider: aws
905
+ cluster: arn:aws:eks:eu-central-1:123456789012:cluster/my-cluster
906
+ address: https://my-prod-cluster.us-east-1.eks.amazonaws.com # optional
907
+ serviceAccountName: apps-iam-role # optional. maps to a cloud identity. used for authentication
908
+ serviceAccountName: apps-sa # optional. must exist in the target cluster. user for impersonation
909
+ ` ` `
831
910
832
911
# ## Decryption
833
912
@@ -1353,9 +1432,9 @@ When the flag is set, all Kustomizations which don't have [`.spec.serviceAccount
1353
1432
specified will use the service account name provided by
1354
1433
` --default-service-account=<SA Name>` in the namespace of the object.
1355
1434
1356
- # ## Remote clusters/ Cluster- API
1435
+ # ## Remote Cluster API clusters
1357
1436
1358
- With the [`.spec.kubeConfig` field ](#kubeconfig-reference ) a Kustomization can be fully
1437
+ Using a [`.spec.kubeConfig` reference ](#kubeconfig-remote-clusters ) a Kustomization can be fully
1359
1438
reconciled on a remote cluster. This composes well with Cluster API bootstrap
1360
1439
providers such as CAPBK (kubeadm), CAPA (AWS) and others.
1361
1440
0 commit comments