Skip to content

Commit

Permalink
feat(kustomize): add patches field (#5114) (#14648)
Browse files Browse the repository at this point in the history
  • Loading branch information
crenshaw-dev authored Sep 23, 2023
1 parent 08e53e7 commit 03c6e1a
Show file tree
Hide file tree
Showing 16 changed files with 9,951 additions and 858 deletions.
69 changes: 69 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6393,6 +6393,13 @@
"type": "string",
"title": "Namespace sets the namespace that Kustomize adds to all resources"
},
"patches": {
"type": "array",
"title": "Patches is a list of Kustomize patches",
"items": {
"$ref": "#/definitions/v1alpha1KustomizePatch"
}
},
"replicas": {
"type": "array",
"title": "Replicas is a list of Kustomize Replicas override specifications",
Expand Down Expand Up @@ -7265,6 +7272,20 @@
}
}
},
"v1alpha1KustomizeGvk": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"kind": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"v1alpha1KustomizeOptions": {
"type": "object",
"title": "KustomizeOptions are options for kustomize to use when building manifests",
Expand All @@ -7279,6 +7300,26 @@
}
}
},
"v1alpha1KustomizePatch": {
"type": "object",
"properties": {
"options": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
},
"patch": {
"type": "string"
},
"path": {
"type": "string"
},
"target": {
"$ref": "#/definitions/v1alpha1KustomizeSelector"
}
}
},
"v1alpha1KustomizeReplica": {
"type": "object",
"properties": {
Expand All @@ -7291,6 +7332,34 @@
}
}
},
"v1alpha1KustomizeResId": {
"type": "object",
"properties": {
"gvk": {
"$ref": "#/definitions/v1alpha1KustomizeGvk"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
}
}
},
"v1alpha1KustomizeSelector": {
"type": "object",
"properties": {
"annotationSelector": {
"type": "string"
},
"labelSelector": {
"type": "string"
},
"resId": {
"$ref": "#/definitions/v1alpha1KustomizeResId"
}
}
},
"v1alpha1ListGenerator": {
"type": "object",
"title": "ListGenerator include items info",
Expand Down
52 changes: 52 additions & 0 deletions docs/user-guide/kustomize.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,64 @@ The following configuration options are available for Kustomize:
* `namespace` is a kubernetes resources namespace
* `forceCommonAnnotations` is a boolean value which defines if it's allowed to override existing annotations
* `commonAnnotationsEnvsubst` is a boolean value which enables env variables substition in annotation values
* `patches` is a list of Kustomize patches that supports inline updates

To use Kustomize with an overlay, point your path to the overlay.

!!! tip
If you're generating resources, you should read up how to ignore those generated resources using the [`IgnoreExtraneous` compare option](compare-options.md).

## Patches
Patches are a way to kustomize resources using inline configurations in Argo CD applications. This allows for kustomizing without kustomization file. `patches` follow the same logic as the corresponding Kustomization. Any patches that target existing Kustomization file will be merged.

The following Kustomization can be done similarly in an Argo CD application.
```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
name: kustomize-inline-example
namespace: test1
resources:
- https://raw.githubusercontent.com/argoproj/argocd-example-apps/master/guestbook/guestbook-ui-deployment.yaml
- https://raw.githubusercontent.com/argoproj/argocd-example-apps/master/guestbook/guestbook-ui-svc.yaml
patches:
- target:
kind: Deployment
name: guestbook-ui
patch: |-
- op: replace
path: /spec/template/spec/containers/0/ports/0/containerPort
value: 443
```
Application will clone the repository, use the specified path, then kustomize using inline patches configuration.
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kustomize-inline-guestbook
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: test1
server: https://kubernetes.default.svc
project: default
source:
path: guestbook
repoURL: https://github.com/argoproj/argocd-example-apps.git
targetRevision: master
kustomize:
patches:
- target:
kind: Deployment
name: guestbook-ui
patch: |-
- op: replace
path: /spec/template/spec/containers/0/ports/0/containerPort
value: 443
```
## Private Remote Bases
If you have remote bases that are either (a) HTTPS and need username/password (b) SSH and need SSH private key, then they'll inherit that from the app's repo.
Expand Down
Loading

0 comments on commit 03c6e1a

Please sign in to comment.