use of io.fabric8.kubernetes.api.model.Binding in project quarkus-operator-sdk by quarkiverse.
the class CsvManifestsBuilder method handleClusterPermissions.
private void handleClusterPermissions(List<ClusterRoleBinding> clusterRoleBindings, List<ClusterRole> clusterRoles, List<Role> roles, String defaultServiceAccountName, NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
for (ClusterRoleBinding binding : clusterRoleBindings) {
String serviceAccountName = findServiceAccountFromSubjects(binding.getSubjects(), defaultServiceAccountName);
if (NO_SERVICE_ACCOUNT.equals(serviceAccountName)) {
LOGGER.warnf("Cluster Role '%s' was not added because the service account is missing", binding.getRoleRef().getName());
continue;
}
handleClusterPermission(findRules(binding.getRoleRef(), clusterRoles, roles), serviceAccountName, installSpec);
}
}
use of io.fabric8.kubernetes.api.model.Binding in project yaks by citrusframework.
the class VerifyKameletBindingAction method doExecute.
@Override
public void doExecute(TestContext context) {
String bindingName = context.replaceDynamicContentInString(name);
CustomResourceDefinitionContext ctx = CamelKSupport.kameletBindingCRDContext(CamelKSettings.getKameletApiVersion());
KameletBinding binding = getKubernetesClient().customResources(ctx, KameletBinding.class, KameletBindingList.class).inNamespace(namespace(context)).withName(bindingName).get();
if (binding == null) {
throw new ValidationException(String.format("Failed to retrieve KameletBinding '%s' in namespace '%s'", name, namespace(context)));
}
LOG.info("KamletBinding validation successful - All values OK!");
if (LOG.isDebugEnabled()) {
try {
LOG.debug(KubernetesSupport.json().writeValueAsString(binding));
} catch (JsonProcessingException e) {
LOG.warn("Unable to dump KameletBinding data", e);
}
}
}
use of io.fabric8.kubernetes.api.model.Binding in project syndesis-qe by syndesisio.
the class OperatorValidationSteps method createPv.
@Given("create test persistent volumes with {string} storage class name")
public void createPv(String className) {
// Create 3 PVs, two with higher capacity that will be used by meta and prometheus, because the binding of PV is FCFS,
// so they theoretically can steal the test-pv from db
// These volumes won't work, but they will be available to bind
Map<String, Quantity> capacity = new HashMap<>();
capacity.put("storage", new Quantity("3Gi"));
if (!"".equals(className) && OpenShiftUtils.getInstance().storage().storageClasses().withName(className).get() == null) {
log.info("Creating storage class " + className);
OpenShiftUtils.getInstance().storage().storageClasses().createOrReplaceWithNew().withNewMetadata().withName(className).endMetadata().withProvisioner("kubernetes.io/cinder").done();
}
PersistentVolumeFluent.SpecNested<DoneablePersistentVolume> pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME).withLabels(TestUtils.map("operator", "test")).endMetadata().withNewSpec().withAccessModes("ReadOnlyMany", "ReadWriteOnce", "ReadWriteMany").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
// The default storage class for OCP3 is empty, for OCP4 is "standard", so if the className is empty, we should use the default one
if ("".equals(className)) {
if (!OpenShiftUtils.isOpenshift3()) {
if (OpenShiftUtils.isOSD()) {
pv.withStorageClassName("gp2");
} else {
pv.withStorageClassName("standard");
}
}
} else {
pv.withStorageClassName(className);
}
pv.endSpec().done();
capacity.put("storage", new Quantity("5Gi"));
for (int i = 1; i < 3; i++) {
pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME + "-" + i).endMetadata().withNewSpec().withAccessModes("ReadWriteOnce").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
if (!OpenShiftUtils.isOpenshift3()) {
// This should always be the default value despite the actual value of className - that is used only in "test-pv" intentionally
if (OpenShiftUtils.isOSD()) {
pv.withStorageClassName("gp2");
} else {
pv.withStorageClassName("standard");
}
}
pv.endSpec().done();
}
}
use of io.fabric8.kubernetes.api.model.Binding in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveRelativeVolumePathContainingSlashes.
/**
* The volume binding string: {@code src/test/docker:/path/to/container/mountpoint} is resolved, because {@code src/
* test/docker} is considered a <em>relative path</em>.
*/
@Test
public void testResolveRelativeVolumePathContainingSlashes() throws Exception {
String relativePath = "src" + SEP + "test" + SEP + "docker";
String volumeString = format(BIND_STRING_FMT, relativePath, CONTAINER_PATH);
// 'src/test/docker:/path/to/container/dir' to '/absolute/basedir/src/test/docker:/path/to/container/dir'
String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
String expectedBindingString = format(BIND_STRING_FMT, new File(ABS_BASEDIR, relativePath), CONTAINER_PATH);
assertEquals(expectedBindingString, relativizedVolumeString);
}
use of io.fabric8.kubernetes.api.model.Binding in project docker-maven-plugin by fabric8io.
the class VolumeBindingUtilTest method testResolveVolumeBindingsWithRunVolumeConfiguration.
/**
* Insures that relative paths in the host portion of a volume binding string are properly resolved against a base
* directory when present in a {@link RunVolumeConfiguration}.
*/
@Test
public void testResolveVolumeBindingsWithRunVolumeConfiguration() {
RunVolumeConfiguration.Builder builder = new RunVolumeConfiguration.Builder();
builder.bind(singletonList(format(BIND_STRING_FMT, RELATIVE_PATH, CONTAINER_PATH)));
RunVolumeConfiguration volumeConfiguration = builder.build();
// './rel:/path/to/container/dir' to '/absolute/basedir/rel:/path/to/container/dir'
resolveRelativeVolumeBindings(ABS_BASEDIR, volumeConfiguration);
String expectedBindingString = format(BIND_STRING_FMT, join("", ABS_BASEDIR.getAbsolutePath(), stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
assertEquals(expectedBindingString, volumeConfiguration.getBind().get(0));
}
Aggregations