Skip to content

Commit

Permalink
Merge pull request #762 from ccamacho/tkflow
Browse files Browse the repository at this point in the history
fix: remove libvirt virt-install options that are not used
  • Loading branch information
ccamacho authored Jul 27, 2023
2 parents 5e1e627 + 16d8d9c commit 8c121dd
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions kubeinit/roles/kubeinit_eks/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
kubeinit_eks_debug: "{{ (ansible_verbosity | int) >= 2 | bool }}"
kubeinit_eks_hide_sensitive_logs: true

kubeinit_eks_pod_network: 10.244.0.0
# This is the cluster CIDR
kubeinit_eks_pod_network_cidr: 10.244.0.0/16
kubeinit_eks_pod_subnet_len: 16

kubeinit_eks_service_network_cidr: 10.96.0.0/12

kubeinit_eks_common_dependencies:
Expand Down
35 changes: 26 additions & 9 deletions kubeinit/roles/kubeinit_eks/tasks/post_configure_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@

- name: Make sure cri-o binary is reachable and the configuration is correct
ansible.builtin.shell: |
yum install -y jq
# Make sure crio binary is reachable
ln -s /usr/bin/crio /usr/local/bin/crio
tmp=$(mktemp)
crioconf=$(ls /etc/cni/net.d/87-crio-bridge* | xargs realpath)
jq '.plugins[0].ipam.ranges[0][0].subnet = "{{ kubeinit_eks_pod_network }}/{{ kubeinit_eks_pod_subnet_len }}"' "$crioconf" > "$tmp" && mv -f "$tmp" "$crioconf"
# jq '.type = "flannel"' /etc/cni/net.d/87-crio-bridge.conf > "$tmp" && mv -f "$tmp" /etc/cni/net.d/87-crio-bridge.conf
# rm -rf /etc/cni/net.d/87-crio-bridge.conf
# echo '{"name": "crio","type": "flannel"}' > /etc/cni/net.d/10-crio.conf
cp /etc/crio/crio.conf /etc/crio/crio.conf.backup
sed -i s/^.*default_runtime\ =\ .*$/default_runtime\ =\ \"crun\"/g /etc/crio/crio.conf
# There is no example config for crun anymore
# sed -i "s/^\#\[crio\.runtime\.runtimes\.crun.*\]/[crio.runtime.runtimes.crun]/g" /etc/crio/crio.conf
#sed -i "s/^\#\[crio\.runtime\.runtimes\.crun.*\]/[crio.runtime.runtimes.crun]/g" /etc/crio/crio.conf
cat << EOF >> /etc/crio/crio.conf
[crio.runtime.runtimes.crun]
runtime_path = "/usr/bin/crun"
Expand Down Expand Up @@ -141,30 +149,39 @@
register: _result
changed_when: "_result.rc == 0"

- name: Install (replace) requirements
- name: Install (replace) kubectl
ansible.builtin.shell: |
set -eo pipefail
# TODO:FIXME: Replace with a loop
# Binaries to be replaced
bin_files="kubectl kubeadm kubelet"
for val in $bin_files; do
echo "Replacing $val"
done
# kubectl
kubectl_bin=$( curl -s https://distro.eks.amazonaws.com/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}-eks-{{ kubeinit_eks_revision }}.yaml | \
yq '.status.components | map(select(.name == "kubernetes")) | .[0].assets | map(select(.name == "bin/linux/amd64/kubectl")) | .[0].archive.uri' | tr -d '"')
wget -q $kubectl_bin
chmod +x kubectl
mv ./kubectl $(which kubectl)
args:
executable: /bin/bash
register: _result
changed_when: "_result.rc == 0"

- name: Install (replace) kubeadm
ansible.builtin.shell: |
set -eo pipefail
# kubeadm
kubeadm_bin=$( curl -s https://distro.eks.amazonaws.com/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}-eks-{{ kubeinit_eks_revision }}.yaml | \
yq '.status.components | map(select(.name == "kubernetes")) | .[0].assets | map(select(.name == "bin/linux/amd64/kubeadm")) | .[0].archive.uri' | tr -d '"')
wget -q $kubeadm_bin
chmod +x kubeadm
mv ./kubeadm $(which kubeadm)
args:
executable: /bin/bash
register: _result
changed_when: "_result.rc == 0"

- name: Install (replace) kubelet
ansible.builtin.shell: |
set -eo pipefail
# kubelet
kubelet_bin=$( curl -s https://distro.eks.amazonaws.com/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}/kubernetes-{{ kubeinit_eks_kubernetes_major_minor }}-eks-{{ kubeinit_eks_revision }}.yaml | \
Expand Down
3 changes: 2 additions & 1 deletion kubeinit/roles/kubeinit_k8s/tasks/post_configure_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
# Make sure crio binary is reachable
ln -s /usr/bin/crio /usr/local/bin/crio
tmp=$(mktemp)
jq '.plugins[0].ipam.ranges[0][0].subnet = "{{ kubeinit_k8s_pod_network }}/{{ kubeinit_k8s_pod_subnet_len }}"' /etc/cni/net.d/87-crio-bridge.conflist > "$tmp" && mv -f "$tmp" /etc/cni/net.d/87-crio-bridge.conflist
crioconf=$(ls /etc/cni/net.d/87-crio-bridge* | xargs realpath)
jq '.plugins[0].ipam.ranges[0][0].subnet = "{{ kubeinit_k8s_pod_network }}/{{ kubeinit_k8s_pod_subnet_len }}"' "$crioconf" > "$tmp" && mv -f "$tmp" "$crioconf"
# jq '.type = "flannel"' /etc/cni/net.d/87-crio-bridge.conf > "$tmp" && mv -f "$tmp" /etc/cni/net.d/87-crio-bridge.conf
# rm -rf /etc/cni/net.d/87-crio-bridge.conf
# echo '{"name": "crio","type": "flannel"}' > /etc/cni/net.d/10-crio.conf
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_libvirt/tasks/deploy_centos_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@
--connect qemu:///system \
--name {{ hostvars[kubeinit_deployment_node_name].guest_name }} \
--memory memory={{ hostvars[kubeinit_deployment_node_name].ram|int // 1024 }} \
--cpuset auto \
--vcpus {{ hostvars[kubeinit_deployment_node_name].vcpus }},maxvcpus={{ hostvars[kubeinit_deployment_node_name].maxvcpus }} \
--os-type linux \
--os-variant rhel8.0 \
--autostart \
--network network={{ kubeinit_cluster_hostvars.network_name }},mac={{ hostvars[kubeinit_deployment_node_name].mac }},virtualport.parameters.interfaceid={{ hostvars[kubeinit_deployment_node_name].interfaceid }},target.dev=veth0-{{ hostvars[kubeinit_deployment_node_name].ansible_host | ansible.utils.ip4_hex }},model=virtio \
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_libvirt/tasks/deploy_coreos_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
--connect qemu:///system \
--name={{ hostvars[kubeinit_deployment_node_name].guest_name }} \
--memory memory={{ hostvars[kubeinit_deployment_node_name].ram|int // 1024 }} \
--cpuset=auto \
--vcpus={{ hostvars[kubeinit_deployment_node_name].vcpus }},maxvcpus={{ hostvars[kubeinit_deployment_node_name].maxvcpus }} \
--os-type=linux \
--os-variant=fedora29 \
--autostart \
--network network={{ kubeinit_cluster_hostvars.network_name }},mac={{ hostvars[kubeinit_deployment_node_name].mac }},virtualport.parameters.interfaceid={{ hostvars[kubeinit_deployment_node_name].interfaceid }},target.dev=veth0-{{ hostvars[kubeinit_deployment_node_name].ansible_host | ansible.utils.ip4_hex }},model=virtio \
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_libvirt/tasks/deploy_debian_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
--connect qemu:///system \
--name={{ hostvars[kubeinit_deployment_node_name].guest_name }} \
--memory memory={{ hostvars[kubeinit_deployment_node_name].ram|int // 1024 }} \
--cpuset=auto \
--vcpus={{ hostvars[kubeinit_deployment_node_name].vcpus }},maxvcpus={{ hostvars[kubeinit_deployment_node_name].maxvcpus }} \
--os-type=linux \
--os-variant=ubuntu18.04 \
--autostart \
--network network={{ kubeinit_cluster_hostvars.network_name }},mac={{ hostvars[kubeinit_deployment_node_name].mac }},virtualport.parameters.interfaceid={{ hostvars[kubeinit_deployment_node_name].interfaceid }},target.dev=veth0-{{ hostvars[kubeinit_deployment_node_name].ansible_host | ansible.utils.ip4_hex }},model=virtio \
Expand Down
2 changes: 0 additions & 2 deletions kubeinit/roles/kubeinit_libvirt/tasks/deploy_ubuntu_guest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
--connect qemu:///system \
--name={{ hostvars[kubeinit_deployment_node_name].guest_name }} \
--memory memory={{ hostvars[kubeinit_deployment_node_name].ram|int // 1024 }} \
--cpuset=auto \
--vcpus={{ hostvars[kubeinit_deployment_node_name].vcpus }},maxvcpus={{ hostvars[kubeinit_deployment_node_name].maxvcpus }} \
--os-type=linux \
--os-variant=ubuntu18.04 \
--autostart \
--network network={{ kubeinit_cluster_hostvars.network_name }},mac={{ hostvars[kubeinit_deployment_node_name].mac }},virtualport.parameters.interfaceid={{ hostvars[kubeinit_deployment_node_name].interfaceid }},target.dev=veth0-{{ hostvars[kubeinit_deployment_node_name].ansible_host | ansible.utils.ip4_hex }},model=virtio \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,12 @@
virt-install \
--name={{ hostvars[kubeinit_deployment_node_name].guest_name }} \
--memory memory={{ hostvars[kubeinit_deployment_node_name].ram|int // 1024 }} \
--cpuset=auto \
--vcpus={{ hostvars[kubeinit_deployment_node_name].vcpus }},maxvcpus={{ hostvars[kubeinit_deployment_node_name].maxvcpus }} \
--network network={{ kubeinit_cluster_hostvars.network_name }},mac={{ hostvars[kubeinit_deployment_node_name].mac }},virtualport.parameters.interfaceid={{ hostvars[kubeinit_deployment_node_name].interfaceid }},target.dev=veth0-{{ hostvars[kubeinit_deployment_node_name].ansible_host | ansible.utils.ip4_hex }},model=virtio \
--disk path={{ kubeinit_libvirt_target_image_dir }}/{{ hostvars[kubeinit_deployment_node_name].guest_name }}.qcow2,format=qcow2,bus=virtio \
--cdrom {{ kubeinit_libvirt_target_image_dir }}/SERVER_EVAL_x64FRE_en-us.iso \
--disk path={{ kubeinit_libvirt_target_image_dir }}/{{ kubeinit_libvirt_virtio_image_name }},device=cdrom \
--disk path={{ kubeinit_libvirt_target_image_dir }}/{{ hostvars[kubeinit_deployment_node_name].guest_name }}_config.iso,device=cdrom \
--os-type windows \
--os-variant win2k8 \
--vnc \
--autostart \
Expand Down

0 comments on commit 8c121dd

Please sign in to comment.