Skip to content

Commit

Permalink
Merge pull request #754 from klausenbusk/components
Browse files Browse the repository at this point in the history
Add support for Kustomize components
  • Loading branch information
stefanprodan authored Dec 5, 2022
2 parents e7e42e9 + b25dea8 commit a0c79e1
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 3 deletions.
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.

**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

0 comments on commit a0c79e1

Please sign in to comment.