Skip to content

Commit

Permalink
Fix eclipse-jkube#231: IngressEnricher ignores IngressRules defined i…
Browse files Browse the repository at this point in the history
…n XML config
  • Loading branch information
rohanKanojia committed Jan 4, 2021
1 parent 632df5f commit 62dcd98
Show file tree
Hide file tree
Showing 13 changed files with 642 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Usage:
* Fix #387: Update Fabric8 Kubernetes Client to v4.13.0 to support `networking.k8s.io/v1` `Ingress`
* Fix #473: Debug goals work with QuarkusGenerator generated container images
* Fix #484: cacheFrom configuration parameter is missing
* Fix #231: IngressEnricher ignores IngressRules defined in XML config

### 1.0.2 (2020-10-30)
* Fix #429: Added quickstart for Micronaut framework
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.kit.config.resource;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Getter
@EqualsAndHashCode
public class IngressRuleConfig {
private String host;
private List<IngressRulePathConfig> paths;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.kit.config.resource;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Getter
@EqualsAndHashCode
public class IngressRulePathConfig {
private String pathType;
private String path;
private String serviceName;
private int servicePort;
private IngressRulePathResourceConfig resource;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.kit.config.resource;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Getter
@EqualsAndHashCode
public class IngressRulePathResourceConfig {
private String apiGroup;
private String kind;
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.kit.config.resource;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Getter
@EqualsAndHashCode
public class IngressTlsConfig {
private List<String> hosts;
private String secretName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package org.eclipse.jkube.kit.config.resource;

import io.fabric8.kubernetes.api.model.extensions.IngressRule;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -79,7 +78,10 @@ public class ResourceConfig {
@Singular
private List<ServiceAccountConfig> serviceAccounts;
@Singular
private List<IngressRule> ingressRules;
private List<IngressRuleConfig> ingressRules;

@Singular
private List<IngressTlsConfig> ingressTlsConfigs;
private OpenshiftBuildConfig openshiftBuildConfig;
private String routeDomain;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import org.eclipse.jkube.kit.common.util.ResourceUtil;
import org.eclipse.jkube.kit.config.image.ImageName;
import org.eclipse.jkube.kit.config.resource.GroupArtifactVersion;
import org.eclipse.jkube.kit.config.resource.JKubeAnnotations;
import org.eclipse.jkube.kit.config.resource.PlatformMode;
import org.eclipse.jkube.kit.config.resource.ResourceVersioning;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -104,6 +105,7 @@ private KubernetesResourceUtil() { }
public static final String OPENSHIFT_V1_VERSION = "apps.openshift.io/v1";
public static final String CRONJOB_VERSION = "batch/v1beta1";
public static final String RBAC_VERSION = "rbac.authorization.k8s.io/v1";
public static final String EXPOSE_LABEL = "expose";

public static final ResourceVersioning DEFAULT_RESOURCE_VERSIONING = new ResourceVersioning()
.withCoreVersion(API_VERSION)
Expand Down Expand Up @@ -1030,4 +1032,9 @@ private static boolean isLocalCustomisation(PodSpec podSpec) {
}
return true;
}

public static boolean isExposedService(ObjectMeta objectMeta) {
return containsLabelInMetadata(objectMeta, EXPOSE_LABEL, "true") ||
containsLabelInMetadata(objectMeta, JKubeAnnotations.SERVICE_EXPOSE_URL.value(), "true");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.api.model.PodSpec;
import io.fabric8.kubernetes.api.model.PodSpecBuilder;
import io.fabric8.kubernetes.api.model.Quantity;
Expand Down Expand Up @@ -266,6 +267,12 @@ public void testGetResourceShouldLoadNetworkV1Ingress() throws IOException {
assertEquals("my-ingress", result.getMetadata().getName());
}

@Test
public void testIsExposedService() {
assertTrue(KubernetesResourceUtil.isExposedService(new ObjectMetaBuilder().addToLabels("expose", "true").build()));
assertTrue(KubernetesResourceUtil.isExposedService(new ObjectMetaBuilder().addToLabels("jkube.io/exposeUrl", "true").build()));
}

private PodSpec getDefaultGeneratedPodSpec() {
return new PodSpecBuilder()
.addNewContainer()
Expand Down
Loading

0 comments on commit 62dcd98

Please sign in to comment.