Skip to content

Commit 793eefd

Browse files
committed
add functoin set-standard-labels
1 parent c653dc8 commit 793eefd

File tree

37 files changed

+1067
-0
lines changed

37 files changed

+1067
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 1e641f7..bb4be90 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -2,6 +2,9 @@ apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: the-map
9+
+ labels:
10+
+ color: orange
11+
+ fruit: apple
12+
data:
13+
some-key: some-value
14+
---
15+
@@ -10,6 +13,9 @@ kind: MyResource
16+
metadata:
17+
name: the-service
18+
namespace: the-namespace
19+
+ labels:
20+
+ color: orange
21+
+ fruit: apple
22+
spec:
23+
selector:
24+
labels:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kpt.dev/v1
2+
kind: Kptfile
3+
metadata:
4+
name: base-app
5+
annotations:
6+
config.kubernetes.io/local-config: "true"
7+
pipeline:
8+
mutators:
9+
- image: gcr.io/kpt-fn/set-standard-labels:unstable
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# set-standard-labels: Abstract Example
2+
3+
### Overview
4+
5+
This example demonstrates how to add kubernetes recommended labels to kpt Abstract (or Catalog) packages
6+
by running the [`set-starndard-labels`] function.
7+
8+
### Fetch the example package
9+
10+
Get the example package by running the following commands:
11+
12+
```shell
13+
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-stanrdard-labels-abstract
14+
```
15+
16+
We use the following `Kptfile` to configure the function.
17+
18+
```yaml
19+
apiVersion: kpt.dev/v1
20+
kind: Kptfile
21+
metadata:
22+
name: base-app
23+
annotations:
24+
config.kubernetes.io/local-config: "true"
25+
pipeline:
26+
mutators:
27+
- image: gcr.io/kpt-fn/set-standard-labels:unstable
28+
```
29+
30+
### Function invocation
31+
32+
Invoke the function by running the following commands:
33+
34+
```shell
35+
$ kpt fn render set-stanrdard-labels-abstract
36+
```
37+
38+
### Expected result
39+
40+
Check the deployment has label `app.kubernetes.io/name: base-app` added.
41+
42+
[`set-labels`]: https://catalog.kpt.dev/set-standard-labels/v0.1/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: base-app
6+
namespace: example
7+
spec:
8+
selector:
9+
matchLabels:
10+
test: abstract-base-app
11+
template:
12+
metadata:
13+
labels:
14+
test: abstract-base-app
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 1e641f7..bb4be90 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -2,6 +2,9 @@ apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: the-map
9+
+ labels:
10+
+ color: orange
11+
+ fruit: apple
12+
data:
13+
some-key: some-value
14+
---
15+
@@ -10,6 +13,9 @@ kind: MyResource
16+
metadata:
17+
name: the-service
18+
namespace: the-namespace
19+
+ labels:
20+
+ color: orange
21+
+ fruit: apple
22+
spec:
23+
selector:
24+
labels:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kpt.dev/v1
2+
kind: Kptfile
3+
metadata:
4+
name: frontend
5+
annotations:
6+
config.kubernetes.io/local-config: "true"
7+
pipeline:
8+
mutators:
9+
- image: gcr.io/kpt-fn/set-standard-labels:unstable
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# set-standard-labels: Blueprint Example
2+
3+
### Overview
4+
5+
This example demonstrates how to add kubernetes recommended labels to kpt Blueprint packages
6+
by running the [`set-starndard-labels`] function.
7+
8+
### Fetch the example package
9+
10+
Get the example package by running the following commands:
11+
12+
```shell
13+
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-stanrdard-labels-blueprint
14+
```
15+
16+
We use the following `Kptfile` to configure the function.
17+
18+
```yaml
19+
apiVersion: kpt.dev/v1
20+
kind: Kptfile
21+
metadata:
22+
name: frontend
23+
annotations:
24+
config.kubernetes.io/local-config: "true"
25+
```
26+
27+
### Function invocation
28+
29+
Invoke the function by running the following commands:
30+
31+
```shell
32+
$ kpt fn render set-stanrdard-labels-blueprint
33+
```
34+
35+
### Expected result
36+
37+
Check the deployment has label `app.kubernetes.io/name: frontend` added.
38+
39+
[`set-labels`]: https://catalog.kpt.dev/set-standard-labels/v0.1/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: base-app
5+
namespace: example
6+
labels:
7+
test: abstract-base-app
8+
app.kubernetes.io/name: base-app
9+
spec:
10+
selector:
11+
matchLabels:
12+
test: abstract-base-app
13+
app.kubernetes.io/name: base-app
14+
template:
15+
metadata:
16+
labels:
17+
test: abstract-base-app
18+
app.kubernetes.io/name: base-app
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 1e641f7..bb4be90 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -2,6 +2,9 @@ apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: the-map
9+
+ labels:
10+
+ color: orange
11+
+ fruit: apple
12+
data:
13+
some-key: some-value
14+
---
15+
@@ -10,6 +13,9 @@ kind: MyResource
16+
metadata:
17+
name: the-service
18+
namespace: the-namespace
19+
+ labels:
20+
+ color: orange
21+
+ fruit: apple
22+
spec:
23+
selector:
24+
labels:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kpt.dev/v1
2+
kind: Kptfile
3+
metadata:
4+
name: frontend-dev
5+
annotations:
6+
config.kubernetes.io/local-config: "true"
7+
pipeline:
8+
mutators:
9+
- image: gcr.io/kpt-fn/set-standard-labels:unstable

0 commit comments

Comments
 (0)