use of io.kubernetes.client.models.V1ObjectMeta in project weblogic-kubernetes-operator by oracle.
the class IngressWatcher method getIngressClusterName.
static String getIngressClusterName(V1beta1Ingress ingress) {
V1ObjectMeta meta = ingress.getMetadata();
Map<String, String> labels = meta.getLabels();
if (labels != null) {
return labels.get(LabelConstants.CLUSTERNAME_LABEL);
}
return null;
}
use of io.kubernetes.client.models.V1ObjectMeta in project weblogic-kubernetes-operator by oracle.
the class IngressWatcher method getIngressDomainUID.
static String getIngressDomainUID(V1beta1Ingress ingress) {
V1ObjectMeta meta = ingress.getMetadata();
Map<String, String> labels = meta.getLabels();
if (labels != null) {
return labels.get(LabelConstants.DOMAINUID_LABEL);
}
return null;
}
use of io.kubernetes.client.models.V1ObjectMeta in project weblogic-kubernetes-operator by oracle.
the class Main method dispatchServiceWatch.
private static void dispatchServiceWatch(Watch.Response<V1Service> item) {
V1Service s = item.object;
if (s != null) {
V1ObjectMeta metadata = s.getMetadata();
String domainUID = metadata.getLabels().get(LabelConstants.DOMAINUID_LABEL);
String serverName = metadata.getLabels().get(LabelConstants.SERVERNAME_LABEL);
String channelName = metadata.getLabels().get(LabelConstants.CHANNELNAME_LABEL);
String clusterName = metadata.getLabels().get(LabelConstants.CLUSTERNAME_LABEL);
if (domainUID != null) {
DomainPresenceInfo info = domains.get(domainUID);
ServerKubernetesObjects sko = null;
if (info != null) {
if (serverName != null) {
ServerKubernetesObjects created = new ServerKubernetesObjects();
ServerKubernetesObjects current = info.getServers().putIfAbsent(serverName, created);
sko = current != null ? current : created;
}
switch(item.type) {
case "ADDED":
if (sko != null) {
if (channelName != null) {
sko.getChannels().put(channelName, s);
} else {
sko.getService().set(s);
}
} else if (clusterName != null) {
info.getClusters().put(clusterName, s);
}
break;
case "MODIFIED":
if (sko != null) {
if (channelName != null) {
V1Service skoService = sko.getChannels().get(channelName);
if (skoService != null) {
sko.getChannels().replace(channelName, skoService, s);
}
} else {
V1Service skoService = sko.getService().get();
if (skoService != null) {
sko.getService().compareAndSet(skoService, s);
}
}
} else if (clusterName != null) {
V1Service clusterService = info.getClusters().get(clusterName);
if (clusterService != null) {
info.getClusters().replace(clusterName, clusterService, s);
}
}
break;
case "DELETED":
if (sko != null) {
if (channelName != null) {
V1Service oldService = sko.getChannels().put(channelName, null);
if (oldService != null) {
// Service was deleted, but sko still contained a non-null entry
LOGGER.info(MessageKeys.SERVER_SERVICE_DELETED, domainUID, metadata.getNamespace(), serverName);
doCheckAndCreateDomainPresence(info.getDomain(), true);
}
} else {
V1Service oldService = sko.getService().getAndSet(null);
if (oldService != null) {
// Service was deleted, but sko still contained a non-null entry
LOGGER.info(MessageKeys.SERVER_SERVICE_DELETED, domainUID, metadata.getNamespace(), serverName);
doCheckAndCreateDomainPresence(info.getDomain(), true);
}
}
} else if (clusterName != null) {
V1Service oldService = info.getClusters().put(clusterName, null);
if (oldService != null) {
// Service was deleted, but clusters still contained a non-null entry
LOGGER.info(MessageKeys.CLUSTER_SERVICE_DELETED, domainUID, metadata.getNamespace(), clusterName);
doCheckAndCreateDomainPresence(info.getDomain(), true);
}
}
break;
case "ERROR":
default:
}
}
}
}
}
use of io.kubernetes.client.models.V1ObjectMeta in project weblogic-kubernetes-operator by oracle.
the class Main method dispatchPodWatch.
private static void dispatchPodWatch(Watch.Response<V1Pod> item) {
V1Pod p = item.object;
if (p != null) {
V1ObjectMeta metadata = p.getMetadata();
String domainUID = metadata.getLabels().get(LabelConstants.DOMAINUID_LABEL);
String serverName = metadata.getLabels().get(LabelConstants.SERVERNAME_LABEL);
if (domainUID != null) {
DomainPresenceInfo info = domains.get(domainUID);
if (info != null && serverName != null) {
ServerKubernetesObjects created = new ServerKubernetesObjects();
ServerKubernetesObjects current = info.getServers().putIfAbsent(serverName, created);
ServerKubernetesObjects sko = current != null ? current : created;
if (sko != null) {
switch(item.type) {
case "ADDED":
sko.getPod().set(p);
break;
case "MODIFIED":
V1Pod skoPod = sko.getPod().get();
if (skoPod != null) {
// If the skoPod is null then the operator deleted this pod
// and modifications are to the terminating pod
sko.getPod().compareAndSet(skoPod, p);
}
break;
case "DELETED":
V1Pod oldPod = sko.getPod().getAndSet(null);
if (oldPod != null) {
// Pod was deleted, but sko still contained a non-null entry
LOGGER.info(MessageKeys.POD_DELETED, domainUID, metadata.getNamespace(), serverName);
doCheckAndCreateDomainPresence(info.getDomain(), true);
}
break;
case "ERROR":
default:
}
}
}
}
}
}
use of io.kubernetes.client.models.V1ObjectMeta in project weblogic-kubernetes-operator by oracle.
the class AuthorizationProxy method prepareSubjectAccessReview.
/**
* Prepares an instance of SubjectAccessReview and returns same.
*
* @param principal The user, group or service account.
* @param groups The groups that principal is a member of.
* @param operation The operation to be authorized.
* @param resource The kind of resource on which the operation is to be authorized.
* @param resourceName The name of the resource instance on which the operation is to be authorized.
* @param scope The scope of the operation (cluster or namespace).
* @param namespaceName name of the namespace if scope is namespace else null.
* @return an instance of SubjectAccessReview.
*/
private V1SubjectAccessReview prepareSubjectAccessReview(String principal, final List<String> groups, Operation operation, Resource resource, String resourceName, Scope scope, String namespaceName) {
LOGGER.entering();
V1SubjectAccessReviewSpec subjectAccessReviewSpec = new V1SubjectAccessReviewSpec();
subjectAccessReviewSpec.setUser(principal);
subjectAccessReviewSpec.setGroups(groups);
subjectAccessReviewSpec.setResourceAttributes(prepareResourceAttributes(operation, resource, resourceName, scope, namespaceName));
V1SubjectAccessReview subjectAccessReview = new V1SubjectAccessReview();
subjectAccessReview.setApiVersion("authorization.k8s.io/v1");
subjectAccessReview.setKind("SubjectAccessReview");
subjectAccessReview.setMetadata(new V1ObjectMeta());
subjectAccessReview.setSpec(subjectAccessReviewSpec);
LOGGER.exiting(subjectAccessReview);
return subjectAccessReview;
}
Aggregations