Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding of various k8s labels #26543

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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