github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/package-examples/ingress-nginx/README.md (about) 1 # ingress-nginx 2 3 ## Description 4 5 Nginx Ingress Controller package 6 7 ## Usage 8 9 ### Fetch the package 10 11 ```sh 12 kpt pkg get git@github.com:googlecontainertools/kpt.git/package-examples/ingress-nginx ingress-nginx 13 ``` 14 15 ### View package content 16 17 ```sh 18 19 kpt pkg tree ingress-nginx 20 21 ``` 22 23 ### Apply the package 24 25 ```sh 26 27 kpt live init ingress-nginx 28 kpt live apply ingress-nginx --reconcile-timeout=2m --output=table 29 30 ``` 31 32 ### How was this package created 33 34 ```sh 35 36 # download the static manifests from the github releases 37 wget -O ingress-nginx.yaml https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.3.0/deploy/static/provider/cloud/deploy.yaml 38 39 ``` 40 41 Starlark function to add `app.kubernetes.io/component` label if it doesn't exists. 42 43 ```yaml 44 45 ## default-label.yaml 46 47 apiVersion: fn.kpt.dev/v1alpha1 48 kind: StarlarkRun 49 metadata: 50 name: set-cluster-label 51 annotations: 52 source: | 53 # set the component label to cluster if not specified 54 def setlabel(resources): 55 for resource in resources: 56 curr_labels = resource.get("metadata").get("labels") 57 if "app.kubernetes.io/component" not in curr_labels: 58 resource["metadata"]["labels"]["app.kubernetes.io/component"] = "controller" 59 setlabel(ctx.resource_list["items"]) 60 ``` 61 62 Create the package 63 64 ```sh 65 66 mkdir ingress-nginx 67 kpt pkg init ingress-nginx 68 69 cat ingress-nginx.yaml |kpt fn eval - -o unwrap -i starlark:v0.4.3 --fn-config default-label.yaml| kubectl-slice --template '{{ index "app.kubernetes.io/component" .metadata.labels }}/{{.kind | lower}}-{{.metadata.name|dottodash}}.yaml' -o ingress-nginx --dry-run 70 71 ```