Merge pull request #28 from navi-infra/INFRA-428
INFRA-428| Deepak Jain| applying ingress with sg update
This commit is contained in:
@@ -49,15 +49,8 @@ public class KubernetesManifestService {
|
||||
|
||||
private final PortalEventPublisher portalEventPublisher;
|
||||
|
||||
public String generateManifests(Manifest manifest) {
|
||||
writeAggregatedManifestAsJson(manifest);
|
||||
int exitCode = generateKManifests(getManifestPath(manifest),
|
||||
getKubernetesManifestPath(manifest));
|
||||
if (exitCode > 0) {
|
||||
throw new KubernetesManifestException("Not able to generate kubernetes manifests");
|
||||
}
|
||||
final String kManifestPath = Paths.get(getKubernetesManifestPath(manifest)).toAbsolutePath()
|
||||
.toString();
|
||||
public String generateManifestsAndApply(Manifest manifest) {
|
||||
final String kManifestPath = generateManifests(manifest);
|
||||
log.info("Generated kubernetes manifests at {}", kManifestPath);
|
||||
|
||||
// we need a way to find diff in object if there is diff then and only then apply specific object. it will reduce time.
|
||||
@@ -73,11 +66,25 @@ public class KubernetesManifestService {
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
updateLoadBalancer(manifest, kManifestPath);
|
||||
generateManifests(manifest);
|
||||
applyManifest(manifest, kManifestPath, "ingress");
|
||||
}, CompletableFuture.delayedExecutor(5, TimeUnit.SECONDS)).orTimeout(15, TimeUnit.SECONDS);
|
||||
|
||||
return kManifestPath;
|
||||
}
|
||||
|
||||
private String generateManifests(Manifest manifest) {
|
||||
writeAggregatedManifestAsJson(manifest);
|
||||
int exitCode = generateKManifests(getManifestPath(manifest),
|
||||
getKubernetesManifestPath(manifest));
|
||||
if (exitCode > 0) {
|
||||
throw new KubernetesManifestException("Not able to generate kubernetes manifests");
|
||||
}
|
||||
return Paths.get(getKubernetesManifestPath(manifest)).toAbsolutePath()
|
||||
.toString();
|
||||
|
||||
}
|
||||
|
||||
private void updateLoadBalancer(Manifest manifest, String kManifestPath) {
|
||||
List<LoadBalancer> loadBalancers = manifest.getDeployment().getLoadBalancers();
|
||||
if (!loadBalancers.isEmpty()) {
|
||||
|
||||
@@ -11,6 +11,12 @@ import com.navi.infra.portal.repository.ManifestRepository;
|
||||
import com.navi.infra.portal.security.authorization.AuthorizationContext;
|
||||
import com.navi.infra.portal.util.ValidationUtils;
|
||||
import com.networknt.schema.ValidationMessage;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -21,13 +27,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@@ -54,7 +53,7 @@ public class ManifestService {
|
||||
|
||||
Manifest manifest = objectMapper.convertValue(manifestRequest, Manifest.class);
|
||||
manifestResponse.setManifest(saveManifestWithoutSecrets(manifest));
|
||||
kubernetesManifestService.generateManifests(manifest);
|
||||
kubernetesManifestService.generateManifestsAndApply(manifest);
|
||||
return manifestResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "A setup variable for the container",
|
||||
"required": ["name", "value", "type"],
|
||||
"required": [
|
||||
"name",
|
||||
"value",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
@@ -272,6 +276,10 @@
|
||||
"toPort": {
|
||||
"default": 443,
|
||||
"type": "integer"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"default": "Allow https traffic"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user