feat: add annotations to node (#2594)

Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
liujian 2025-05-27 16:40:13 +08:00 committed by GitHub
parent 38944a5d2f
commit ff50e145ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View File

@ -73,3 +73,8 @@
- name: Add work label
command: |
/usr/local/bin/kubectl label --overwrite node {{ .hostname }} node-role.kubernetes.io/worker=
- name: Add annotations
when: .annotations | empty | not
command: |
kubectl annotate {{ .hostname }} {{- range $k,$v := .annotations }}{{ printf "%s=%s" $k $v}} {{- end }}

View File

@ -47,6 +47,11 @@
command: |
/usr/local/bin/kubectl label --overwrite node {{ .hostname }} node-role.kubernetes.io/worker=
- name: Add annotations
when: .annotations | empty | not
command: |
kubectl annotate {{ .hostname }} {{- range $k,$v := .annotations }}{{ printf "%s=%s" $k $v}} {{- end }}
- name: Set change custom hosts to localDNS file
when:
- eq .kubernetes.control_plane_endpoint.type "local"

View File

@ -188,6 +188,23 @@ func TestParseBool(t *testing.T) {
},
excepted: true,
},
// ======= empty =======
{
name: "empty true-1",
condition: []string{`{{ empty .foo }}`},
variable: map[string]any{
"foo": map[string]any{},
},
excepted: true,
},
{
name: "empty true-2",
condition: []string{`{{ empty .foo }}`},
variable: map[string]any{
"foo": []any{},
},
excepted: true,
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {