diff --git a/.zuul.yaml b/.zuul.yaml index 0158d9b..c8c9e97 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -15,10 +15,47 @@ devstack_plugins: devstack-plugin-container: https://opendev.org/openstack/devstack-plugin-container +- job: + name: devstack-plugin-container-k8s + parent: devstack-minimal + nodeset: openstack-two-node-bionic + pre-run: playbooks/devstack-plugin-container-k8s/pre.yaml + run: playbooks/devstack-plugin-container-k8s/run.yaml + post-run: playbooks/devstack-plugin-container-k8s/post.yaml + timeout: 7200 + required-projects: + - openstack/devstack + - openstack/devstack-gate + - openstack/devstack-plugin-container + vars: + devstack_services: + # Ignore any default set by devstack. Emit a "disable_all_services". + base: false + etcd3: true + container: true + k8s-master: true + devstack_localrc: + K8S_TOKEN: "9agf12.zsu5uh2m4pzt3qba" + USE_PYTHON3: true + devstack_plugins: + devstack-plugin-container: https://opendev.org/openstack/devstack-plugin-container + group-vars: + subnode: + devstack_services: + # Ignore any default set by devstack. Emit a "disable_all_services". + base: false + container: true + k8s-node: true + devstack_localrc: + K8S_TOKEN: "9agf12.zsu5uh2m4pzt3qba" + USE_PYTHON3: true + - project: check: jobs: - devstack-plugin-container-dsvm + - devstack-plugin-container-k8s: + voting: false gate: jobs: - devstack-plugin-container-dsvm diff --git a/devstack/settings b/devstack/settings index c9ddcdd..876eb1f 100644 --- a/devstack/settings +++ b/devstack/settings @@ -5,6 +5,7 @@ CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} ENABLE_CLEAR_CONTAINER=${ENABLE_CLEAR_CONTAINER:-false} ENABLE_LIVE_RESTORE=${ENABLE_LIVE_RESTORE:-false} ENABLE_IPV6=${ENABLE_IPV6:-false} +K8S_NETWORK_ADDON=${K8S_NETWORK_ADDON:-flannel} # Enable container services enable_service container diff --git a/playbooks/devstack-plugin-container-k8s/post.yaml b/playbooks/devstack-plugin-container-k8s/post.yaml new file mode 100644 index 0000000..2809c6f --- /dev/null +++ b/playbooks/devstack-plugin-container-k8s/post.yaml @@ -0,0 +1,4 @@ +- hosts: all + roles: + - fetch_docker_log + - fetch_kubelet_log diff --git a/playbooks/devstack-plugin-container-k8s/pre.yaml b/playbooks/devstack-plugin-container-k8s/pre.yaml new file mode 100644 index 0000000..93d19f1 --- /dev/null +++ b/playbooks/devstack-plugin-container-k8s/pre.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - orchestrate-devstack diff --git a/playbooks/devstack-plugin-container-k8s/run.yaml b/playbooks/devstack-plugin-container-k8s/run.yaml new file mode 100644 index 0000000..18b22db --- /dev/null +++ b/playbooks/devstack-plugin-container-k8s/run.yaml @@ -0,0 +1,29 @@ +- hosts: controller + name: Verify that k8s is installed correctly by running a pod + tasks: + - shell: + cmd: | + set -e + set -x + + kubectl get nodes + kubectl get pods --namespace kube-system + + tmpfile=$(mktemp) + cat < $tmpfile + apiVersion: v1 + kind: Pod + metadata: + name: myapp-pod + labels: + app: myapp + spec: + containers: + - name: myapp-container + image: busybox + command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600'] + EOT + kubectl create -f $tmpfile + kubectl wait --for=condition=Ready pod myapp-pod + become: true + become_user: stack diff --git a/roles/fetch_kubelet_log/README.rst b/roles/fetch_kubelet_log/README.rst new file mode 100644 index 0000000..e40d28b --- /dev/null +++ b/roles/fetch_kubelet_log/README.rst @@ -0,0 +1 @@ +Collect kubelet log from test run diff --git a/roles/fetch_kubelet_log/tasks/main.yaml b/roles/fetch_kubelet_log/tasks/main.yaml new file mode 100644 index 0000000..a279035 --- /dev/null +++ b/roles/fetch_kubelet_log/tasks/main.yaml @@ -0,0 +1,22 @@ +- name: Ensure log path exists + become: yes + file: + path: "{{ ansible_user_dir }}/logs" + state: directory + owner: "{{ ansible_user }}" + group: "{{ ansible_user }}" + mode: 0775 + +- name: Store kubelet log in {{ ansible_user_dir }}/logs + become: yes + shell: + cmd: | + sudo journalctl -o short-precise --unit kubelet | sudo tee {{ ansible_user_dir }}/logs/kubelet.log > /dev/null + +- name: Set kubelet.log file permissions + become: yes + file: + path: '{{ ansible_user_dir }}/logs/kubelet.log' + owner: '{{ ansible_user }}' + group: '{{ ansible_user }}' + mode: 0644