diff --git a/roles/install-kubernetes/README.rst b/roles/install-kubernetes/README.rst index b5567959e..aaf75a16d 100644 --- a/roles/install-kubernetes/README.rst +++ b/roles/install-kubernetes/README.rst @@ -17,3 +17,9 @@ An ansible role to install kubernetes. List of dns resolvers to configure in k8s. Use this to override the resolvers that are found by default. + +.. zuul:rolevar:: kubernetes_runtime + :default: docker + + Which kubernetes runtime to use; values are ``docker`` or + ``cri-o``. diff --git a/roles/install-kubernetes/defaults/main.yaml b/roles/install-kubernetes/defaults/main.yaml index 158b030e1..d9cc6f4fb 100644 --- a/roles/install-kubernetes/defaults/main.yaml +++ b/roles/install-kubernetes/defaults/main.yaml @@ -1,3 +1,4 @@ install_kubernetes_with_cluster: True minikube_version: latest minikube_dns_resolvers: [] +kubernetes_runtime: docker diff --git a/roles/install-kubernetes/tasks/crio.yaml b/roles/install-kubernetes/tasks/crio.yaml new file mode 100644 index 000000000..3a5482fb3 --- /dev/null +++ b/roles/install-kubernetes/tasks/crio.yaml @@ -0,0 +1,28 @@ +- name: Add project atomic PPA + apt_repository: + repo: ppa:projectatomic/ppa + become: true +- name: Install packages + package: + name: + - cri-o-1.15 + - containernetworking-plugins + - podman + - cri-tools + state: present + become: true +- name: Fix conmon symlink + file: + src: /usr/bin/conmon + dest: /usr/libexec/crio/conmon + owner: root + group: root + state: link + become: true +- name: Set crio cgroup driver + ini_file: + path: /etc/crio/crio.conf + section: crio.runtime + option: cgroup_manager + value: '"cgroupfs"' + become: true diff --git a/roles/install-kubernetes/tasks/minikube.yaml b/roles/install-kubernetes/tasks/minikube.yaml index 4ace01322..d025ad3f1 100644 --- a/roles/install-kubernetes/tasks/minikube.yaml +++ b/roles/install-kubernetes/tasks/minikube.yaml @@ -14,6 +14,10 @@ include_role: name: install-docker +- name: Install crio + when: kubernetes_runtime == 'cri-o' + include_tasks: crio.yaml + - name: Create .kube directory file: path: "{{ ansible_user_dir }}/.kube" @@ -50,7 +54,7 @@ - name: Start Minikube become: yes - command: "/tmp/minikube --vm-driver=none start {{ minikube_args }}" + command: "/tmp/minikube --vm-driver=none --container-runtime={{ kubernetes_runtime }} {{ minikube_args }} start" environment: MINIKUBE_WANTUPDATENOTIFICATION: false MINIKUBE_WANTREPORTERRORPROMPT: false diff --git a/test-playbooks/install-kubernetes/crio.yaml b/test-playbooks/install-kubernetes/crio.yaml new file mode 100644 index 000000000..f0ffc531e --- /dev/null +++ b/test-playbooks/install-kubernetes/crio.yaml @@ -0,0 +1,9 @@ +- hosts: all + name: Install kubernetes with minikube + roles: + - role: install-kubernetes + vars: + minikube_dns_resolvers: + - '1.1.1.1' + - '8.8.8.8' + kubernetes_runtime: cri-o diff --git a/test-playbooks/install-kubernetes.yaml b/test-playbooks/install-kubernetes/docker.yaml similarity index 90% rename from test-playbooks/install-kubernetes.yaml rename to test-playbooks/install-kubernetes/docker.yaml index a348350a2..0d0cc21fe 100644 --- a/test-playbooks/install-kubernetes.yaml +++ b/test-playbooks/install-kubernetes/docker.yaml @@ -1,4 +1,4 @@ -- hosts: primary +- hosts: all name: Install kubernetes with minikube roles: - role: install-kubernetes diff --git a/test-playbooks/install-kubernetes/post.yaml b/test-playbooks/install-kubernetes/post.yaml new file mode 100644 index 000000000..634870291 --- /dev/null +++ b/test-playbooks/install-kubernetes/post.yaml @@ -0,0 +1,7 @@ +- hosts: all + tasks: + - name: Get minikube logs + become: true + shell: "/tmp/minikube logs > {{ ansible_user_dir }}/zuul-output/logs/minikube.txt" + environment: + MINIKUBE_HOME: "{{ ansible_user_dir }}" diff --git a/zuul-tests.d/container-roles-jobs.yaml b/zuul-tests.d/container-roles-jobs.yaml index f47e1252f..a5f6ec06d 100644 --- a/zuul-tests.d/container-roles-jobs.yaml +++ b/zuul-tests.d/container-roles-jobs.yaml @@ -26,9 +26,9 @@ label: ubuntu-bionic - job: - name: zuul-jobs-test-install-kubernetes + name: zuul-jobs-test-install-kubernetes-docker description: | - Test the install-kubernetes role + Test the install-kubernetes role with docker This job tests changes to the install-kubernetes roles. It is not meant to be used directly but rather run on changes to @@ -37,11 +37,23 @@ - roles/install-docker/.* - roles/install-kubernetes/.* - test-playbooks/install-kubernetes.yaml - run: test-playbooks/install-kubernetes.yaml - nodeset: - nodes: - - name: primary - label: ubuntu-bionic + run: test-playbooks/install-kubernetes/docker.yaml + post-run: test-playbooks/install-kubernetes/post.yaml + +- job: + name: zuul-jobs-test-install-kubernetes-crio + description: | + Test the install-kubernetes role with crio-o + + This job tests changes to the install-kubernetes roles. It + is not meant to be used directly but rather run on changes to + roles in the zuul-jobs repo. + files: + - roles/install-docker/.* + - roles/install-kubernetes/.* + - test-playbooks/install-kubernetes.yaml + run: test-playbooks/install-kubernetes/crio.yaml + post-run: test-playbooks/install-kubernetes/post.yaml # List all the jobs in this file. @@ -49,6 +61,7 @@ check: jobs: &id001 - zuul-jobs-test-registry - - zuul-jobs-test-install-kubernetes + - zuul-jobs-test-install-kubernetes-docker + - zuul-jobs-test-install-kubernetes-crio gate: jobs: *id001