zuul-jobs/test-playbooks/ensure-kubernetes/post.yaml
Jan Gutter 83bfd5b917
Update ensure-kubernetes with podman support
* This adds some extra options to the ensure-kubernetes role:
  * podman + cri-o can now be used for testing
  * This mode seems to be slightly more supported than the
    current profiles.
* The location for minikube install can be moved.
* The use-buildset-registry role needed slight updates in order
  to populate the kubernetes registry config early.

Change-Id: Ia578f1e00432eec5d81304f70db649e420786a02
2024-08-22 20:50:39 +01:00

81 lines
2.6 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: registry.k8s.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
shell: "minikube logs > {{ ansible_user_dir }}/zuul-output/logs/minikube.txt"
environment:
MINIKUBE_HOME: "{{ ansible_user_dir }}"
failed_when: false
- name: Get kubelet logs inside podman container
shell: |
set -x
KUBELET_LOG_DIR={{ ansible_user_dir }}/zuul-output/logs/kubelet/
mkdir -p ${KUBELET_LOG_DIR}
JOURNALCTL_CMD="sudo podman exec -it minikube journalctl"
${JOURNALCTL_CMD} -u kubelet.service >> ${KUBELET_LOG_DIR}/kubelet.txt
failed_when: false
- name: Fetch the system cri-o logs
become: true
shell: |
ZUUL_LOG_DIR={{ ansible_user_dir }}/zuul-output/logs
cp /etc/resolv.conf ${ZUUL_LOG_DIR}
mkdir -p ${ZUUL_LOG_DIR}/containerd
cp -r /etc/containers ${ZUUL_LOG_DIR}/containerd
mkdir -p ${ZUUL_LOG_DIR}/cri-o
systemctl status crio > ${ZUUL_LOG_DIR}/cri-o/systemctl-status.txt
journalctl -u crio > ${ZUUL_LOG_DIR}/cri-o/journalctl-u.txt
failed_when: false