nodepool-builder: deploy from container

This deploys the nodepool-builder container and verifies it has
started in testinfra.

Change-Id: I8a717d06f1291a4112b2753641ff88f074cf0b31
This commit is contained in:
Ian Wienand 2020-03-03 12:30:20 +11:00
parent b2b0cc1c83
commit 1979d6b160
9 changed files with 98 additions and 3 deletions

View File

@ -849,6 +849,7 @@
- playbooks/group_vars/nodepool-builder.yaml - playbooks/group_vars/nodepool-builder.yaml
- playbooks/group_vars/nodepool-launcher.yaml - playbooks/group_vars/nodepool-launcher.yaml
- playbooks/roles/configure-openstacksdk/ - playbooks/roles/configure-openstacksdk/
- playbooks/roles/nodepool.*
- playbooks/templates/clouds/ - playbooks/templates/clouds/
- testinfra/test_nodepool.py - testinfra/test_nodepool.py

View File

@ -1 +1,6 @@
nodepool_base_install_zookeeper: False nodepool_base_install_zookeeper: False
# Keep these in sync with the container uid's so containers can write
# to local bits and pieces.
nodepool_base_nodepool_uid: 10001
nodepool_base_nodepool_gid: 10001

View File

@ -2,6 +2,7 @@
group: group:
name: nodepool name: nodepool
state: present state: present
gid: '{{ nodepool_base_nodepool_gid }}'
- name: Add the nodepool user - name: Add the nodepool user
user: user:
@ -10,6 +11,7 @@
home: /home/nodepool home: /home/nodepool
create_home: yes create_home: yes
shell: /bin/bash shell: /bin/bash
uid: '{{ nodepool_base_nodepool_uid }}'
- name: Install zookeeper - name: Install zookeeper
include_role: include_role:

View File

@ -0,0 +1,8 @@
Deploy nodepool-builder container
**Role Variables**
.. zuul:rolevar:: nodepool_builder_container_tag
:default: unset
Override tag for container deployment

View File

@ -0,0 +1,37 @@
- name: Ensure dib directories
file:
state: directory
path: '{{ item }}'
mode: 0755
owner: nodepool
group: nodepool
loop:
- '/opt/dib_tmp'
- '/opt/nodepool_dib'
- '/var/log/nodepool/builds'
- name: Ensure /etc/nodepool-builder-compose directory
file:
state: directory
path: /etc/nodepool-builder-compose
mode: 0755
- name: Put docker-compose file in place
template:
src: docker-compose.yaml.j2
dest: /etc/nodepool-builder-compose/docker-compose.yaml
mode: 0644
- name: Install podman-compose
pip:
name: podman-compose
state: latest
# NOTE(mordred) Cannot use full path to pip3 here because it is
# different on zuul test nodes and in production. This is, of
# course, not stellar.
executable: pip3
- name: Run podman-compose up
shell:
cmd: podman-compose up -d
chdir: /etc/nodepool-builder-compose/

View File

@ -0,0 +1,28 @@
version: '3.0'
services:
nodepool-builder:
image: docker.io/zuul/nodepool-builder:{{ nodepool_builder_container_tag|default('latest') }}
user: nodepool
network_mode: host
restart: always
privileged: true
environment:
- DEBUG=1
volumes:
# NOTE(ianw): for non-containerised builds the base roles
# (configure-openstacksdk) have always deployed the cloud config
# in ~nodepool/.config.
- /home/nodepool/.config/openstack:/etc/openstack:ro
# nodepool config
- /etc/nodepool:/etc/nodepool:ro
# project-config
- /opt/project-config:/opt/project-config:ro
# dib temporary storage; see config in project-config
- /opt/dib_tmp:/opt/dib_tmp:rw
# dib image output; see config in project-config
- /opt/nodepool_dib:/opt/nodepool_dib:rw
# logs (builder + dib build logs under /build)
- /var/log/nodepool:/var/log/nodepool:rw

View File

@ -10,8 +10,12 @@
name: "Configure nodepool builders" name: "Configure nodepool builders"
strategy: free strategy: free
roles: roles:
- pip3
- install-podman
- nodepool-base - nodepool-base
- configure-openstacksdk - configure-openstacksdk
- nodepool-builder
# TODO(ianw) 2020-03-03 : watch this space... # TODO(ianw) 2020-03-03 : watch this space...
#- hosts: nodepool-launcher_opendev:!disabled #- hosts: nodepool-launcher_opendev:!disabled

View File

@ -12,8 +12,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pytest
testinfra_hosts = ['nl01.openstack.org', 'nb01.openstack.org'] testinfra_hosts = ['nl01.openstack.org', 'nb01.openstack.org',
'nb01-test.opendev.org']
def test_clouds_yaml(host): def test_clouds_yaml(host):
@ -22,9 +24,17 @@ def test_clouds_yaml(host):
assert b'password' in clouds_yaml.content assert b'password' in clouds_yaml.content
def test_kube_config(host): def test_kube_config(host):
if not host.backend.get_hostname().endswith('openstack.org'):
pytest.skip()
kubeconfig = host.file('/home/nodepool/.kube/config') kubeconfig = host.file('/home/nodepool/.kube/config')
assert kubeconfig.exists assert kubeconfig.exists
assert b'nodepool_k8s_key' in kubeconfig.content assert b'nodepool_k8s_key' in kubeconfig.content
def test_builder_container_running(host):
if host.backend.get_hostname() != 'nb01-test.opendev.org':
pytest.skip()
cmd = host.run("podman ps -a --format '{{ .Names }}'")
assert 'nodepool-builder-compose_nodepool-builder_1' in cmd.stdout