Unique access to Kubernetes resources

2/13/2019

For some integration tests we would like to have a way of ensuring, that only one test at a time has access to certain resources (e.g. 3 DeploymentConfigurations).

For that to work we have have the following workflow:

  1. Before test is started - wait until all DCs are "undeployed".
  2. When test is started - set DC replicas to 1.
  3. When test is stopped - set DC replicas to 0.

This works to some degree, but obviously has the problem, that once the test terminates unexpectedly, the DCs might still be in flight.

Now one way to "solve" this would be to introduce a CR, with a Controller, which handles lifetime of the lock (CR).

Is there any more elegant and straight forward way of allowing unique access to Kubernetes resources?


EDIT:

Sadly we are stuck with Kubernetes 1.9 for now.

-- abergmeier
kubernetes

1 Answer

2/13/2019

look at 'kubectl wait' api to set different conditions between the test flow and depending on the result proceed to next test step.

-- P Ekambaram
Source: StackOverflow