Skip to content

Commit

Permalink
Add get-started code as starlark SDK user guide sample code (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenma authored May 14, 2022
1 parent f85503f commit 812496e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions starlark/get-started/data/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
10 changes: 10 additions & 0 deletions starlark/get-started/starlark-fn-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
name: set-annotation
# EDIT THE SOURCE!
# This should be your starlark script which preloads the `ResourceList` to `ctx.resource_list`
source: |
for resource in ctx.resource_list["items"]:
if resource.get("kind") == "Deployment":
resource["metadata"]["annotations"]["managed-by"] = "kpt"

0 comments on commit 812496e

Please sign in to comment.