{"record":{"id":"c5570c49a2da9fea","repo":"quarkusio/quarkus","slug":"all-kubernetes-ports-must-be-unique","errorCode":null,"errorMessage":"All Kubernetes ports must be unique - ","messagePattern":"All Kubernetes ports must be unique - ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java","lineNumber":147,"sourceCode":"    public static boolean isNotNullOrEmpty(String string) {\n        return string != null && !string.isEmpty();\n    }\n\n    private static Map<String, Integer> verifyPorts(List<KubernetesPortBuildItem> kubernetesPortBuildItems) {\n        final Map<String, Integer> result = new HashMap<>();\n        final Set<Integer> usedPorts = new HashSet<>();\n        for (KubernetesPortBuildItem entry : kubernetesPortBuildItems) {\n            if (!entry.isEnabled()) {\n                continue;\n            }\n            final String name = entry.getName();\n            if (result.containsKey(name)) {\n                throw new IllegalArgumentException(\n                        \"All Kubernetes ports must have unique names - \" + name + \" has been used multiple times\");\n            }\n            final Integer port = entry.getPort();\n            if (usedPorts.contains(port)) {\n                throw new IllegalArgumentException(\n                        \"All Kubernetes ports must be unique - \" + port + \" has been used multiple times\");\n            }\n            result.put(name, port);\n            usedPorts.add(port);\n        }\n        return result;\n    }\n\n    /**\n     * Creates the configurator build items.\n     */\n    public static void printMessageAboutPortsThatCantChange(String target, List<KubernetesPortBuildItem> ports,\n            PlatformConfiguration configuration) {\n        ports.forEach(port -> {\n            boolean enabled = port.isEnabled() || configuration.ports().containsKey(port.getName());\n            if (enabled) {\n                String name = \"quarkus.\" + target + \".ports.\" + port.getName() + \".container-port\";\n                Optional<Integer> value = Optional.ofNullable(configuration.ports().get(port.getName()))","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java#L129-L165","documentation":"Also in KubernetesCommonHelper.verifyPorts: after checking name uniqueness it enforces that the numeric port values themselves are not reused by two enabled ports, since a Kubernetes container can bind each port number once. Violations throw IllegalArgumentException naming the duplicated port number.","triggerScenarios":"Two enabled KubernetesPortBuildItems expose the same integer port value (e.g. two services both mapped to 8080) during manifest generation.","commonSituations":"quarkus.http.port and a custom port build item both set to 8080; management port mistakenly equal to the HTTP port; a container image exposing the same port via two entries.","solutions":["Change one of the conflicting ports to a distinct value (e.g. management port to 9000)","Disable one of the duplicate port build items if it is redundant","Review quarkus.http.port / quarkus.management.port and any custom KubernetesPortBuildItem producers for collisions"],"exampleFix":"// before\nquarkus.http.port=8080\nquarkus.management.port=8080\n// after\nquarkus.http.port=8080\nquarkus.management.port=9000","handlingStrategy":"validation","validationCode":"Set<Integer> used = new HashSet<>();\nfor (KubernetesPortBuildItem p : ports) {\n    if (!used.add(p.getPort())) throw new IllegalArgumentException(\"duplicate port: \" + p.getPort());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep http and management ports distinct (e.g. 8080 vs 9000)","Centralize port constants in config to prevent drift","Before building, grep config for quarkus.*.port values and check uniqueness"],"tags":["kubernetes","ports","duplicate-port"],"backgroundTag":"duplicate-port-number","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}