Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Kustomize components #754

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1beta2/kustomization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ type KustomizationSpec struct {
// +kubebuilder:validation:Enum=none;client;server
// +optional
Validation string `json:"validation,omitempty"`

// Components specifies relative paths to specifications of other Components
// +optional
Components []string `json:"components,omitempty"`
}

// Decryption defines how decryption is handled for Kubernetes manifests.
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ spec:
description: KustomizationSpec defines the configuration to calculate
the desired state from a Source using Kustomize.
properties:
components:
description: Components specifies relative paths to specifications
of other Components
items:
type: string
type: array
decryption:
description: Decrypt Kubernetes secrets before applying them on the
cluster.
Expand Down
24 changes: 24 additions & 0 deletions docs/api/kustomize.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ string
<p>Deprecated: Not used in v1beta2.</p>
</td>
</tr>
<tr>
<td>
<code>components</code><br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Components specifies relative paths to specifications of other Components</p>
</td>
</tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -816,6 +828,18 @@ string
<p>Deprecated: Not used in v1beta2.</p>
</td>
</tr>
<tr>
<td>
<code>components</code><br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Components specifies relative paths to specifications of other Components</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
26 changes: 26 additions & 0 deletions docs/spec/v1beta2/kustomization.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ offering support for the following Kustomize directives:
- [namespace](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/namespace/)
- [patches](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patches/)
- [images](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/images/)
- [components](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/components/)

### Target namespace

Expand Down Expand Up @@ -654,6 +655,31 @@ spec:
digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
```

### Components

To add [Kustomize `components` entries](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/components/)
to the configuration, and use reusable pieces of configuration logic that can
be included from multiple overlays, `spec.components` can be defined:

```yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo
namespace: flux-system
spec:
# ...omitted for brevity
components:
- ingress
- tls
```

**Note:** The component paths must be local and relative.
stefanprodan marked this conversation as resolved.
Show resolved Hide resolved

**Warning:** Components are a alpha feature in Kustomize and are therefore
considered experimental in Flux. No guarantees are provided and the feature may
be modified in backwards incompatible ways or removed without warning.

## Variable substitution

With `spec.postBuild.substitute` you can provide a map of key/value pairs holding the
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/fluxcd/pkg/apis/kustomize v0.7.0
github.com/fluxcd/pkg/apis/meta v0.18.0
github.com/fluxcd/pkg/http/fetch v0.3.0
github.com/fluxcd/pkg/kustomize v0.10.0
github.com/fluxcd/pkg/kustomize v0.11.0
github.com/fluxcd/pkg/runtime v0.24.0
github.com/fluxcd/pkg/ssa v0.22.0
github.com/fluxcd/pkg/tar v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ github.com/fluxcd/pkg/apis/meta v0.18.0 h1:s0LeulWcQ4DxVX6805vgDTxlA6bAYk+Lq1QHS
github.com/fluxcd/pkg/apis/meta v0.18.0/go.mod h1:pYvXRFi1UKNNrGR34jw3uqOnMXw9X6dTkML8j5Z7tis=
github.com/fluxcd/pkg/http/fetch v0.3.0 h1:/mLj0IzTx+GhR09etzMJsBoNQ0qeOx9cSdeUgRB+oqM=
github.com/fluxcd/pkg/http/fetch v0.3.0/go.mod h1:dHTDYIeL0ZAQ9mHM6ZS4VProxho+Atm73MHJ55yj0Sg=
github.com/fluxcd/pkg/kustomize v0.10.0 h1:EG5MbYrLtxeCiZxeFUgvyBhFZaXnKfeqqpg7O+J7o3s=
github.com/fluxcd/pkg/kustomize v0.10.0/go.mod h1:awHID4OKe2/WAfTFg4u0fURXZPUkrIslSZNSPX9MEFQ=
github.com/fluxcd/pkg/kustomize v0.11.0 h1:zseS9LRUuzhP/7KamccmsOgYpJAdhqtsf+2wN/CHF3I=
github.com/fluxcd/pkg/kustomize v0.11.0/go.mod h1:awHID4OKe2/WAfTFg4u0fURXZPUkrIslSZNSPX9MEFQ=
github.com/fluxcd/pkg/runtime v0.24.0 h1:rQmm5Xq8K7f8xcPj1oNOInM1x4YwmgTucZJOP51Xmr4=
github.com/fluxcd/pkg/runtime v0.24.0/go.mod h1:I2T+HWVNzX0cxm9TgH+SVNHTwqlmEDiSke43JXsq9iY=
github.com/fluxcd/pkg/ssa v0.22.0 h1:HvJTuiYLZMxCjin7bAqBgnc2RjSqEfYrMbV5yINoM64=
Expand Down