Browse Source

Add Kubernetes job

Change-Id: I2c75c81521ed8a53627119b231f526508154e34d
changes/25/665525/12
Hongbin Lu 2 years ago
parent
commit
735bde961d
7 changed files with 97 additions and 0 deletions
  1. +37
    -0
      .zuul.yaml
  2. +1
    -0
      devstack/settings
  3. +4
    -0
      playbooks/devstack-plugin-container-k8s/post.yaml
  4. +3
    -0
      playbooks/devstack-plugin-container-k8s/pre.yaml
  5. +29
    -0
      playbooks/devstack-plugin-container-k8s/run.yaml
  6. +1
    -0
      roles/fetch_kubelet_log/README.rst
  7. +22
    -0
      roles/fetch_kubelet_log/tasks/main.yaml

+ 37
- 0
.zuul.yaml View File

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

+ 1
- 0
devstack/settings View File

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


+ 4
- 0
playbooks/devstack-plugin-container-k8s/post.yaml View File

@ -0,0 +1,4 @@
- hosts: all
roles:
- fetch_docker_log
- fetch_kubelet_log

+ 3
- 0
playbooks/devstack-plugin-container-k8s/pre.yaml View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- orchestrate-devstack

+ 29
- 0
playbooks/devstack-plugin-container-k8s/run.yaml View File

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

+ 1
- 0
roles/fetch_kubelet_log/README.rst View File

@ -0,0 +1 @@
Collect kubelet log from test run

+ 22
- 0
roles/fetch_kubelet_log/tasks/main.yaml View File

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

Loading…
Cancel
Save