mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-ansible-private.git
synced 2025-10-27 08:43:05 +00:00
Compare commits
15 Commits
75ca33bfa9
...
47b3cb9bd4
| Author | SHA1 | Date | |
|---|---|---|---|
| 47b3cb9bd4 | |||
| b016fd12ca | |||
| 805b5c0817 | |||
| def84bb4de | |||
| 8b7a067374 | |||
| 249f9cadf3 | |||
| ff172ce20d | |||
| 542b70c057 | |||
| 13fc57c614 | |||
| 52ddca4910 | |||
| 05600edcec | |||
| ac9d93a0fb | |||
| 0324d38eb4 | |||
| 1c5db46acc | |||
| fd6cae2c81 |
@ -22,7 +22,7 @@
|
|||||||
replace:
|
replace:
|
||||||
path: /tmp/kube-flannel.yml
|
path: /tmp/kube-flannel.yml
|
||||||
regexp: '10\.244\.0\.0/16'
|
regexp: '10\.244\.0\.0/16'
|
||||||
replace: '192.168.2.0/16' # .3.
|
replace: '192.168.2.0/24' # .3.
|
||||||
|
|
||||||
- name: Corrigir net-conf.json no manifest do Flannel
|
- name: Corrigir net-conf.json no manifest do Flannel
|
||||||
become: true
|
become: true
|
||||||
@ -55,7 +55,7 @@
|
|||||||
argv:
|
argv:
|
||||||
- kubeadm
|
- kubeadm
|
||||||
- init
|
- init
|
||||||
- --pod-network-cidr=192.168.2.0/16 # .3.
|
- --pod-network-cidr=192.168.2.0/24 # .3.
|
||||||
- --apiserver-advertise-address=192.168.1.150
|
- --apiserver-advertise-address=192.168.1.150
|
||||||
creates: /etc/kubernetes/admin.conf
|
creates: /etc/kubernetes/admin.conf
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ with open("/tmp/kube-flannel.yml", "r") as f:
|
|||||||
for doc in docs:
|
for doc in docs:
|
||||||
if doc.get("kind") == "ConfigMap" and doc.get("metadata", {}).get("name") == "kube-flannel-cfg":
|
if doc.get("kind") == "ConfigMap" and doc.get("metadata", {}).get("name") == "kube-flannel-cfg":
|
||||||
doc["data"]["net-conf.json"] = '''{
|
doc["data"]["net-conf.json"] = '''{
|
||||||
"Network": "192.168.2.0/16",
|
"Network": "192.168.2.0/24",
|
||||||
"Backend": {
|
"Backend": {
|
||||||
"Type": "vxlan"
|
"Type": "vxlan"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,6 +2,30 @@
|
|||||||
hostname:
|
hostname:
|
||||||
name: "ubuntu-{{ ansible_play_hosts.index(inventory_hostname) }}"
|
name: "ubuntu-{{ ansible_play_hosts.index(inventory_hostname) }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Obter hostname real do nó
|
||||||
|
become: true
|
||||||
|
command: hostname
|
||||||
|
register: node_hostname
|
||||||
|
|
||||||
|
- name: Verificar se o nó já está no cluster
|
||||||
|
shell: |
|
||||||
|
kubectl get nodes --no-headers | grep -w {{ node_hostname.stdout }} || echo "NOT_IN_CLUSTER"
|
||||||
|
register: node_status
|
||||||
|
environment:
|
||||||
|
KUBECONFIG: /etc/kubernetes/kubelet.conf
|
||||||
|
|
||||||
|
|
||||||
- name: Join Kubernetes cluster
|
- name: Join Kubernetes cluster
|
||||||
shell: "{{ hostvars['master1']['kubeadm_join_command'] }}"
|
shell: "{{ hostvars['master1']['kubeadm_join_command'] }}"
|
||||||
when: hostvars['master1']['kubeadm_join_command'] is defined
|
when:
|
||||||
|
- hostvars['master1']['kubeadm_join_command'] is defined
|
||||||
|
- node_status.stdout | trim == "NOT_IN_CLUSTER"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Atribuir podCIDR ao nó via hostname real
|
||||||
|
shell: |
|
||||||
|
kubectl patch node {{ node_hostname.stdout }} -p '{"spec":{"podCIDR":"192.168.2.0/24"}}'
|
||||||
|
when:
|
||||||
|
- hostvars['master1']['kubeadm_join_command'] is defined
|
||||||
|
- node_status.stdout | trim == "NOT_IN_CLUSTER"
|
||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
- name: Gerar config.toml padrão do containerd
|
- name: Gerar config.toml padrão do containerd
|
||||||
become: true
|
become: true
|
||||||
command: containerd config default > /etc/containerd/config.toml
|
shell: containerd config default > /etc/containerd/config.toml
|
||||||
args:
|
args:
|
||||||
creates: /etc/containerd/config.toml
|
creates: /etc/containerd/config.toml
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user