Add KubeConfig field to API

This commit is contained in:
stefanprodan 2020-09-30 01:00:44 +03:00
parent ed929826dd
commit 2da8d7ca0c
5 changed files with 137 additions and 8 deletions

View File

@ -44,16 +44,20 @@ type KustomizationSpec struct {
// +optional
Decryption *Decryption `json:"decryption,omitempty"`
// The interval at which to apply the kustomization.
// The interval at which to reconcile the kustomization.
// +required
Interval metav1.Duration `json:"interval"`
// The KubeConfig for reconciling the Kustomization on a remote cluster.
// +optional
KubeConfig *KubeConfig `json:"kubeConfig,omitempty"`
// Path to the directory containing the kustomization file.
// +kubebuilder:validation:Pattern="^\\./"
// +required
Path string `json:"path"`
// Enables garbage collection.
// Prune enables garbage collection.
// +required
Prune bool `json:"prune"`
@ -117,6 +121,16 @@ type Decryption struct {
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
}
// KubeConfig references a Kubernetes secret generated by CAPI.
// that contains a kubeconfig file.
type KubeConfig struct {
// The secret name containing a 'value' key
// with the kubeconfig file as the value.
// Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24
// +required
SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"`
}
// KustomizationStatus defines the observed state of a kustomization.
type KustomizationStatus struct {
// ObservedGeneration is the last reconciled generation.

View File

@ -93,6 +93,22 @@ func (in *Decryption) DeepCopy() *Decryption {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *KubeConfig) DeepCopyInto(out *KubeConfig) {
*out = *in
out.SecretRef = in.SecretRef
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeConfig.
func (in *KubeConfig) DeepCopy() *KubeConfig {
if in == nil {
return nil
}
out := new(KubeConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Kustomization) DeepCopyInto(out *Kustomization) {
*out = *in
@ -166,6 +182,11 @@ func (in *KustomizationSpec) DeepCopyInto(out *KustomizationSpec) {
(*in).DeepCopyInto(*out)
}
out.Interval = in.Interval
if in.KubeConfig != nil {
in, out := &in.KubeConfig, &out.KubeConfig
*out = new(KubeConfig)
**out = **in
}
if in.HealthChecks != nil {
in, out := &in.HealthChecks, &out.HealthChecks
*out = make([]CrossNamespaceObjectReference, len(*in))

View File

@ -111,14 +111,28 @@ spec:
type: object
type: array
interval:
description: The interval at which to apply the kustomization.
description: The interval at which to reconcile the kustomization.
type: string
kubeConfig:
description: The KubeConfig for reconciling the Kustomization on a
remote cluster.
properties:
secretRef:
description: 'The secret name containing a ''value'' key with
the kubeconfig file as the value. Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24'
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
type: object
path:
description: Path to the directory containing the kustomization file.
pattern: ^\./
type: string
prune:
description: Enables garbage collection.
description: Prune enables garbage collection.
type: boolean
serviceAccount:
description: The Kubernetes service account used for applying the

View File

@ -108,7 +108,21 @@ Kubernetes meta/v1.Duration
</em>
</td>
<td>
<p>The interval at which to apply the kustomization.</p>
<p>The interval at which to reconcile the kustomization.</p>
</td>
</tr>
<tr>
<td>
<code>kubeConfig</code><br>
<em>
<a href="#kustomize.toolkit.fluxcd.io/v1alpha1.KubeConfig">
KubeConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The KubeConfig for reconciling the Kustomization on a remote cluster.</p>
</td>
</tr>
<tr>
@ -130,7 +144,7 @@ bool
</em>
</td>
<td>
<p>Enables garbage collection.</p>
<p>Prune enables garbage collection.</p>
</td>
</tr>
<tr>
@ -513,6 +527,43 @@ Kubernetes core/v1.LocalObjectReference
</table>
</div>
</div>
<h3 id="kustomize.toolkit.fluxcd.io/v1alpha1.KubeConfig">KubeConfig
</h3>
<p>
(<em>Appears on:</em>
<a href="#kustomize.toolkit.fluxcd.io/v1alpha1.KustomizationSpec">KustomizationSpec</a>)
</p>
<p>KubeConfig references a Kubernetes secret generated by CAPI.
that contains a kubeconfig file.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>secretRef</code><br>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
Kubernetes core/v1.LocalObjectReference
</a>
</em>
</td>
<td>
<p>The secret name containing a &lsquo;value&rsquo; key
with the kubeconfig file as the value.
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></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="kustomize.toolkit.fluxcd.io/v1alpha1.KustomizationSpec">KustomizationSpec
</h3>
<p>
@ -570,7 +621,21 @@ Kubernetes meta/v1.Duration
</em>
</td>
<td>
<p>The interval at which to apply the kustomization.</p>
<p>The interval at which to reconcile the kustomization.</p>
</td>
</tr>
<tr>
<td>
<code>kubeConfig</code><br>
<em>
<a href="#kustomize.toolkit.fluxcd.io/v1alpha1.KubeConfig">
KubeConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>The KubeConfig for reconciling the Kustomization on a remote cluster.</p>
</td>
</tr>
<tr>
@ -592,7 +657,7 @@ bool
</em>
</td>
<td>
<p>Enables garbage collection.</p>
<p>Prune enables garbage collection.</p>
</td>
</tr>
<tr>

View File

@ -25,6 +25,10 @@ type KustomizationSpec struct {
// +required
Interval metav1.Duration `json:"interval"`
// The KubeConfig for reconciling the Kustomization on a remote cluster.
// +optional
KubeConfig *KubeConfig `json:"kubeConfig,omitempty"`
// Path to the directory containing the kustomization file.
// +kubebuilder:validation:Pattern="^\\./"
// +required
@ -84,6 +88,17 @@ type Decryption struct {
}
```
KubeConfig references a Kubernetes secret generated by CAPI:
```go
type KubeConfig struct {
// The secret name containing a 'value' key with the kubeconfig file as the value.
// Ref: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/secret/consts.go#L24
// +required
SecretRef corev1.LocalObjectReference `json:"secretRef,omitempty"`
}
```
The status sub-resource records the result of the last reconciliation:
```go