add roles support for worker nodes

This commit is contained in:
2025-08-09 21:46:23 +03:00
parent 55fdd58f92
commit c2f41356cb
4 changed files with 24 additions and 43 deletions

View File

@@ -1,47 +1,23 @@
{{- range .Hosts }}
{{- range .Hosts.Masters }}
{{ .Hostname }} ansible_host={{ .Ip }} ip={{ .Ip }} {{ if .User }}ansible_user={{ .User }}{{- end }} {{ if .Password }}ansible_ssh_password={{ .Password }}{{- end }}
{{- end }}
{{- range .Hosts.Workers }}
{{ .Hostname }} ansible_host={{ .Ip }} ip={{ .Ip }} {{ if .User }}ansible_user={{ .User }}{{- end }} {{ if .Password }}ansible_ssh_password={{ .Password }}{{- end }}
{{- end }}
[kube_control_plane]
{{- range .Hosts }}
{{- $search := "control_plane" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{- range .Hosts.Masters }}
{{ .Hostname }}
{{- end }}
{{- end }}
[etcd]
{{- range .Hosts }}
{{- $search := "etcd" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{- range .Hosts.Masters }}
{{ .Hostname }}
{{- end }}
{{- end }}
[kube_node]
{{- range .Hosts }}
{{- $search := "node" -}}
{{- $found := false -}}
{{- range .Roles }}
{{- if eq . $search }}
{{- $found = true }}
{{- end }}
{{- end }}
{{- if $found }}
{{ .Hostname }}
{{- end }}
{{- range .Hosts.Workers }}
{{ .Hostname }}{{- if .Roles }} node_taints='[{{- range $i, $role := .Roles }}{{- if $i }},{{- end }}"node-role.kubernetes.io/{{ $role }}:NoSchedule"{{- end }}]' node_labels="{ {{- range $i, $role := .Roles }}{{- if $i }},{{- end }}'node-role.kubernetes.io/{{ $role }}': ''{{- end }} }"{{- end }}
{{- end }}
[all:vars]