forked from kptdev/krm-functions-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.go
More file actions
106 lines (82 loc) · 4 KB
/
Copy pathdocs.go
File metadata and controls
106 lines (82 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Code generated by "mdtogo"; DO NOT EDIT.
package generated
var SetNamespaceShort = `The ` + "`" + `set-namespace` + "`" + ` function replaces the ` + "`" + `namespace` + "`" + ` specific resource type in a variety
of KRM resources.`
var SetNamespaceLong = `
## Usage
This function replaces the KRM resources existing namespace to a new value.
### Target KRM resources
- This function updates all namespace-scoped KRM resources ` + "`" + `metadata.namespace` + "`" + ` fields.
We determine whether a KRM resource is namespace scoped by checking if it has ` + "`" + `metadata.namespace` + "`" + ` set and matches the "oldNamespace"
If not, this function won't add new namespace.
- This function updates ` + "`" + `RoleBinding` + "`" + ` and ` + "`" + `ClusterRoleBinding` + "`" + ` resources ` + "`" + `subjects` + "`" + ` element whose kind is ` + "`" + `ServiceAccount` + "`" + `
and the subject's ` + "`" + `namespace` + "`" + ` is set and matches the "oldNamespace".
- This function updates ` + "`" + `CustomResourceDefinition` + "`" + ` (CRD) ` + "`" + `spec/conversion/webhook/clientConfig/service/namespace` + "`" + ` field
if the field is set and matches the "oldNamespace"
- This function updates ` + "`" + `APIService` + "`" + ` ` + "`" + `spec/service/namespace` + "`" + ` field if the field is set and matches the "oldNamespace"
- This function updates the KRM resources annotation ` + "`" + `config.kubernetes.io/depends-on` + "`" + ` if this annotation contains the
matching namespace.
### FunctionConfig
This function supports the default ` + "`" + `ConfigMap` + "`" + ` as function config and a custom ` + "`" + `SetNamespace` + "`" + `. See below examples
ConfigMap as functionConfig
apiVersion: v1
kind: ConfigMap
data:
namespace: newNamespace # required
namespaceSelector: example # update namespace whose value is "example" to "newNamespace"
SetNamespace as functionConfig
apiVersion: fn.kpt.dev/v1alpha1
kind: SetNamespace
namespace: newNamespace # required
namespaceSelector: example # update namespace whose value is "example" to "newNamespace"
### Three updating modes
This function supports three modes to flexibly choose and update the target namespaces.
# Restrict Mode:
All target KRM resources namespace has to have the same value. All namespace will be updated to the new value.
ConfigMap as functionConfig
apiVersion: v1
kind: ConfigMap
data:
namespace: newNamespace # update all namespace fields to "newNamespace"
# DefaultNamespace Mode:
The input ` + "`" + `resourcelist.items` + "`" + ` contains one and only one namespace object. The function matches the namespace ` + "`" + `metadata.name` + "`" + `
with all other KRM resources, and only update the namespace if it matches the namespace object.
If more than one namespace objects are found, raise errors;
kind: ResourceList
functionConfig:
apiVersion: v1
kind: ConfigMap
data:
namespace: newNs
items:
- apiVersion: v1
kind: Namespace
metadata:
name: example # updated to "newNs"
- apiVersion: v1
kind: Service
metadata:
name: the-service1
namespace: example # updated to "newNs"
- apiVersion: v1
kind: Service
metadata:
name: the-service2
namespace: irrelevant # skip since namespace does not match "example".
# Selector Mode:
Only updates the namespace which matches a given value. The "oldNamespace" refers to the argument in FunctionConfig
ConfigMap as functionConfig
apiVersion: v1
kind: ConfigMap
data:
namespace: newNamespace
namespaceSelector: example # update namespace whose value is "example" to "newNamespace"
SetNamespace as functionConfig
apiVersion: fn.kpt.dev/v1alpha1
kind: SetNamespace
namespace: newNamespace
namespaceSelector: example # update namespace whose value is "example" to "newNamespace"
### DependsOn annotation
DependsOn annotation is a [kpt feature](https://kpt.dev/reference/annotations/depends-on/). This function updates the
namespace segment in a depends-on annotation if matches oldNs
`