Skip to content

Commit 198eda8

Browse files
authored
Merge pull request #148 from fluxcd/docs/improve-kubeconfig-docs
Improve remote cluster documentation
2 parents df3af29 + 154560f commit 198eda8

File tree

4 files changed

+44
-66
lines changed

4 files changed

+44
-66
lines changed

api/v1beta1/kustomization_types.go

+9-15
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,16 @@ type Decryption struct {
122122
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
123123
}
124124

125-
// KubeConfig references a Kubernetes secret generated by CAPI.
126-
// that contains a kubeconfig file.
125+
// KubeConfig references a Kubernetes secret that contains a kubeconfig file.
127126
type KubeConfig struct {
128-
// The secret name containing a 'value' key with the kubeconfig file as the value.
129-
// This secret must be in the same Namespace as the Kustomization.
130-
// KubeConfig secrets maintained by Cluster API bootstrap providers can be used here.
131-
// (ex: If your CAPI Cluster's name is `stage`, set this to `stage-kubeconfig`.
132-
// Ensure the Kustomization is in the same Namespace as the Cluster object.
133-
// Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24)
134-
// The reconciliation clients are regularly refreshed from the Secret, so
135-
// rotating kubeconfigs for KaaS control-planes from cloud-providers are supported.
136-
// These kubeconfigs follow the same design constraints as Cluster API.
137-
// It is recommended that kubeconfigs be self-contained, and the Secret be
138-
// regularly updated if credentials such as a cloud-access-token expire.
139-
// Cloud-specific `cmd-path` auth helpers will not function without adding
140-
// binaries and credentials to the kustomize-controller Pod.
127+
// SecretRef holds the name to a secret that contains a 'value' key with
128+
// the kubeconfig file as the value. It must be in the same namespace as
129+
// the Kustomization.
130+
// It is recommended that the kubeconfig is self-contained, and the secret
131+
// is regularly updated if credentials such as a cloud-access-token expire.
132+
// Cloud specific `cmd-path` auth helpers will not function without adding
133+
// binaries and credentials to the Pod that is responsible for reconciling
134+
// the Kustomization.
141135
// +required
142136
SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"`
143137
}

config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml

+8-15
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,14 @@ spec:
118118
remote cluster.
119119
properties:
120120
secretRef:
121-
description: 'The secret name containing a ''value'' key with
122-
the kubeconfig file as the value. This secret must be in the
123-
same Namespace as the Kustomization. KubeConfig secrets maintained
124-
by Cluster API bootstrap providers can be used here. (ex: If
125-
your CAPI Cluster''s name is `stage`, set this to `stage-kubeconfig`.
126-
Ensure the Kustomization is in the same Namespace as the Cluster
127-
object. Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24)
128-
The reconciliation clients are regularly refreshed from the
129-
Secret, so rotating kubeconfigs for KaaS control-planes from
130-
cloud-providers are supported. These kubeconfigs follow the
131-
same design constraints as Cluster API. It is recommended that
132-
kubeconfigs be self-contained, and the Secret be regularly updated
133-
if credentials such as a cloud-access-token expire. Cloud-specific
134-
`cmd-path` auth helpers will not function without adding binaries
135-
and credentials to the kustomize-controller Pod.'
121+
description: SecretRef holds the name to a secret that contains
122+
a 'value' key with the kubeconfig file as the value. It must
123+
be in the same namespace as the Kustomization. It is recommended
124+
that the kubeconfig is self-contained, and the secret is regularly
125+
updated if credentials such as a cloud-access-token expire.
126+
Cloud specific `cmd-path` auth helpers will not function without
127+
adding binaries and credentials to the Pod that is responsible
128+
for reconciling the Kustomization.
136129
properties:
137130
name:
138131
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names

docs/api/kustomize.md

+9-15
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ Kubernetes core/v1.LocalObjectReference
449449
(<em>Appears on:</em>
450450
<a href="#kustomize.toolkit.fluxcd.io/v1beta1.KustomizationSpec">KustomizationSpec</a>)
451451
</p>
452-
<p>KubeConfig references a Kubernetes secret generated by CAPI.
453-
that contains a kubeconfig file.</p>
452+
<p>KubeConfig references a Kubernetes secret that contains a kubeconfig file.</p>
454453
<div class="md-typeset__scrollwrap">
455454
<div class="md-typeset__table">
456455
<table>
@@ -471,19 +470,14 @@ Kubernetes core/v1.LocalObjectReference
471470
</em>
472471
</td>
473472
<td>
474-
<p>The secret name containing a &lsquo;value&rsquo; key with the kubeconfig file as the value.
475-
This secret must be in the same Namespace as the Kustomization.
476-
KubeConfig secrets maintained by Cluster API bootstrap providers can be used here.
477-
(ex: If your CAPI Cluster&rsquo;s name is <code>stage</code>, set this to <code>stage-kubeconfig</code>.
478-
Ensure the Kustomization is in the same Namespace as the Cluster object.
479-
Ref: <a href="https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24)">https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24)</a>
480-
The reconciliation clients are regularly refreshed from the Secret, so
481-
rotating kubeconfigs for KaaS control-planes from cloud-providers are supported.
482-
These kubeconfigs follow the same design constraints as Cluster API.
483-
It is recommended that kubeconfigs be self-contained, and the Secret be
484-
regularly updated if credentials such as a cloud-access-token expire.
485-
Cloud-specific <code>cmd-path</code> auth helpers will not function without adding
486-
binaries and credentials to the kustomize-controller Pod.</p>
473+
<p>SecretRef holds the name to a secret that contains a &lsquo;value&rsquo; key with
474+
the kubeconfig file as the value. It must be in the same namespace as
475+
the Kustomization.
476+
It is recommended that the kubeconfig is self-contained, and the secret
477+
is regularly updated if credentials such as a cloud-access-token expire.
478+
Cloud specific <code>cmd-path</code> auth helpers will not function without adding
479+
binaries and credentials to the Pod that is responsible for reconciling
480+
the Kustomization.</p>
487481
</td>
488482
</tr>
489483
</tbody>

docs/spec/v1beta1/kustomization.md

+18-21
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,14 @@ This can be used with Cluster API:
9393

9494
```go
9595
type KubeConfig struct {
96-
// The secret name containing a 'value' key with the kubeconfig file as the value.
97-
// This secret must be in the same Namespace as the Kustomization.
98-
// KubeConfig secrets maintained by Cluster API bootstrap providers can be used here.
99-
// (ex: If your CAPI Cluster's name is `stage`, set this to `stage-kubeconfig`.
100-
// Ensure the Kustomization is in the same Namespace as the Cluster object.
101-
// Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24)
102-
// The reconciliation clients are regularly refreshed from the Secret, so
103-
// rotating kubeconfigs for KaaS control-planes from cloud-providers are supported.
104-
// These kubeconfigs follow the same design constraints as Cluster API.
105-
// It is recommended that kubeconfigs be self-contained, and the Secret be
106-
// regularly updated if credentials such as a cloud-access-token expire.
107-
// Cloud-specific `cmd-path` auth helpers will not function without adding
108-
// binaries and credentials to the kustomize-controller Pod.
96+
// SecretRef holds the name to a secret that contains a 'value' key with
97+
// the kubeconfig file as the value. It must be in the same namespace as
98+
// the Kustomization.
99+
// It is recommended that the kubeconfig is self-contained, and the secret
100+
// is regularly updated if credentials such as a cloud-access-token expire.
101+
// Cloud specific `cmd-path` auth helpers will not function without adding
102+
// binaries and credentials to the Pod that is responsible for reconciling
103+
// the Kustomization.
109104
// +required
110105
SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"`
111106
}
@@ -498,18 +493,19 @@ account. If the kustomization contains cluster level objects like CRDs or object
498493
namespace, the reconciliation will fail since the account it runs under has no permissions to alter objects
499494
outside of the `webapp` namespace.
500495

501-
## Cluster-API / Remote Clusters
496+
## Remote Clusters / Cluster-API
502497

503498
If the `kubeConfig` field is set, objects will be applied, health-checked, pruned, and deleted for the default
504499
cluster specified in that KubeConfig instead of using the in-cluster ServiceAccount.
505500

506-
This is done by specifying a KubeConfig from a Secret in the same Namespace as the Kustomization.
507-
The KubeConfig bytes are loaded from the `value` key of the Secret's data.
508-
This Secret can be regularly updated if cluster-access-tokens have to rotate due to expiration.
501+
The secret defined in the `kubeConfig.SecretRef` must exist in the same namespace as the Kustomization.
502+
On every reconciliation, the KubeConfig bytes will be loaded from the `values` key of the secret's data, and
503+
the secret can thus be regularly updated if cluster-access-tokens have to rotate due to expiration.
509504

510-
This composes well with Cluster API bootstrap providers such as CAPBK(kubeadm) as well as the CAPA(aws) EKS integration.
505+
This composes well with Cluster API bootstrap providers such as CAPBK (kubeadm) as well as the CAPA (AWS) EKS
506+
integration.
511507

512-
To reconcile a kustomization to a CAPI controlled cluster, put the `Kustomization` in the same Namespace as your
508+
To reconcile a Kustomization to a CAPI controlled cluster, put the `Kustomization` in the same namespace as your
513509
`Cluster` object, and set the `kubeConfig.secretRef.name` to `<cluster-name>-kubeconfig`:
514510

515511
```yaml
@@ -560,8 +556,9 @@ spec:
560556
The Cluster and Kustomization can be created at the same time.
561557
The Kustomization will eventually reconcile once the cluster is available.
562558

563-
If you wish to target clusters created by other means than CAPI, you can create a ServiceAccount on the remote cluster,
564-
generate a kube config for that account, then create a secret on the cluster where kustomize-controller is running e.g.:
559+
If you wish to target clusters created by other means than CAPI, you can create a ServiceAccount
560+
on the remote cluster, generate a KubeConfig for that account, and then create a secret on the
561+
cluster where kustomize-controller is running e.g.:
565562

566563
```sh
567564
kubectl create secret generic prod-kubeconfig \

0 commit comments

Comments
 (0)