add roles support for worker nodes
This commit is contained in:
@@ -4,17 +4,17 @@ credentials:
|
|||||||
private_key_file: /Users/georgest/.ssh/id_rsa
|
private_key_file: /Users/georgest/.ssh/id_rsa
|
||||||
|
|
||||||
hosts:
|
hosts:
|
||||||
- hostname: k8s-master-1
|
master:
|
||||||
ip: "172.16.1.136"
|
- hostname: k8s-master-1
|
||||||
roles: [control_plane, etcd]
|
ip: "172.16.1.136"
|
||||||
|
worker:
|
||||||
|
- hostname: k8s-worker-1
|
||||||
|
ip: "172.16.1.135"
|
||||||
|
# roles: [infra]
|
||||||
|
|
||||||
- hostname: k8s-worker-1
|
- hostname: k8s-worker-2
|
||||||
ip: "172.16.1.135"
|
ip: "172.16.1.137"
|
||||||
roles: [node]
|
# roles: [ingress]
|
||||||
|
|
||||||
- hostname: k8s-worker-2
|
|
||||||
ip: "172.16.1.137"
|
|
||||||
roles: [node]
|
|
||||||
|
|
||||||
orchestrator:
|
orchestrator:
|
||||||
version: "1.32.4"
|
version: "1.32.4"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ type Config struct {
|
|||||||
InventoryDir string
|
InventoryDir string
|
||||||
Verbose bool
|
Verbose bool
|
||||||
KubeconfigFile string
|
KubeconfigFile string
|
||||||
|
Forks string `yaml:"forks" env-default:"10"`
|
||||||
InstallationName string `yaml:"installation_name" env-default:"cluster.local"`
|
InstallationName string `yaml:"installation_name" env-default:"cluster.local"`
|
||||||
Credentials struct {
|
Credentials struct {
|
||||||
User string `yaml:"user"`
|
User string `yaml:"user"`
|
||||||
@@ -37,7 +38,10 @@ type Config struct {
|
|||||||
PrivateKeyFile string `yaml:"private_key_file"`
|
PrivateKeyFile string `yaml:"private_key_file"`
|
||||||
} `yaml:"credentials"`
|
} `yaml:"credentials"`
|
||||||
|
|
||||||
Hosts []Host `yaml:"hosts"`
|
Hosts struct {
|
||||||
|
Masters []Host `yaml:"master"`
|
||||||
|
Workers []Host `yaml:"worker"`
|
||||||
|
} `yaml:"hosts"`
|
||||||
|
|
||||||
Orchestrator Orchestrator `yaml:"orchestrator"`
|
Orchestrator Orchestrator `yaml:"orchestrator"`
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ func runPlaybook(playbookPath string, tags string) {
|
|||||||
"ANSIBLE_DISPLAY_OK_HOSTS": "false",
|
"ANSIBLE_DISPLAY_OK_HOSTS": "false",
|
||||||
"ANSIBLE_FORCE_COLOR": "true",
|
"ANSIBLE_FORCE_COLOR": "true",
|
||||||
"ANSIBLE_HOST_KEY_CHECKING": "false",
|
"ANSIBLE_HOST_KEY_CHECKING": "false",
|
||||||
|
"ANSIBLE_FORKS": config.Forks,
|
||||||
}
|
}
|
||||||
|
|
||||||
playbookOptions := getPlaybookParameters(tags)
|
playbookOptions := getPlaybookParameters(tags)
|
||||||
|
|||||||
@@ -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 }}
|
{{ .Hostname }} ansible_host={{ .Ip }} ip={{ .Ip }} {{ if .User }}ansible_user={{ .User }}{{- end }} {{ if .Password }}ansible_ssh_password={{ .Password }}{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
[kube_control_plane]
|
[kube_control_plane]
|
||||||
{{- range .Hosts }}
|
{{- range .Hosts.Masters }}
|
||||||
{{- $search := "control_plane" -}}
|
|
||||||
{{- $found := false -}}
|
|
||||||
{{- range .Roles }}
|
|
||||||
{{- if eq . $search }}
|
|
||||||
{{- $found = true }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if $found }}
|
|
||||||
{{ .Hostname }}
|
{{ .Hostname }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
[etcd]
|
[etcd]
|
||||||
{{- range .Hosts }}
|
{{- range .Hosts.Masters }}
|
||||||
{{- $search := "etcd" -}}
|
|
||||||
{{- $found := false -}}
|
|
||||||
{{- range .Roles }}
|
|
||||||
{{- if eq . $search }}
|
|
||||||
{{- $found = true }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if $found }}
|
|
||||||
{{ .Hostname }}
|
{{ .Hostname }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
[kube_node]
|
[kube_node]
|
||||||
{{- range .Hosts }}
|
{{- range .Hosts.Workers }}
|
||||||
{{- $search := "node" -}}
|
{{ .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 }}
|
||||||
{{- $found := false -}}
|
|
||||||
{{- range .Roles }}
|
|
||||||
{{- if eq . $search }}
|
|
||||||
{{- $found = true }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if $found }}
|
|
||||||
{{ .Hostname }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
[all:vars]
|
[all:vars]
|
||||||
|
|||||||
Reference in New Issue
Block a user