Commit Graph

85 Commits

Author SHA1 Message Date
James E. Blair f89b41f6ad Reconcile docs/validation for some options
Some drivers were missing docs and/or validation for options that
they actually support.  This change:

adds launch-timeout to:
  metastatic docs and validation
  aws validation
  gce docs and validation
adds post-upload-hook to:
  aws validation
adds boot-timeout to:
  metastatic docs and validation
adds launch-retries to:
  metastatic docs and validation

Change-Id: Id3f4bb687c1b2c39a1feb926a50c46b23ae9df9a
2024-02-08 09:36:35 -08:00
James E. Blair c78fe769f2 Allow custom k8s pod specs
This change adds the ability to use the k8s (and friends) drivers
to create pods with custom specs.  This will allow nodepool admins
to define labels that create pods with options not otherwise supported
by Nodepool, as well as pods with multiple containers.

This can be used to implement the versatile sidecar pattern, which,
in a system where it is difficult to background a system process (such
as a database server or container runtime) is useful to run jobs with
such requirements.

It is still the case that a single resource is returned to Zuul, so
a single pod will be added to the inventory.  Therefore, the expectation
that it should be possible to shell into the first container in the
pod is documented.

Change-Id: I4a24a953a61239a8a52c9e7a2b68a7ec779f7a3d
2024-01-30 15:59:34 -08:00
James E. Blair 9bf44b4a4c Add scheduler, volumes, and labels to k8s/openshift
This adds support for specifying the scheduler name, volumes (and
volume mounts), and additional metadata labels to the Kubernetes
and OpenShift (and OpenShift pods) drivers.

This also extends the k8s and openshift test frameworks so that we
can exercise the new code paths (as well as some previous similar
settings).  Tests and assertions for both a minimal (mostly defaults)
configuration as well as a configuration that uses all the optional
settings are added.

Change-Id: I648e88a518c311b53c8ee26013a324a5013f3be3
2023-02-11 12:03:45 -08:00
James E. Blair aa8580ce32 Add support for privileged containers
To allow users to run docker-in-docker style workloads on k8s
and openshift clusters, add support for adding the privileged
flag to containers created in k8s and openshift pods.

Change-Id: I349d61bf200d7fb6d1effe112f7505815b06e9a8
2023-01-25 11:09:25 -08:00
Albin Vass 0c84b7fa4e Add shell-type config
Ansible needs to know which shell type the node uses to operate
correctly, especially for ssh connections for windows nodes because
otherwise ansible defaults to trying bash.

Change-Id: I71abfefa57aaafd88f199be19ee7caa64efda538
2021-03-05 15:14:29 +01:00
Zuul e8b9bfe139 Merge "OpenShift/k8s Provider: Basic Support for k8s nodeSelectors" 2020-09-07 12:33:11 +00:00
Zuul 6473a0049c Merge "config: add environment variable substitution" 2020-08-21 20:57:17 +00:00
Benjamin Schanzel 19be1a2e26 OpenShift/k8s Provider: Basic Support for k8s nodeSelectors
This adds support to specify node selectors on Pod node labels.
They are used by the k8s scheduler to place a Pod on specific nodes with
corresponding labels.
This allows to place a build node/Pod on k8s nodes with certain
capabilities (e.g. storage types, number of CPU cores, etc.)

Change-Id: Ic00a84181c8ef66189e4259ef6434dc62b81c3c6
2020-08-14 16:39:04 +02:00
Benjamin Schanzel b76a0f458e OpenShift/k8s Provider: Allow passing env vars to Pods
For the OpenShift and Kubernetes drivers, allow passing env vars to the
Pod nodes via their label config.
It is not possible to set persistent env vars in containers on run time
because there is no login shell available. Thus, we need to pass in any
env vars during node launch. This allows to set, e.g., ``http_proxy``
variables.

The env vars are passed as a list of dicts with ``name`` and ``value``
fields as per the k8s Pod YAML schema. [1]

```
- name: pod-fedora
  type: pod
  image: docker.io/fedora:28
  env:
  - name: foo
    value: bar
```

[1] https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/

Change-Id: Ibbd9222fcd8f7dc5be227e7f5c8d8772a4c594e2
2020-07-13 17:11:01 +02:00
Benjamin Schanzel baf5407adc Kubernetes Driver: Allow cpu/mem resource limits
In the OpenShift and OpenShiftPods drivers, it is possible to configure
resource requests and limits for the container per label attributes.
This feature was missing in the Kubernetes driver, thus this change
introduces it analogously to the OpenShift driver.

Change-Id: I7e67aebf892d10939672bdf76b8b3eb543124f9a
2020-06-19 15:00:25 +02:00
Tristan Cacqueray eb9af85025 config: add environment variable substitution
This change enables setting configuration values through
environment variables. This is useful to manage user defined
configuration, such as user password, in Kubernetes deployment.

Change-Id: Iafbb63ebbb388ef3038f45fd3a929c3e7e2dc343
2020-05-20 11:44:49 +00:00
Tobias Henkel 0dc40d33e4
Support optional post upload hooks
There are several scenarios where it can be useful hook into nodepool
after an image got uploaded but before it is taken into use by the
launchers. One use case is to be able to run validations on the image
(e.g. image size, boot test, etc.) before nodepool tries to use that
image and causing potentially node_failures. Another more advanced use
case is to be able to pre-distribute an image to all compute nodes in
a cloud before an image is used at scale.

To facilitate these use cases this adds a new config option
post-upload-hook to the provider config. This takes a path to a user
defined executable script which then can perform various tasks. If the
process fails with an rc != 0 the image gets deleted again and the
upload fails.

Change-Id: I099cf1243b1bd262b8ee96ab323dbd34c7578c10
2019-11-25 13:37:28 +01:00
Jan Gutter 6789c4b618 Add port-cleanup-interval config option
There are some edge cases where the port cleanup logic is too
aggressive. This change attempts to address both of them in one commit:

* Some providers might spawn instances very slowly. In the past this was
  handled by hardcoding the timeout to 10 minutes. This allows a user to
  tweak the timeout in config.
* In the esoteric combination of using Ironic without the Ironic Neutron
  agent, it's normal for ports to remain DOWN indefinitely. Setting the
  timeout to 0, will work around that edge case.

Change-Id: I120d79c4b5f209bb1bd9907db172f94f29b9cb5d
2019-10-09 17:06:48 +02:00
Tristan Cacqueray 159038503a Implement an OpenShift Pod provider
This change implements a single project OpenShift pod provider usable by a
regular user service account, without the need for a self-provisioner role.

Change-Id: I84e4bdda64716f9dd803eaa89e576c26a1667809
2019-05-07 02:25:15 +00:00
Tristan Cacqueray 76aa62230c Add python-path option to node
This change adds a new python_path Node attribute so that zuul executor
can remove the default hard-coded ansible_python_interpreter.

Change-Id: Iddf2cc6b2df579636ec39b091edcfe85a4a4ed10
2019-05-07 02:22:45 +00:00
Paul Belanger aaf36db8c6 Allow openstack provider labels to configure networks
We have a use case where we have a single pool, due to quota reasons,
but need the ability to selectively choose which network a label will
use. Now a nodepool operator will be able to define which networks are
attached to labels (in our case network appliances).

Change-Id: I3bfa32473c76b9fd59deee7d05b492e7cf67f69d
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2019-04-29 17:31:50 -04:00
Monty Taylor 516e8cd176 Rename aws flavor-name to instance-type
The AWS term is instance-type, not flavor-name. Rename this while
we don't have a huge userbase.

While we're in there, rename a variable from image_name to image_id
since we use image_id everywhere else.

Change-Id: I1f7f16d2873982626d2434cf5ca1f6280adf739c
2019-02-06 17:09:36 +00:00
Zuul 280cd5937d Merge "Revert "Revert "Add a timeout for the image build""" 2019-02-06 13:16:06 +00:00
Zuul 7b640f7f48 Merge "Amazon EC2 driver" 2019-02-04 16:13:05 +00:00
David Shrewsbury 890ea4975e Revert "Revert "Add a timeout for the image build""
This reverts commit ccf40a462a.

The previous version would not work properly when daemonized
because there was no stdout. This version maintains stdout and
uses select/poll with non-blocking stdout to capture the output
to a log file.

Depends-On: https://review.openstack.org/634266

Change-Id: I7f0617b91e071294fe6051d14475ead1d7df56b7
2019-01-31 11:36:47 -05:00
Tristan Cacqueray aa16b8b891 Amazon EC2 driver
This change adds an experimental AWS driver. It lacks some of the deeper
features of the openstack driver, such as quota management and image
building, but is highly functional for running tests on a static AMI.

Note that the test base had to be refactored to allow fixtures to be
customized in a more flexible way.

Change-Id: I313f9da435dfeb35591e37ad0bec921c8b5bc2b5
Co-Authored-By: Tristan Cacqueray <tdecacqu@redhat.com>
Co-Authored-By: David Moreau-Simard <dmsimard@redhat.com>
Co-AUthored-By: Clint Byrum <clint@fewbar.com>
2019-01-28 12:08:36 -08:00
Zuul f2c155821c Merge "Revert "Add a timeout for the image build"" 2019-01-25 22:37:34 +00:00
David Shrewsbury ccf40a462a Revert "Add a timeout for the image build"
This reverts commit 7225354ec0.

The disk-image-create command does not appear to be starting.

Change-Id: I81abe25a253a385cae08a57561129a678546f18f
2019-01-25 17:36:31 +00:00
Zuul 26c57ee5a9 Merge "Add a timeout for the image build" 2019-01-24 16:15:32 +00:00
David Shrewsbury 7225354ec0 Add a timeout for the image build
A builder thread can wedge if the build process wedges. Add a timeout
to the subprocess. Since it was the call to readline() that would block,
we change the process to have DIB write directly to the log. This allows
us to set a timeout in the Popen.wait() call. And we kill the dib
subprocess, as well.

The timeout value can be controlled in the diskimage configuration and
defaults to 8 hours.

Change-Id: I188e8a74dc39b55a4b50ade5c1a96832fea76a7d
2019-01-23 16:27:19 -05:00
Zuul 44ae87c310 Merge "Support userdata for instances in openstack" 2019-01-23 14:36:19 +00:00
Sagi Shnaidman d5027ff6a9 Support userdata for instances in openstack
Use "userdata" from Nova API to pass cloud-init config to nova
instances in openstack.

Change-Id: I1c6a1cbc5377d268901210631a376ca26f4887d8
2019-01-22 19:14:52 +02:00
Tristan Cacqueray c1378c4407 Implement an OpenShift resource provider
This change implements an OpenShift resource provider. The driver currently
supports project request and pod request to enable both containers as machine
and native containers workflow.

Depends-On: https://review.openstack.org/608610
Change-Id: Id3770f2b22b80c2e3666b9ae5e1b2fc8092ed67c
2019-01-10 05:05:46 +00:00
David Shrewsbury 16325d5c4c Add arbitrary node attributes config option
This config option, available under each provider pool section, can
contain static key-value pairs that will be stored in ZooKeeper on
each Node znode. This will allow us to pass along abitrary data from
nodepool to any user of nodepool (specifically, zuul). Initially, this
will be used to pass along zone information to zuul executors.

Change-Id: I126d37a8c0a4f44dca59c11f76a583b9181ab653
2018-11-29 09:35:59 -05:00
Tristan Cacqueray 4295ff6870 Implement a Kubernetes driver
This changes implements a Kubernetes resource provider.
The driver supports namespace request and pod request to enable both
containers as machine and native containers workflow.

Depends-On: https://review.openstack.org/605823
Change-Id: I81b5dc5abe92b71cc98b0d71c8a2863cddff6027
2018-10-25 10:24:45 +00:00
Ian Wienand 7015bd9af4 Add instance boot properties
This allows us to set parameters for server boot on various images.
This is the equivalent of the "--property" flag when using "openstack
server create".  Various tools on the booted servers can then query
the config-drive metadata to get this value.

Needed-By: https://review.openstack.org/604193/

Change-Id: I99c1980f089aa2971ba728b77adfc6f4200e0b77
2018-09-21 16:29:16 +10:00
Artem Goncharov 674c9516dc Add support for specifying security_group in nodepool
In some installations it might be unreal to rely on the default security
group (security concerns). In order to also enable possibility to share
one tenant between zuul and other resources a support for specifying
security_groups on the driver.openstack.pool level is added.

Change-Id: I63240049cba295e15f7cfe75b7e7a7d53aa4e37d
2018-06-05 10:00:06 +02:00
Zuul badb7e48ad Merge "Support winrm hosts in static driver" 2018-04-18 17:10:46 +00:00
Monty Taylor da95a817bb
Support winrm hosts in static driver
The static driver currently assumes ssh connectivity. Add a
connection-type parameter and rename the ssh-port to connection-port to
match the diskimages setting name.

Keep the old 'ssh-port' setting for backwards compat.

Change-Id: I1a96f03f9845b0d99d9ce89d2213be4d483afdd9
2018-04-13 11:36:58 -05:00
Zuul 7ddee72b51 Merge "Add connection-port to provider diskimage" 2018-04-13 15:20:58 +00:00
Tristan Cacqueray f42f65d7f5 openstack: convert rate to float
When using 'rate: 1' in the OpenStack driver, the validation fails with:
MultipleInvalid: expected float for dictionary value @ data['rate']

This change fixes that issue by auto converting rate to float.

Change-Id: Id1e95127014ad24807d629d358ae340e5720bb89
2018-04-12 02:59:48 +00:00
Tobias Henkel 687f120b3c
Add connection-port to provider diskimage
The connection port should be included in the privider diskimage.
This makes it possible to define images using other ports for
connections winrm for Windows which run on a different port than 22.

Change-Id: Ib4b335ffbcc4dc71704c06387377675a4206c663
2018-04-03 17:48:52 +02:00
Paul Belanger 2286f2432c Add host-key-checking option to openstack providers
In some cases nodepool-launcher uses public API to launch nodes, but
doesn't have access to the private networks of nodes it launches.
Rather then failing, expose an option for operators to disable
ssh-keyscan and allow nodes to become ready.

Change-Id: I764398aa21461ef44048e9e6565d2ee3e01aaaf8
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2018-03-26 22:29:14 +00:00
Tristan Cacqueray 6ac2f33cb3 Implement a static driver for Nodepool
This change adds a static node driver.

Change-Id: I065f2b42af49a57218f1c04a08b3ddd15ccc0832
Story: 2001044
Task: 4615
2018-01-31 03:55:56 +00:00
Tobias Henkel b707e7218e Add connection-type to provider diskimage
The connection type should be included in the provider diskimage. This
makes it possible to define images using other connection methods than
ssh like winrm for Windows.

Change-Id: Ica0b9afe39d347028eb66c069b8dbd56a8c0ec8c
2017-12-06 21:02:34 +01:00
Tobias Henkel 9065905296 Support username also for unmanaged cloud images
The username should also be configurable for unmanaged cloud images.

Change-Id: Ib4b8878a7fc49ed0016f0e90ff076c057216f740
2017-12-06 20:57:55 +01:00
Rui Chen 32e1e0b616 Apply floating ip for node according to configuration
When we deploy nodepool and zuul instances in virtual machine of
cloud provider, the provisioned nodes may be in the same internal
network with nodepool and zuul instances, in that case we don't
have to allocate floating ip for nodes, zuul can talk with nodes
via fixed ip of virtual machines. So if we can customize the behavior,
save the quota of floating ip, it's awesome.

Note: Although option "floating_ip_source: None" in clouds.yaml can
decide to apply floating ip or not for specified cloud, but that impact
all the SDKs and tools that use the clouds.yaml, we should control
nodepool behavior flexibly and independently.

This patch add a bool option "auto-floating-ip" into each pool of
"provider" section in nodepool.conf

Change-Id: Ia9a1bed6dd4f6e39015bde660f52e4cd6addb26e
2017-11-22 08:34:57 +00:00
Tristan Cacqueray c0e6d5112b Extend Nodepool configuration syntax to support multiple drivers
Change-Id: I220e8e71c1205174a0a7515899c9bb6c4cc6adcb
Story: 2001044
Task: 4616
2017-07-25 14:27:17 +00:00
Tristan Cacqueray a0159428d7 Add webapp port and listen_address configuration
This change adds a webapp settings to nodepool.yaml to enable custom setting
for port and listen_address.

Change-Id: I0f41a0b131bc2a09c47a448c65471e052c0a9e88
2017-06-09 13:56:36 +00:00
Paul Belanger 1d0990a1c1
Add boot-from-volume support for nodes
For example, a cloud may get better preformance from a cinder volume
then the local compute drive. As a result, give nodepool to option to
choose if the server should boot from volume or not.

Change-Id: I3faefe99096fef1fe28816ac0a4b28c05ff7f0ec
Depends-On: If58cd96b0b9ce4569120d60fbceb2c23b2f7641d
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-30 14:23:24 -04:00
Paul Belanger 1a804c7859
Add console-log to config-validate
Sadly, I missed this on our previous commit. Also update coverage from
nodepool dsvm job.

Change-Id: I6966957ac8162a588531c38bd69a93fb58a15258
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2017-05-29 15:31:54 -04:00
Jenkins df6051b4aa Merge "Support externally managed images" into feature/zuulv3 2017-05-18 15:34:11 +00:00
Tobias Henkel fbd45ba266 Support externally managed images
This adds support for using images which are not built and managed by
nodepool.

Change-Id: Iabfcf2e2f0d42622c0504b16e5f10ec7dfba97ca
2017-05-18 10:42:03 +02:00
Tobias Henkel ac6406679e Add max-ready-age to label config
This adds the max-ready-age setting to the label config. With this one
can specify how long nodes should live unused in READY state. This
enables the following use cases:

- When switching nodepool between a 'working-hours' and a
  'non-working-hours' configuration with high or low min-ready
  settings this can trigger a (delayed) scale down of unused
  resources. this can be important when using a cloud provider with
  ondemand billing model.

- Renewing old nodes without having to run a job on it. This can be
  useful for capping the age of the cached data inside the nodes.

Change-Id: Id705f0a5e478ab658ed3a396f92d6eb6694c1c8f
2017-05-18 10:31:20 +02:00
Monty Taylor 6b949f8abb Enforce cloud as a required config value
We require clouds.yaml files now. It's just the way it is. If we don't
have one, os-client-config will become unpleased - but it will do so in
a hard to understand error message (that's the best we can do there for
$reasons) ... so make sure that we present a config validation error and
not "keystoneauth1.exceptions.auth_plugins.MissingRequiredOptions: Auth
plugin requires parameters which were not given: auth_url"

Change-Id: I84e36400f38eecd5d798b772c09d768002f535f5
2017-04-27 08:37:02 -07:00