zuul-jobs/test-playbooks/ensure-kubernetes/post.yaml
Ian Wienand 99678c46e0 ensure-kubernetes: add microk8s support
Add microk8s support to the ensure-kubernetes role.  This installs via
a snap, and is currently only implemented for Ubuntu Jammy.

Mostly this is a straight-forward installation.  I did notice though
it needs a little more time to be stable in the test, so the timeout
is bumped slightly.

microk8s is the Ubuntu "blessed" way of doing things.  This should be
a better choice for Ubuntu platforms, because minikube is tightly tied
to cri-o, which is only packaged through kubic, which is currently in
some sort of deprecated but best-effort supported mode [1].  This was
inspired by an outage where the kubic gpg expired.  This appears fixed
now.

[1] https://kubic.opensuse.org/blog/2022-06-10-kubic-retired/

Change-Id: Id3e31c70a35dde218e35e7c50964f8a3c0348150
2023-01-08 08:05:40 -08:00

60 lines
1.7 KiB
YAML

- hosts: all
name: Post testing
tasks:
- name: Run functionality tests
block:
# The default account is known to take a while to appear; see
# https://github.com/kubernetes/kubernetes/issues/66689
- name: Ensure default account created
command: kubectl -n default get serviceaccount default -o name
retries: 5
delay: 5
register: result
until: result.rc == 0
- name: Create a test pod definition
copy:
dest: test-pod.yaml
content: |
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
restartPolicy: Never
containers:
- name: test
image: k8s.gcr.io/pause:3.1
- name: Start pod
command: kubectl apply -f test-pod.yaml
- name: Wait a bit
pause:
seconds: 30
- name: Describe pod
shell: sleep 5; kubectl describe pods test
- name: Ensure pod is running
shell: sleep 5; kubectl get pods
register: _get_pods_output
until: "'Running' in _get_pods_output.stdout"
retries: 3
delay: 10
always:
- name: Collect container logs
import_role:
name: collect-container-logs
- name: Collect kubernetes logs
import_role:
name: collect-kubernetes-logs
- name: Get minikube logs
become: true
shell: "/tmp/minikube logs > {{ ansible_user_dir }}/zuul-output/logs/minikube.txt || true"
environment:
MINIKUBE_HOME: "{{ ansible_user_dir }}"