Skip to content

Commit

Permalink
Merge pull request #26543 from geoand/k8s-labels
Browse files Browse the repository at this point in the history
Allow overriding of various k8s labels
  • Loading branch information
geoand committed Jul 4, 2022
2 parents 64f47d0 + 80bd1c8 commit 85375e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -76,6 +76,7 @@ public class KnativeProcessor {
private static final String KNATIVE_UTILIZATION_PERCENTAGE = "autoscaling.knative.dev/target-utilization-percentage";
private static final String KNATIVE_AUTOSCALING_TARGET = "autoscaling.knative.dev/target";
private static final String KNATIVE_CONTAINER_CONCURRENCY = "container-concurrency";
private static final String KNATIVE_DEV_VISIBILITY = "networking.knative.dev/visibility";

@BuildStep
public void checkKnative(ApplicationInfoBuildItem applicationInfo, KnativeConfig config,
Expand Down Expand Up @@ -171,8 +172,11 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
});

if (config.clusterLocal) {
result.add(new DecoratorBuildItem(KNATIVE,
new AddLabelDecorator(name, "networking.knative.dev/visibility", "cluster-local")));
if (labels.stream().noneMatch(l -> l.getKey().equals(KNATIVE_DEV_VISIBILITY))) {
result.add(new DecoratorBuildItem(KNATIVE,
new AddLabelDecorator(name, KNATIVE_DEV_VISIBILITY, "cluster-local")));
}

}

/**
Expand Down
Expand Up @@ -67,6 +67,7 @@ public class OpenshiftProcessor {
private static final int OPENSHIFT_PRIORITY = DEFAULT_PRIORITY;
private static final String OPENSHIFT_INTERNAL_REGISTRY = "image-registry.openshift-image-registry.svc:5000";
private static final String DOCKERIO_REGISTRY = "docker.io";
private static final String OPENSHIFT_V3_APP = "app";

@BuildStep
public void checkOpenshift(ApplicationInfoBuildItem applicationInfo, OpenshiftConfig config,
Expand Down Expand Up @@ -197,7 +198,9 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
if (config.flavor == v3) {
//Openshift 3.x doesn't recognize 'app.kubernetes.io/name', it uses 'app' instead.
//The decorator will be applied even on non-openshift resources is it may affect for example: knative
result.add(new DecoratorBuildItem(new AddLabelDecorator(name, "app", name)));
if (labels.stream().noneMatch(l -> l.getKey().equals(OPENSHIFT_V3_APP))) {
result.add(new DecoratorBuildItem(new AddLabelDecorator(name, OPENSHIFT_V3_APP, name)));
}

// The presence of optional is causing issues in OCP 3.11, so we better remove them.
// The following 4 decorator will set the optional property to null, so that it won't make it into the file.
Expand Down

0 comments on commit 85375e3

Please sign in to comment.