Add nodepool kubernetes pod label to integration test

This change enables using real kubernetes pod label
for the integration tests.

Depends-On: https://review.opendev.org/715308
Change-Id: I24448bf1edb6c546475796a06cf8cbe456716c32
This commit is contained in:
Tristan Cacqueray 2020-03-26 21:24:52 +00:00
parent 28ea866426
commit af310512cd
3 changed files with 53 additions and 29 deletions

View File

@ -16,6 +16,29 @@
command: cat id_rsa
register: _ssh_key
- name: Read generated kubectl configuration
command: |
sed -e 's#/home/zuul/.minikube/profiles/minikube/#/etc/nodepool-kubernetes/#g'
-e 's#/home/zuul/.minikube/#/etc/nodepool-kubernetes/#g'
~/.kube/config
register: _kube_config
- name: Read client cert
command: cat ~/.minikube/profiles/minikube/client.crt
register: _kube_cert
- name: Read client key
command: cat ~/.minikube/profiles/minikube/client.key
register: _kube_key
- name: Read ca cert
command: cat ~/.minikube/ca.crt
register: _kube_ca
- name: Read current context name
command: kubectl config current-context
register: _kube_context
- name: Setup user provided secrets
k8s:
namespace: "{{ namespace }}"
@ -46,42 +69,27 @@
data:
nodepool.yaml: |
labels:
- name: pod-centos
- name: pod-fedora-31
min-ready: 1
providers:
- name: kube-cluster
driver: openshiftpods
context: local
driver: kubernetes
context: {{ _kube_context.stdout }}
max-pods: 15
pools:
- name: default
labels:
- name: pod-centos
image: quay.io/software-factory/pod-centos-7
python-path: /bin/python2
- name: pod-fedora-31
type: pod
image: docker.io/fedora:31
python-path: /bin/python3
- name: nodepool-kube-config
data:
kube.config: |
apiVersion: v1
kind: Config
preferences: {}
clusters:
- cluster:
server: https://10.43.0.1:8043
insecure-skip-tls-verify: true
name: local
users:
- name: nodepool
user:
token: test-token
contexts:
- context:
cluster: local
user: nodepool
namespace: default
name: local
current-context: local
kube.config: "{{ _kube_config.stdout }}"
client.crt: "{{ _kube_cert.stdout }}"
client.key: "{{ _kube_key.stdout }}"
ca.crt: "{{ _kube_ca.stdout }}"
- name: Deploy CR
include_tasks: tasks/apply_cr.yaml

View File

@ -24,13 +24,19 @@
sql:
- nodeset:
name: localhost
nodes: []
name: pod-fedora
nodes:
- name: container
label: pod-fedora-31
- job:
name: test-job
run: test.yaml
nodeset: localhost
# skip zuul-base-jobs for now as it doesn't work with kubectl
roles:
- zuul: zuul/zuul-jobs
parent: null
nodeset: pod-fedora
- project:
periodic:
@ -41,6 +47,8 @@
content: |
- hosts: localhost
tasks:
- include_role:
name: start-zuul-console
- debug: msg='Demo job is running'
- pause: seconds=30

View File

@ -84,6 +84,10 @@
name: opendev.org
- baseurl: "git://{{ ansible_all_ipv4_addresses[0] }}/"
name: local-git
external_config:
kubernetes:
secretName: nodepool-kube-config
key: kube.config
- name: ensure a job is running
when: skip_check is not defined
@ -110,6 +114,10 @@
shell: |
curl -s {{ zuul_web_url }}/api/tenant/local/status | jq -r '.pipelines[].change_queues[].heads[][].jobs[].uuid'
register: _job_uuid
# Wait until the executor start the job
until: _job_uuid.stdout != "" and _job_uuid.stdout != "null"
retries: 60
delay: 1
- name: connect to console-stream
command: |