Skip to content

Commit 812496e

Browse files
authored
Add get-started code as starlark SDK user guide sample code (#575)
1 parent f85503f commit 812496e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
spec:
6+
selector:
7+
app: MyApp
8+
ports:
9+
- protocol: TCP
10+
port: 80
11+
targetPort: 9376
12+
---
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: nginx-deployment
17+
labels:
18+
app: nginx
19+
spec:
20+
replicas: 3
21+
selector:
22+
matchLabels:
23+
app: nginx
24+
template:
25+
metadata:
26+
labels:
27+
app: nginx
28+
spec:
29+
containers:
30+
- name: nginx
31+
image: nginx:1.14.2
32+
ports:
33+
- containerPort: 80
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: fn.kpt.dev/v1alpha1
2+
kind: StarlarkRun
3+
metadata:
4+
name: set-annotation
5+
# EDIT THE SOURCE!
6+
# This should be your starlark script which preloads the `ResourceList` to `ctx.resource_list`
7+
source: |
8+
for resource in ctx.resource_list["items"]:
9+
if resource.get("kind") == "Deployment":
10+
resource["metadata"]["annotations"]["managed-by"] = "kpt"

0 commit comments

Comments
 (0)