From 3840feb51824edb2892b55bb0fe4fedc7a1c3d2f Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Wed, 18 Nov 2020 14:51:02 +0100 Subject: [PATCH] capi: make containerd cri socket configurable We should be able to configure path to containerd CRI socket file, `containerd_cri_socket`, for each distro. Its main use case is to support distros with different CRI socket path, for example, `/run/docker/libcontainerd/container.sock` for Flatcar. By default it is `/var/run/containerd/containerd.sock` as it has been in all other distros. This PR is split out from https://github.com/kubernetes-sigs/image-builder/pull/248, as suggested by @codenrhoden. --- images/capi/ansible/roles/containerd/templates/etc/crictl.yaml | 1 + images/capi/ansible/roles/kubernetes/tasks/kubeadmpull.yml | 2 +- images/capi/ansible/roles/kubernetes/tasks/url.yml | 2 +- images/capi/ansible/roles/kubernetes/templates/etc/kubeadm.yml | 2 +- images/capi/packer/ami/packer.json | 1 + images/capi/packer/azure/packer.json | 1 + images/capi/packer/config/ansible-args.json | 2 +- images/capi/packer/digitalocean/packer.json | 1 + images/capi/packer/gce/packer.json | 1 + images/capi/packer/ova/packer-node.json | 1 + images/capi/packer/qemu/packer.json | 1 + 11 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 images/capi/ansible/roles/containerd/templates/etc/crictl.yaml diff --git a/images/capi/ansible/roles/containerd/templates/etc/crictl.yaml b/images/capi/ansible/roles/containerd/templates/etc/crictl.yaml new file mode 100644 index 0000000000..0c2b3fd536 --- /dev/null +++ b/images/capi/ansible/roles/containerd/templates/etc/crictl.yaml @@ -0,0 +1 @@ +runtime-endpoint: unix://{{ containerd_cri_socket }} diff --git a/images/capi/ansible/roles/kubernetes/tasks/kubeadmpull.yml b/images/capi/ansible/roles/kubernetes/tasks/kubeadmpull.yml index 2fe2c92010..a465aba564 100644 --- a/images/capi/ansible/roles/kubernetes/tasks/kubeadmpull.yml +++ b/images/capi/ansible/roles/kubernetes/tasks/kubeadmpull.yml @@ -5,7 +5,7 @@ mode: 0600 - name: Kubeadm pull images - shell: 'kubeadm config images pull --config /etc/kubeadm.yml' + shell: 'kubeadm config images pull --config /etc/kubeadm.yml --cri-socket {{ containerd_cri_socket }}' - name: delete kubeadm config file: diff --git a/images/capi/ansible/roles/kubernetes/tasks/url.yml b/images/capi/ansible/roles/kubernetes/tasks/url.yml index 841ab2f263..b7f6455665 100644 --- a/images/capi/ansible/roles/kubernetes/tasks/url.yml +++ b/images/capi/ansible/roles/kubernetes/tasks/url.yml @@ -77,7 +77,7 @@ loop: "{{ kubernetes_imgs }}" - name: Load Kubernetes images - shell: 'CONTAINERD_NAMESPACE="k8s.io" ctr images import /tmp/{{ item }}' + shell: 'CONTAINERD_NAMESPACE="k8s.io" ctr --address={{ containerd_cri_socket }} images import /tmp/{{ item }}' loop: "{{ kubernetes_imgs }}" - name: Remove Kubernetes images diff --git a/images/capi/ansible/roles/kubernetes/templates/etc/kubeadm.yml b/images/capi/ansible/roles/kubernetes/templates/etc/kubeadm.yml index 705c86befa..ed83b561a1 100644 --- a/images/capi/ansible/roles/kubernetes/templates/etc/kubeadm.yml +++ b/images/capi/ansible/roles/kubernetes/templates/etc/kubeadm.yml @@ -6,4 +6,4 @@ kubernetesVersion: {{ kubernetes_semver }} apiVersion: kubeadm.k8s.io/v1beta1 kind: InitConfiguration nodeRegistration: - criSocket: "/var/run/containerd/containerd.sock" \ No newline at end of file + criSocket: {{ containerd_cri_socket }} diff --git a/images/capi/packer/ami/packer.json b/images/capi/packer/ami/packer.json index 018b260a4d..e5fa3671da 100644 --- a/images/capi/packer/ami/packer.json +++ b/images/capi/packer/ami/packer.json @@ -13,6 +13,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "build_timestamp": "{{timestamp}}", diff --git a/images/capi/packer/azure/packer.json b/images/capi/packer/azure/packer.json index d85a0315d7..662c3323f5 100644 --- a/images/capi/packer/azure/packer.json +++ b/images/capi/packer/azure/packer.json @@ -10,6 +10,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "distribution": null, diff --git a/images/capi/packer/config/ansible-args.json b/images/capi/packer/config/ansible-args.json index a89be5c5f9..580d4fd331 100644 --- a/images/capi/packer/config/ansible-args.json +++ b/images/capi/packer/config/ansible-args.json @@ -1,3 +1,3 @@ { - "ansible_common_vars": "containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256`}} containerd_pause_image={{user `containerd_pause_image`}} containerd_additional_settings={{user `containerd_additional_settings`}} crictl_url={{user `crictl_url`}} crictl_sha256={{user `crictl_sha256`}} crictl_source_type={{user `crictl_source_type`}} custom_role={{user `custom_role`}} custom_role_names={{user `custom_role_names`}} disable_public_repos={{user `disable_public_repos`}} extra_debs={{user `extra_debs`}} extra_repos={{user `extra_repos`}} extra_rpms={{user `extra_rpms`}} http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} kubeadm_template={{user `kubeadm_template`}} kubernetes_cni_http_source={{user `kubernetes_cni_http_source`}} kubernetes_cni_http_checksum={{user `kubernetes_cni_http_checksum`}} kubernetes_http_source={{user `kubernetes_http_source`}} kubernetes_container_registry={{user `kubernetes_container_registry`}} kubernetes_rpm_repo={{user `kubernetes_rpm_repo`}} kubernetes_rpm_gpg_key={{user `kubernetes_rpm_gpg_key`}} kubernetes_rpm_gpg_check={{user `kubernetes_rpm_gpg_check`}} kubernetes_deb_repo={{user `kubernetes_deb_repo`}} kubernetes_deb_gpg_key={{user `kubernetes_deb_gpg_key`}} kubernetes_cni_deb_version={{user `kubernetes_cni_deb_version`}} kubernetes_cni_rpm_version={{user `kubernetes_cni_rpm_version`}} kubernetes_cni_semver={{user `kubernetes_cni_semver`}} kubernetes_cni_source_type={{user `kubernetes_cni_source_type`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_source_type={{user `kubernetes_source_type`}} kubernetes_load_additional_imgs={{user `kubernetes_load_additional_imgs`}} kubernetes_deb_version={{user `kubernetes_deb_version`}} kubernetes_rpm_version={{user `kubernetes_rpm_version`}} no_proxy={{user `no_proxy`}} redhat_epel_rpm={{user `redhat_epel_rpm`}} reenable_public_repos={{user `reenable_public_repos`}} remove_extra_repos={{user `remove_extra_repos`}} " + "ansible_common_vars": "containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256`}} containerd_pause_image={{user `containerd_pause_image`}} containerd_additional_settings={{user `containerd_additional_settings`}} containerd_cri_socket={{user `containerd_cri_socket`}} crictl_url={{user `crictl_url`}} crictl_sha256={{user `crictl_sha256`}} crictl_source_type={{user `crictl_source_type`}} custom_role={{user `custom_role`}} custom_role_names={{user `custom_role_names`}} disable_public_repos={{user `disable_public_repos`}} extra_debs={{user `extra_debs`}} extra_repos={{user `extra_repos`}} extra_rpms={{user `extra_rpms`}} http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} kubeadm_template={{user `kubeadm_template`}} kubernetes_cni_http_source={{user `kubernetes_cni_http_source`}} kubernetes_cni_http_checksum={{user `kubernetes_cni_http_checksum`}} kubernetes_http_source={{user `kubernetes_http_source`}} kubernetes_container_registry={{user `kubernetes_container_registry`}} kubernetes_rpm_repo={{user `kubernetes_rpm_repo`}} kubernetes_rpm_gpg_key={{user `kubernetes_rpm_gpg_key`}} kubernetes_rpm_gpg_check={{user `kubernetes_rpm_gpg_check`}} kubernetes_deb_repo={{user `kubernetes_deb_repo`}} kubernetes_deb_gpg_key={{user `kubernetes_deb_gpg_key`}} kubernetes_cni_deb_version={{user `kubernetes_cni_deb_version`}} kubernetes_cni_rpm_version={{user `kubernetes_cni_rpm_version`}} kubernetes_cni_semver={{user `kubernetes_cni_semver`}} kubernetes_cni_source_type={{user `kubernetes_cni_source_type`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_source_type={{user `kubernetes_source_type`}} kubernetes_load_additional_imgs={{user `kubernetes_load_additional_imgs`}} kubernetes_deb_version={{user `kubernetes_deb_version`}} kubernetes_rpm_version={{user `kubernetes_rpm_version`}} no_proxy={{user `no_proxy`}} redhat_epel_rpm={{user `redhat_epel_rpm`}} reenable_public_repos={{user `reenable_public_repos`}} remove_extra_repos={{user `remove_extra_repos`}} " } diff --git a/images/capi/packer/digitalocean/packer.json b/images/capi/packer/digitalocean/packer.json index c3377f9145..88338c16c1 100644 --- a/images/capi/packer/digitalocean/packer.json +++ b/images/capi/packer/digitalocean/packer.json @@ -9,6 +9,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "kubernetes_cni_rpm_version": null, diff --git a/images/capi/packer/gce/packer.json b/images/capi/packer/gce/packer.json index 0acec0d3b7..b16ede4fa5 100644 --- a/images/capi/packer/gce/packer.json +++ b/images/capi/packer/gce/packer.json @@ -11,6 +11,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "kubernetes_cni_rpm_version": null, diff --git a/images/capi/packer/ova/packer-node.json b/images/capi/packer/ova/packer-node.json index 7db086e958..8e09af338a 100644 --- a/images/capi/packer/ova/packer-node.json +++ b/images/capi/packer/ova/packer-node.json @@ -9,6 +9,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "datastore": "", diff --git a/images/capi/packer/qemu/packer.json b/images/capi/packer/qemu/packer.json index 47eb3e4833..2d8718a6cb 100644 --- a/images/capi/packer/qemu/packer.json +++ b/images/capi/packer/qemu/packer.json @@ -7,6 +7,7 @@ "containerd_version": null, "containerd_sha256": null, "containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz", + "containerd_cri_socket": "/var/run/containerd/containerd.sock", "crictl_version": null, "crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz", "existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",