update ansible playbook
This commit is contained in:
parent
6011c75544
commit
ace5e11cec
@ -4,18 +4,20 @@
|
||||
- name: Install k8s
|
||||
hosts: all_vms
|
||||
remote_user: root
|
||||
vars:
|
||||
k8s_version_minor: "{{ '.'.join(k8s_version.split('.')[:-1]) }}"
|
||||
tasks:
|
||||
- name: Install k8s packages
|
||||
apt_rpm:
|
||||
community.general.apt_rpm:
|
||||
name:
|
||||
- kubernetes{{ k8s_version }}-kubeadm
|
||||
- kubernetes{{ k8s_version }}-kubelet
|
||||
- kubernetes{{ k8s_version }}-crio
|
||||
- cri-tools{{ k8s_version }}
|
||||
- kubernetes{{ k8s_version_minor }}-kubeadm
|
||||
- kubernetes{{ k8s_version_minor }}-kubelet
|
||||
- kubernetes{{ k8s_version_minor }}-crio
|
||||
- cri-tools{{ k8s_version_minor }}
|
||||
- wget
|
||||
update_cache: true
|
||||
- name: start and enable k8s services
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "{{ item }}"
|
||||
enabled: yes
|
||||
state: started
|
||||
@ -27,15 +29,12 @@
|
||||
hosts: master
|
||||
tasks:
|
||||
- name: run kubeadm init
|
||||
#shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml,FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml,FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml,FileAvailable--etc-kubernetes-manifests-etcd.yaml | grep 'kubeadm join' -A 1 | sed 's|\\\\||' | xargs"
|
||||
shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository=registry.altlinux.org/k8s-{{ branch }} | grep 'kubeadm join' -A 1 | sed 's|\\\\||' | xargs"
|
||||
#shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository=10.4.4.52:5000/k8s-{{ branch }} | grep 'kubeadm join' -A 1 | sed 's|\\\\||' | xargs"
|
||||
#shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 | grep 'kubeadm join' -A 1 | sed 's|\\\\||' | xargs"
|
||||
ansible.builtin.shell: "kubeadm init --pod-network-cidr=10.244.0.0/16 --image-repository=registry.altlinux.org/k8s-{{ branch }} --kubernetes-version={{ k8s_version }} | grep 'kubeadm join' -A 1 | sed 's|\\\\||' | xargs"
|
||||
register: kubeadm_init
|
||||
changed_when: kubeadm_init.rc == 0
|
||||
failed_when: kubeadm_init.rc not in [0, 2]
|
||||
- name: save join command
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ kubeadm_init.stdout }}"
|
||||
dest: kubeadm-join-command
|
||||
when: kubeadm_init.rc == 0
|
||||
@ -50,7 +49,7 @@
|
||||
hosts: workers
|
||||
tasks:
|
||||
- name: run kubeadm join
|
||||
command: "{{ lookup('file', 'tmp/kubeadm-join-command') }}"
|
||||
ansible.builtin.command: "{{ lookup('file', 'tmp/kubeadm-join-command') }}"
|
||||
register: kubeadm_join
|
||||
changed_when: kubeadm_join.rc == 0
|
||||
failed_when: kubeadm_join.rc not in [0, 2]
|
||||
@ -64,16 +63,13 @@
|
||||
ansible.builtin.replace:
|
||||
path: kube-flannel.yml
|
||||
regexp: '^([ tab]+)image: docker.io/flannel/flannel-cni-plugin:.*'
|
||||
replace: '\1image: registry.altlinux.org/k8s-{{ branch }}/flannel-cni-plugin:v1.4.0-flannel1'
|
||||
#- name: replace upstream flannel-cni-plugin image with alt image
|
||||
#ansible.builtin.replace:
|
||||
#path: kube-flannel.yml
|
||||
#regexp: '^([ tab]+)image: docker.io/flannel/(.*)'
|
||||
#replace: '\1image: registry.altlinux.org/k8s-sisyphus/\2'
|
||||
# TODO(geochip): Make it more generic instead of hardcoding versions
|
||||
replace: '\1image: registry.altlinux.org/k8s-{{ branch }}/flannel-cni-plugin:v1.5.1-flannel1'
|
||||
- name: replace upstream flannel image with alt image
|
||||
ansible.builtin.replace:
|
||||
path: kube-flannel.yml
|
||||
regexp: '^([ tab]+)image: docker.io/flannel/flannel:.*'
|
||||
# TODO(geochip): Make it more generic instead of hardcoding versions
|
||||
replace: '\1image: registry.altlinux.org/k8s-{{ branch }}/flannel:v0.25.1'
|
||||
- name: create flannel network
|
||||
ansible.builtin.command: kubectl apply -f kube-flannel.yml
|
||||
|
Loading…
Reference in New Issue
Block a user