Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
fa9a058a61
|
16
examples/containerized-krm/README.md
Normal file
16
examples/containerized-krm/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Container Plugin Example
|
||||
|
||||
This example runs `YqTransformer` as a **containerized KRM function**.
|
||||
|
||||
## Locate the plugin image
|
||||
|
||||
The `config.kubernetes.io/function` annotation in `yq-transformer.yaml`
|
||||
points to the plugin's image address in the `container.image` key.
|
||||
|
||||
## Build with alpha plugins enabled
|
||||
|
||||
```bash
|
||||
kustomize build --enable-alpha-plugins .
|
||||
```
|
||||
|
||||
You should see a label `environment: dev` added to one of the Deployments.
|
||||
8
examples/containerized-krm/kustomization.yaml
Normal file
8
examples/containerized-krm/kustomization.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../manifests
|
||||
|
||||
transformers:
|
||||
- yq-transformer.yaml
|
||||
18
examples/containerized-krm/yq-transformer.yaml
Normal file
18
examples/containerized-krm/yq-transformer.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: kustomize.bdeshi.space/v1
|
||||
kind: YqTransformer
|
||||
metadata:
|
||||
name: yq-transformer-dev-label # this can be anything
|
||||
annotations:
|
||||
config.kubernetes.io/function: |
|
||||
container:
|
||||
image: ghcr.io/bdeshi/kustomize-plugin-yqtransformer:latest
|
||||
targets:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: dev-app
|
||||
expression: |
|
||||
.metadata.labels.environment = "dev"
|
||||
| .spec.template.metadata.labels.environment = "dev"
|
||||
17
examples/exec-krm/README.md
Normal file
17
examples/exec-krm/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Exec Plugin Example
|
||||
|
||||
This example runs `YqTransformer` as an **exec KRM function**.
|
||||
|
||||
## Locate the plugin executable
|
||||
|
||||
The `config.kubernetes.io/function` annotation in `yq-transformer.yaml`
|
||||
points to the plugin's executable path in the `exec.path` key.
|
||||
This path is relative to `kustomization.yaml` and can be anywhere on disk.
|
||||
|
||||
## Build with alpha plugins and exec enabled
|
||||
|
||||
```bash
|
||||
kustomize build --enable-alpha-plugins --enable-exec .
|
||||
```
|
||||
|
||||
You should see a label `environment: dev` added to one of the Deployments.
|
||||
8
examples/exec-krm/kustomization.yaml
Normal file
8
examples/exec-krm/kustomization.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../manifests
|
||||
|
||||
transformers:
|
||||
- yq-transformer.yaml
|
||||
18
examples/exec-krm/yq-transformer.yaml
Normal file
18
examples/exec-krm/yq-transformer.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: kustomize.bdeshi.space/v1
|
||||
kind: YqTransformer
|
||||
metadata:
|
||||
name: yq-transformer-dev-label # this can be anything
|
||||
annotations:
|
||||
config.kubernetes.io/function: |
|
||||
exec:
|
||||
path: ../../YqTransformer.sh
|
||||
targets:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: dev-app
|
||||
expression: |
|
||||
.metadata.labels.environment = "dev"
|
||||
| .spec.template.metadata.labels.environment = "dev"
|
||||
35
examples/manifests/deployment.yaml
Normal file
35
examples/manifests/deployment.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: demo-app
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo-app
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo-app
|
||||
spec:
|
||||
serviceAccountName: demo-app
|
||||
containers:
|
||||
- name: app
|
||||
image: app:demo
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: demo-app-2
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo-app-2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo-app-2
|
||||
spec:
|
||||
serviceAccountName: dev-app
|
||||
containers:
|
||||
- name: app
|
||||
image: app:demo
|
||||
6
examples/manifests/kustomization.yaml
Normal file
6
examples/manifests/kustomization.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- serviceaccount.yaml
|
||||
9
examples/manifests/serviceaccount.yaml
Normal file
9
examples/manifests/serviceaccount.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: demo-app-1
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: dev-app
|
||||
Reference in New Issue
Block a user