install-kubernetes: add support for cri-o runtime

This adds optional support for using the cri-o rather than the
(still default) docker runtime.

Change-Id: I0f7cbb758a21cb022ceac24654183138bebf83bf
This commit is contained in:
James E. Blair 2019-10-14 14:45:26 -07:00
parent 6d5826844a
commit 03e42f874b
8 changed files with 78 additions and 10 deletions

View File

@ -17,3 +17,9 @@ An ansible role to install kubernetes.
List of dns resolvers to configure in k8s. Use this to override the List of dns resolvers to configure in k8s. Use this to override the
resolvers that are found by default. resolvers that are found by default.
.. zuul:rolevar:: kubernetes_runtime
:default: docker
Which kubernetes runtime to use; values are ``docker`` or
``cri-o``.

View File

@ -1,3 +1,4 @@
install_kubernetes_with_cluster: True install_kubernetes_with_cluster: True
minikube_version: latest minikube_version: latest
minikube_dns_resolvers: [] minikube_dns_resolvers: []
kubernetes_runtime: docker

View File

@ -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

View File

@ -14,6 +14,10 @@
include_role: include_role:
name: install-docker name: install-docker
- name: Install crio
when: kubernetes_runtime == 'cri-o'
include_tasks: crio.yaml
- name: Create .kube directory - name: Create .kube directory
file: file:
path: "{{ ansible_user_dir }}/.kube" path: "{{ ansible_user_dir }}/.kube"
@ -50,7 +54,7 @@
- name: Start Minikube - name: Start Minikube
become: yes 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: environment:
MINIKUBE_WANTUPDATENOTIFICATION: false MINIKUBE_WANTUPDATENOTIFICATION: false
MINIKUBE_WANTREPORTERRORPROMPT: false MINIKUBE_WANTREPORTERRORPROMPT: false

View File

@ -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

View File

@ -1,4 +1,4 @@
- hosts: primary - hosts: all
name: Install kubernetes with minikube name: Install kubernetes with minikube
roles: roles:
- role: install-kubernetes - role: install-kubernetes

View File

@ -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 }}"

View File

@ -26,9 +26,9 @@
label: ubuntu-bionic label: ubuntu-bionic
- job: - job:
name: zuul-jobs-test-install-kubernetes name: zuul-jobs-test-install-kubernetes-docker
description: | description: |
Test the install-kubernetes role Test the install-kubernetes role with docker
This job tests changes to the install-kubernetes roles. It This job tests changes to the install-kubernetes roles. It
is not meant to be used directly but rather run on changes to is not meant to be used directly but rather run on changes to
@ -37,11 +37,23 @@
- roles/install-docker/.* - roles/install-docker/.*
- roles/install-kubernetes/.* - roles/install-kubernetes/.*
- test-playbooks/install-kubernetes.yaml - test-playbooks/install-kubernetes.yaml
run: test-playbooks/install-kubernetes.yaml run: test-playbooks/install-kubernetes/docker.yaml
nodeset: post-run: test-playbooks/install-kubernetes/post.yaml
nodes:
- name: primary - job:
label: ubuntu-bionic 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. # List all the jobs in this file.
@ -49,6 +61,7 @@
check: check:
jobs: &id001 jobs: &id001
- zuul-jobs-test-registry - zuul-jobs-test-registry
- zuul-jobs-test-install-kubernetes - zuul-jobs-test-install-kubernetes-docker
- zuul-jobs-test-install-kubernetes-crio
gate: gate:
jobs: *id001 jobs: *id001