Search in sources :

Example 1 with OwnerReferenceBuilder

use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project flink by apache.

the class Fabric8FlinkKubeClient method setOwnerReference.

private void setOwnerReference(Deployment deployment, List<HasMetadata> resources) {
    final OwnerReference deploymentOwnerReference = new OwnerReferenceBuilder().withName(deployment.getMetadata().getName()).withApiVersion(deployment.getApiVersion()).withUid(deployment.getMetadata().getUid()).withKind(deployment.getKind()).withController(true).withBlockOwnerDeletion(true).build();
    resources.forEach(resource -> resource.getMetadata().setOwnerReferences(Collections.singletonList(deploymentOwnerReference)));
}
Also used : OwnerReference(io.fabric8.kubernetes.api.model.OwnerReference) OwnerReferenceBuilder(io.fabric8.kubernetes.api.model.OwnerReferenceBuilder)

Example 2 with OwnerReferenceBuilder

use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project flink by apache.

the class KubernetesOwnerReference method fromMap.

public static KubernetesOwnerReference fromMap(Map<String, String> stringMap) {
    final OwnerReferenceBuilder ownerReferenceBuilder = new OwnerReferenceBuilder();
    stringMap.forEach((k, v) -> {
        switch(k.toLowerCase()) {
            case API_VERSION:
                ownerReferenceBuilder.withApiVersion(v);
                break;
            case DELETION:
                ownerReferenceBuilder.withBlockOwnerDeletion(Boolean.valueOf(v));
                break;
            case CONTROLLER:
                ownerReferenceBuilder.withController(Boolean.valueOf(v));
                break;
            case KIND:
                ownerReferenceBuilder.withKind(v);
                break;
            case NAME:
                ownerReferenceBuilder.withName(v);
                break;
            case UUID:
                ownerReferenceBuilder.withUid(v);
                break;
            default:
                LOG.warn("Unrecognized key({}) of toleration, will ignore.", k);
                break;
        }
    });
    return new KubernetesOwnerReference(ownerReferenceBuilder.build());
}
Also used : OwnerReferenceBuilder(io.fabric8.kubernetes.api.model.OwnerReferenceBuilder)

Example 3 with OwnerReferenceBuilder

use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project keycloak by keycloak.

the class OperatorManagedResource method setOwnerReferences.

protected void setOwnerReferences(HasMetadata resource) {
    if (!cr.getMetadata().getNamespace().equals(resource.getMetadata().getNamespace())) {
        return;
    }
    OwnerReference owner = new OwnerReferenceBuilder().withApiVersion(cr.getApiVersion()).withKind(cr.getKind()).withName(cr.getMetadata().getName()).withUid(cr.getMetadata().getUid()).withBlockOwnerDeletion(true).withController(true).build();
    resource.getMetadata().setOwnerReferences(Collections.singletonList(owner));
}
Also used : OwnerReference(io.fabric8.kubernetes.api.model.OwnerReference) OwnerReferenceBuilder(io.fabric8.kubernetes.api.model.OwnerReferenceBuilder)

Aggregations

OwnerReferenceBuilder (io.fabric8.kubernetes.api.model.OwnerReferenceBuilder)3 OwnerReference (io.fabric8.kubernetes.api.model.OwnerReference)2