diff --git a/PHEE-operator/deploy-operator.sh b/PHEE-operator/deploy-operator.sh new file mode 100755 index 0000000..ebe37e2 --- /dev/null +++ b/PHEE-operator/deploy-operator.sh @@ -0,0 +1,178 @@ +#!/bin/bash + +# Commands that can be used for this script +# ./deploy-operator.sh -m deploy +# ./deploy-operator.sh -m cleanup + +# Exit script on any error +set -e + +# Text Formatting +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[1;94m' +BOLD='\033[1m' +NC='\033[0m' # No Color + + +# Common Environment Setup for both deploy and cleanup +export IMAGE_NAME="ph-ee-importer-rdbms-operator" +export IMAGE_TAG="latest" +export OPERATOR_NAMESPACE="default" +export HELM_CHART_PATH="../mifos-gazelle/src/mojafos/deployer/apps/ph_template/helm/gazelle" +export RELEASE_NAME="phee" +export VALUES_FILE="ys_values.yaml" +export HELM_NAMESPACE="paymenthub" + +# Function to deploy the operator +deploy_operator() { + + # Display script banner + echo -e "${BLUE}${BOLD}" + echo "====================================================" + echo " K8s Operator Deployment " + echo "====================================================" + echo -e "${NC}" + + echo -e "${YELLOW}${BOLD}Starting Operator Deployment...${NC}" + + # 1. Pre-requisites Check + echo -e "${BLUE}Checking pre-requisites...${NC}" + # Check if kubectl, docker, mvn, and helm are installed + if ! command -v kubectl &> /dev/null || ! command -v docker &> /dev/null || ! command -v helm &> /dev/null + then + echo -e "${RED}kubectl, docker, and helm are required but not installed. Exiting.${NC}" + exit 1 + fi + + # Check if Java is installed, if not, install it + if ! command -v java &> /dev/null + then + echo -e "${YELLOW}Java is not installed. Installing OpenJDK 21...${NC}" + sudo apt-get update + sudo apt-get install openjdk-21-jdk -y || { echo -e "${RED}Failed to install Java. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Java installed successfully.${NC}" + else + echo -e "${GREEN}Java is already installed.${NC}" + fi + + # Check if Maven is installed, if not, install it + if ! command -v mvn &> /dev/null + then + echo -e "${YELLOW}Maven is not installed. Installing Maven...${NC}" + sudo apt-get install maven -y || { echo -e "${RED}Failed to install Maven. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Maven installed successfully.${NC}" + else + echo -e "${GREEN}Maven is already installed.${NC}" + fi + + echo -e "${GREEN}Pre-requisites are met.${NC}" + + # 2. Upgrading the Helm chart with ys_values.yaml + echo -e "${BLUE}Upgrading helm chart...${NC}" + helm upgrade $RELEASE_NAME $HELM_CHART_PATH -n $HELM_NAMESPACE -f $VALUES_FILE || { echo -e "${RED}Helm upgrade failed. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Helm chart upgrade successful.${NC}" + + # 3. Build the Java Project + echo -e "${BLUE}Building the Java project...${NC}" + mvn clean install || { echo -e "${RED}Maven build failed. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Java project build successful.${NC}" + + # 4. Build the Docker Image Locally + echo -e "${BLUE}Building the Docker image locally...${NC}" + mvn compile jib:dockerBuild -Dimage=$IMAGE_NAME:$IMAGE_TAG || { echo -e "${RED}Docker image build failed. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Docker image build successful.${NC}" + + # 5. Save the Docker Image to a TAR File + echo -e "${BLUE}Saving the Docker image to a TAR file...${NC}" + sudo docker save $IMAGE_NAME:$IMAGE_TAG -o $IMAGE_NAME.tar || { echo -e "${RED}Docker save failed. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Docker image saved to TAR file.${NC}" + + # 6. Import the Docker Image into k3s Cluster + echo -e "${BLUE}Importing the Docker image into the k3s cluster...${NC}" + sudo k3s ctr images import $IMAGE_NAME.tar || { echo -e "${RED}Image import to k3s failed. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Docker image successfully imported to k3s.${NC}" + + # 7. Apply CRD, Operator, and CR + echo -e "${BLUE}Applying CRD...${NC}" + kubectl apply -f deploy/crds/ph-ee-importer-rdbms-crd.yaml + echo -e "${GREEN}CRD applied successfully.${NC}" + + echo -e "${BLUE}Deploying the operator...${NC}" + kubectl apply -f deploy/operator/operator.yaml + echo -e "${GREEN}Operator deployed successfully.${NC}" + + echo -e "${BLUE}Applying CR...${NC}" + kubectl apply -f deploy/cr/ph-ee-importer-rdbms-cr.yaml + echo -e "${GREEN}CR applied successfully.${NC}" + + # 8. Post-Deployment Verification + echo -e "${BLUE}Verifying deployment...${NC}" + kubectl rollout status deployment/phee-importer-operator -n $OPERATOR_NAMESPACE || { echo -e "${RED}Deployment verification failed. Exiting.${NC}"; exit 1; } + + echo -e "${GREEN}${BOLD}Operator deployment completed successfully!${NC}" +} + +# Function to clean up the deployed resources +cleanup_operator() { + + # Display script banner + echo -e "${BLUE}${BOLD}" + echo "====================================================" + echo " K8s Operator Cleaup " + echo "====================================================" + echo -e "${NC}" + + echo -e "${YELLOW}${BOLD}Starting Cleanup...${NC}" + + echo -e "${BLUE}Deleting CR...${NC}" + kubectl delete -f deploy/cr/ph-ee-importer-rdbms-cr.yaml || { echo -e "${RED}Failed to delete CR. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}CR deleted successfully.${NC}" + + echo -e "${BLUE}Deleting operator...${NC}" + kubectl delete -f deploy/operator/operator.yaml || { echo -e "${RED}Failed to delete operator. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Operator deleted successfully.${NC}" + + echo -e "${BLUE}Deleting CRD...${NC}" + kubectl delete -f deploy/crds/ph-ee-importer-rdbms-crd.yaml || { echo -e "${RED}Failed to delete CRD. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}CRD deleted successfully.${NC}" + + if [[ -z "$IMAGE_NAME" || -z "$IMAGE_TAG" ]]; then + echo -e "${YELLOW}Image name or tag is not set correctly. Skipping Docker image removal.${NC}" + else + echo -e "${BLUE}Removing local Docker image...${NC}" + docker rmi $IMAGE_NAME:$IMAGE_TAG || { echo -e "${RED}Failed to remove Docker image. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}Docker image removed successfully.${NC}" + fi + + echo -e "${BLUE}Removing the TAR file...${NC}" + rm $IMAGE_NAME.tar || { echo -e "${RED}Failed to remove TAR file. Exiting.${NC}"; exit 1; } + echo -e "${GREEN}TAR file removed successfully.${NC}" + + echo -e "${GREEN}${BOLD}Cleanup completed successfully!${NC}" +} + +# Main script logic to handle different modes +if [ "$1" == "-m" ]; then + case "$2" in + deploy) + deploy_operator + ;; + cleanup) + cleanup_operator + ;; + *) + echo -e "${RED}Invalid mode specified. Use '-m deploy' or '-m cleanup'.${NC}" + exit 1 + ;; + esac +else + echo -e "${YELLOW}Usage: ./deploy-operator.sh -m ${NC}" + echo "Modes:" + echo " ${GREEN}deploy${NC} - Upgrade Helm chart, build, deploy, and verify the operator." + echo " ${GREEN}cleanup${NC} - Remove the operator and related resources." + exit 1 +fi + +# End of script diff --git a/PHEE-operator/deploy/cr/ph-ee-importer-rdbms-cr.yaml b/PHEE-operator/deploy/cr/ph-ee-importer-rdbms-cr.yaml index 06ef089..da187e7 100644 --- a/PHEE-operator/deploy/cr/ph-ee-importer-rdbms-cr.yaml +++ b/PHEE-operator/deploy/cr/ph-ee-importer-rdbms-cr.yaml @@ -1,12 +1,12 @@ apiVersion: my.custom.group/v1 kind: PhEeImporterRdbms metadata: - name: importer-rdbms + name: ph-ee-importer-rdbms namespace: paymenthub spec: enabled: true replicas: 1 - image: docker.io/openmf/ph-ee-importer-rdbms:v1.7.1 + image: docker.io/openmf/ph-ee-importer-rdbms:v1.13.1 # Updated image version springProfilesActive: local,tenantsConnection datasource: username: mifos @@ -25,22 +25,34 @@ spec: cpu: 100m memory: 256Mi javaToolOptions: "-Xmx256M" - bucketName: paymenthub-ee-dev - livenessProbe: - path: /actuator/health/liveness - port: 9191 - initialDelaySeconds: 120 - periodSeconds: 30 - failureThreshold: 3 - timeoutSeconds: 5 - readinessProbe: - path: /actuator/health/readiness - port: 9191 - initialDelaySeconds: 120 - periodSeconds: 30 - failureThreshold: 3 - timeoutSeconds: 5 - rbacEnabled: true # Toggle for RBACs - secretEnabled: true # Toggle for Secrets - configMapEnabled: false # Toggle for ConfigMaps - ingressEnabled: false # Toggle for Ingress \ No newline at end of file + bucketName: paymenthub-ee # Corrected bucket name + # livenessProbe: + # path: /actuator/health/liveness + # port: 9191 + # initialDelaySeconds: 120 + # periodSeconds: 30 + # failureThreshold: 3 + # timeoutSeconds: 5 + # readinessProbe: + # path: /actuator/health/readiness + # port: 9191 + # initialDelaySeconds: 120 + # periodSeconds: 30 + # failureThreshold: 3 + # timeoutSeconds: 5 + ingress: # Ingress configuration + host: "ops.sandbox.fynarfin.io" # Host from the provided Ingress describe + path: "/" # Path as indicated in the Ingress describe + className: "nginx" # Ingress class as indicated in annotations + annotations: # Annotations from the provided Ingress describe + kubernetes.io/ingress.class: "nginx" + meta.helm.sh/release-name: "moja-ph" + meta.helm.sh/release-namespace: "paymenthub" + tls: # TLS configuration from the provided Ingress describe + - hosts: + - "ops.sandbox.fynarfin.io" + secretName: "sandbox-secret" # Secret name from the provided Ingress describe + rbacEnabled: true # Toggle for RBACs (optional, ensure it's necessary) + secretEnabled: true # Toggle for Secrets (relevant due to the usage of secrets in the deployment) + configMapEnabled: false # not working due to non dynamic naming,,, Enabled to match the usage of the ConfigMap `ph-ee-config` + ingressEnabled: true # Ingress not mentioned, keep as false unless required diff --git a/PHEE-operator/deploy/crds/ph-ee-importer-rdbms-crd.yaml b/PHEE-operator/deploy/crds/ph-ee-importer-rdbms-crd.yaml index 28cbcd4..6f5b848 100644 --- a/PHEE-operator/deploy/crds/ph-ee-importer-rdbms-crd.yaml +++ b/PHEE-operator/deploy/crds/ph-ee-importer-rdbms-crd.yaml @@ -105,6 +105,32 @@ spec: type: integer timeoutSeconds: type: integer + # New Ingress Configuration Section + ingress: + type: object + properties: + host: + type: string + path: + type: string + default: "/" + className: + type: string + annotations: + type: object + additionalProperties: + type: string + tls: + type: array + items: + type: object + properties: + hosts: + type: array + items: + type: string + secretName: + type: string rbacEnabled: # Toggle for RBACs type: boolean default: false diff --git a/PHEE-operator/deploy/operator/operator.yaml b/PHEE-operator/deploy/operator/operator.yaml index d6c511b..d1507c7 100644 --- a/PHEE-operator/deploy/operator/operator.yaml +++ b/PHEE-operator/deploy/operator/operator.yaml @@ -94,10 +94,14 @@ rules: resources: - ingresses verbs: + - create - get - list - watch + - update + - patch - delete + --- apiVersion: rbac.authorization.k8s.io/v1 diff --git a/PHEE-operator/src/main/java/com/example/PhEeImporterRdbmsController.java b/PHEE-operator/src/main/java/com/example/PhEeImporterRdbmsController.java index b008cd7..9ddc6fd 100644 --- a/PHEE-operator/src/main/java/com/example/PhEeImporterRdbmsController.java +++ b/PHEE-operator/src/main/java/com/example/PhEeImporterRdbmsController.java @@ -4,6 +4,9 @@ import io.fabric8.kubernetes.api.model.*; import io.fabric8.kubernetes.api.model.apps.*; import io.fabric8.kubernetes.api.model.rbac.*; +import io.fabric8.kubernetes.api.model.networking.v1.Ingress; +import io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder; +import io.fabric8.kubernetes.api.model.networking.v1.IngressTLS; // Kubernetes client imports import io.fabric8.kubernetes.client.KubernetesClient; @@ -19,15 +22,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// Custom classes +// Custom classes and utils import com.example.customresource.PhEeImporterRdbms; import com.example.utils.LoggingUtil; import com.example.utils.StatusUpdateUtil; import com.example.utils.ProbeUtils; import com.example.utils.ResourceDeletionUtil; -// utils +// java utils +import java.time.Instant; import java.util.*; +import java.util.stream.Collectors; @ControllerConfiguration @@ -76,6 +81,23 @@ public UpdateControl reconcile(PhEeImporterRdbms resource, Co reconcileSecret(resource); } + // Check and reconcile ConfigMaps + if (resource.getSpec().getconfigMapEnabled() == null || !resource.getSpec().getconfigMapEnabled()) { + log.info("ConfigMap for resource {} is disabled, deleting associated ConfigMap resources.", resourceName); + ResourceDeletionUtil.deleteConfigMapResources(kubernetesClient, resource); + } else { + reconcileConfigmap(resource); + } + + // Check and reconcile Ingress + if (resource.getSpec().getingressEnabled() == null || !resource.getSpec().getingressEnabled()) { + log.info("Ingress for resource {} is disabled, deleting associated Ingress resources.", resourceName); + ResourceDeletionUtil.deleteIngressResources(kubernetesClient, resource); + } else { + reconcileIngress(resource); + reconcileService(resource); + } + // Always reconcile the Deployment itself reconcileDeployment(resource); @@ -127,6 +149,9 @@ private Deployment createDeployment(PhEeImporterRdbms resource) { .build()) .withLivenessProbe(ProbeUtils.createProbe(resource, "liveness")) .withReadinessProbe(ProbeUtils.createProbe(resource, "readiness")) + .withPorts(new ContainerPortBuilder() // Add this section + .withContainerPort(8000) + .build()) .build(); // Create PodSpec with the defined container and volumes @@ -157,11 +182,15 @@ private Deployment createDeployment(PhEeImporterRdbms resource) { .withTemplate(podTemplateSpec) .build(); + // // Get the current timestamp for the deployTime annotation + // String deployTime = Instant.now().toString(); + // Create Deployment metadata with owner references ObjectMeta metadata = new ObjectMetaBuilder() .withName(resource.getMetadata().getName()) .withNamespace(resource.getMetadata().getNamespace()) .withLabels(labels) + // .withAnnotations(Collections.singletonMap("example.com/deployTime", deployTime)) .withOwnerReferences(createOwnerReferences(resource)) .build(); @@ -177,14 +206,15 @@ private List createEnvironmentVariables(PhEeImporterRdbms resource) { return Arrays.asList( new EnvVar("SPRING_PROFILES_ACTIVE", resource.getSpec().getSpringProfilesActive(), null), new EnvVar("DATASOURCE_CORE_USERNAME", resource.getSpec().getDatasource().getUsername(), null), - new EnvVar("DATASOURCE_CORE_PASSWORD", null, new EnvVarSourceBuilder().withNewSecretKeyRef("database-password", "importer-rdbms-secret", false).build()), + new EnvVar("DATASOURCE_CORE_PASSWORD", null, new EnvVarSourceBuilder().withNewSecretKeyRef("database-password", "ph-ee-importer-rdbms-secret", false).build()), new EnvVar("DATASOURCE_CORE_HOST", resource.getSpec().getDatasource().getHost(), null), new EnvVar("DATASOURCE_CORE_PORT", String.valueOf(resource.getSpec().getDatasource().getPort()), null), new EnvVar("DATASOURCE_CORE_SCHEMA", resource.getSpec().getDatasource().getSchema(), null), new EnvVar("LOGGING_LEVEL_ROOT", resource.getSpec().getLogging().getLevelRoot(), null), new EnvVar("LOGGING_PATTERN_CONSOLE", resource.getSpec().getLogging().getPatternConsole(), null), new EnvVar("JAVA_TOOL_OPTIONS", resource.getSpec().getJavaToolOptions(), null), - new EnvVar("APPLICATION_BUCKET_NAME", resource.getSpec().getBucketName(), null), + new EnvVar("APPLICATION_BUCKET-NAME", resource.getSpec().getBucketName(), null), + new EnvVar("CLOUD_AWS_S3BASEURL", "http://minio:9000", null), new EnvVar("CLOUD_AWS_REGION_STATIC", null, new EnvVarSourceBuilder().withNewSecretKeyRef("aws-region", "bulk-processor-secret", false).build()), new EnvVar("AWS_ACCESS_KEY", null, new EnvVarSourceBuilder().withNewSecretKeyRef("aws-access-key", "bulk-processor-secret", false).build()), new EnvVar("AWS_SECRET_KEY", null, new EnvVarSourceBuilder().withNewSecretKeyRef("aws-secret-key", "bulk-processor-secret", false).build()) @@ -206,6 +236,147 @@ private ResourceRequirements createResourceRequirements(PhEeImporterRdbms resour } +// Reconcile Service +private void reconcileService(PhEeImporterRdbms resource) { + String serviceName = resource.getMetadata().getName() + "-svc"; + log.info("Reconciling Service for resource: {}", resource.getMetadata().getName()); + Service service = createService(resource, serviceName); + log.info("Created Service spec: {}", service); + + Resource serviceResource = kubernetesClient.services() + .inNamespace(resource.getMetadata().getNamespace()) + .withName(serviceName); + + if (serviceResource.get() == null) { + serviceResource.create(service); + log.info("Created new Service: {}", serviceName); + } else { + serviceResource.patch(service); + log.info("Updated existing Service: {}", serviceName); + } +} + +private Service createService(PhEeImporterRdbms resource, String serviceName) { + log.info("Creating Service spec for resource: {}", resource.getMetadata().getName()); + + return new ServiceBuilder() + .withNewMetadata() + .withName(serviceName) + .withNamespace(resource.getMetadata().getNamespace()) + .withLabels(Collections.singletonMap("app", resource.getMetadata().getName())) + .withOwnerReferences(createOwnerReferences(resource)) + .endMetadata() + .withNewSpec() + .withSelector(Collections.singletonMap("app", resource.getMetadata().getName())) + .withPorts(new ServicePortBuilder() + .withPort(8000) + .withTargetPort(new IntOrString(8000)) + .build()) + .withType("ClusterIP") // or "LoadBalancer" depending on your use case + .endSpec() + .build(); +} + +private void reconcileIngress(PhEeImporterRdbms resource) { + String ingressName = resource.getMetadata().getName() + "-ingress"; + log.info("Reconciling Ingress for resource: {}", resource.getMetadata().getName()); + + // Create Ingress + Ingress ingress = createIngress(resource, ingressName); + log.info("Created Ingress spec: {}", ingress); + + Resource ingressResource = kubernetesClient.network().v1().ingresses() + .inNamespace(resource.getMetadata().getNamespace()) + .withName(ingressName); + + if (ingressResource.get() == null) { + ingressResource.create(ingress); + log.info("Created new Ingress: {}", ingressName); + } else { + ingressResource.patch(ingress); + log.info("Updated existing Ingress: {}", ingressName); + } +} + +private Ingress createIngress(PhEeImporterRdbms resource, String ingressName) { + log.info("Creating Ingress spec for resource: {}", resource.getMetadata().getName()); + + // Extract values from the Custom Resource + String host = resource.getSpec().getIngress().getHost(); // e.g., "example.com" + String path = resource.getSpec().getIngress().getPath(); // e.g., "/opsapp" + String serviceName = resource.getMetadata().getName() + "-svc"; + int servicePort = 8080; // Use the port defined in your values or configuration + + // Convert custom TLS objects to Fabric8's IngressTLS + List ingressTlsList = resource.getSpec().getIngress().getTls().stream() + .map(tls -> new IngressTLS(tls.getHosts(), tls.getSecretName())) + .collect(Collectors.toList()); + + return new IngressBuilder() + .withNewMetadata() + .withName(ingressName) + .withNamespace(resource.getMetadata().getNamespace()) + .withLabels(Collections.singletonMap("app", resource.getMetadata().getName())) + .withAnnotations(resource.getSpec().getIngress().getAnnotations()) // Use CR annotations + .withOwnerReferences(createOwnerReferences(resource)) + .endMetadata() + .withNewSpec() + .withIngressClassName(resource.getSpec().getIngress().getClassName()) // Use CR ingressClassName + .withTls(ingressTlsList) // Use the converted TLS list + .addNewRule() + .withHost(host) + .withNewHttp() + .addNewPath() + .withPath(path) + .withPathType("ImplementationSpecific") // Match with values + .withNewBackend() + .withNewService() + .withName(serviceName) + .withNewPort() + .withNumber(servicePort) + .endPort() + .endService() + .endBackend() + .endPath() + .endHttp() + .endRule() + .endSpec() + .build(); +} + + + +private void reconcileConfigmap(PhEeImporterRdbms resource) { + log.info("Reconciling ConfigMap for resource: {}", resource.getMetadata().getName()); + ConfigMap configMap = createConfigMap(resource); + log.info("Created ConfigMap spec: {}", configMap); + + Resource configMapResource = kubernetesClient.configMaps() + .inNamespace(resource.getMetadata().getNamespace()) + .withName("ph-ee-config-rdbms"); + + if (configMapResource.get() == null) { + configMapResource.create(configMap); + log.info("Created new ConfigMap: {}", "ph-ee-config-rdbms"); + } else { + configMapResource.patch(configMap); + log.info("Updated existing ConfigMap: {}", "ph-ee-config-rdbms"); + } +} + +private ConfigMap createConfigMap(PhEeImporterRdbms resource) { + log.info("Creating ConfigMap spec for resource: {}", resource.getMetadata().getName()); + return new ConfigMapBuilder() + .withNewMetadata() + .withName("ph-ee-rdbms-config") + .withNamespace(resource.getMetadata().getNamespace()) + .withOwnerReferences(createOwnerReferences(resource)) + .endMetadata() + .addToData("config-file-name", "config-file-content") // Add actual config data + .build(); +} + + // Reconcile Secret private void reconcileSecret(PhEeImporterRdbms resource) { String secretName = resource.getMetadata().getName() + "-secret"; diff --git a/PHEE-operator/src/main/java/com/example/customresource/PhEeImporterRdbmsSpec.java b/PHEE-operator/src/main/java/com/example/customresource/PhEeImporterRdbmsSpec.java index ad351f5..aa920c3 100644 --- a/PHEE-operator/src/main/java/com/example/customresource/PhEeImporterRdbmsSpec.java +++ b/PHEE-operator/src/main/java/com/example/customresource/PhEeImporterRdbmsSpec.java @@ -1,6 +1,7 @@ package com.example.customresource; -import java.util.Objects; +import java.util.*; + public class PhEeImporterRdbmsSpec { private Boolean enabled; @@ -18,6 +19,7 @@ public class PhEeImporterRdbmsSpec { private Boolean secretEnabled; private Boolean configMapEnabled; private Boolean ingressEnabled; + private Ingress ingress; // New Ingress field public PhEeImporterRdbmsSpec() { } @@ -27,7 +29,8 @@ public PhEeImporterRdbmsSpec(Boolean enabled, Integer replicas, String image, St String javaToolOptions, String bucketName, Probe livenessProbe, Probe readinessProbe, Boolean rbacEnabled, Boolean secretEnabled, - Boolean configMapEnabled, Boolean ingressEnabled) { + Boolean configMapEnabled, Boolean ingressEnabled, + Ingress ingress) { this.enabled = enabled; this.replicas = replicas; this.image = image; @@ -43,8 +46,8 @@ public PhEeImporterRdbmsSpec(Boolean enabled, Integer replicas, String image, St this.secretEnabled = secretEnabled; this.configMapEnabled = configMapEnabled; this.ingressEnabled = ingressEnabled; + this.ingress = ingress; } - public Boolean getEnabled() { return enabled; } @@ -165,6 +168,15 @@ public void setingressEnabled(Boolean ingressEnabled) { this.ingressEnabled = ingressEnabled; } + // Getter and Setter for ingress + public Ingress getIngress() { + return ingress; + } + + public void setIngress(Ingress ingress) { + this.ingress = ingress; + } + @Override public String toString() { return "PhEeImporterRdbmsSpec{" + @@ -183,6 +195,7 @@ public String toString() { ", secretEnabled=" + secretEnabled + ", configMapEnabled=" + configMapEnabled + ", ingressEnabled=" + ingressEnabled + + ", ingress=" + ingress + '}'; } @@ -205,7 +218,8 @@ public boolean equals(Object o) { Objects.equals(getrbacEnabled(), that.getrbacEnabled()) && Objects.equals(getsecretEnabled(), that.getsecretEnabled()) && Objects.equals(getconfigMapEnabled(), that.getconfigMapEnabled()) && - Objects.equals(getingressEnabled(), that.getingressEnabled()); + Objects.equals(getingressEnabled(), that.getingressEnabled()) && + Objects.equals(getIngress(), that.getIngress()); } @Override @@ -214,7 +228,7 @@ public int hashCode() { getDatasource(), getResources(), getLogging(), getJavaToolOptions(), getBucketName(), getLivenessProbe(), getReadinessProbe(), getrbacEnabled(), getsecretEnabled(), - getconfigMapEnabled(), getingressEnabled()); + getconfigMapEnabled(), getingressEnabled(), getIngress()); } // Inner classes for nested objects @@ -558,4 +572,142 @@ public int hashCode() { getPeriodSeconds(), getFailureThreshold(), getTimeoutSeconds()); } } + public static class Ingress { + private String host; + private String path; + private String className; + private Map annotations; + private List tls; + + public Ingress() { + } + + public Ingress(String host, String path, String className, Map annotations, List tls) { + this.host = host; + this.path = path; + this.className = className; + this.annotations = annotations; + this.tls = tls; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Map getAnnotations() { + return annotations; + } + + public void setAnnotations(Map annotations) { + this.annotations = annotations; + } + + public List getTls() { + return tls; + } + + public void setTls(List tls) { + this.tls = tls; + } + + @Override + public String toString() { + return "Ingress{" + + "host='" + host + '\'' + + ", path='" + path + '\'' + + ", className='" + className + '\'' + + ", annotations=" + annotations + + ", tls=" + tls + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Ingress)) return false; + Ingress ingress = (Ingress) o; + return Objects.equals(getHost(), ingress.getHost()) && + Objects.equals(getPath(), ingress.getPath()) && + Objects.equals(getClassName(), ingress.getClassName()) && + Objects.equals(getAnnotations(), ingress.getAnnotations()) && + Objects.equals(getTls(), ingress.getTls()); + } + + @Override + public int hashCode() { + return Objects.hash(getHost(), getPath(), getClassName(), getAnnotations(), getTls()); + } + + // Inner class for TLS settings + public static class TLS { + private List hosts; + private String secretName; + + public TLS() { + } + + public TLS(List hosts, String secretName) { + this.hosts = hosts; + this.secretName = secretName; + } + + public List getHosts() { + return hosts; + } + + public void setHosts(List hosts) { + this.hosts = hosts; + } + + public String getSecretName() { + return secretName; + } + + public void setSecretName(String secretName) { + this.secretName = secretName; + } + + @Override + public String toString() { + return "TLS{" + + "hosts=" + hosts + + ", secretName='" + secretName + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof TLS)) return false; + TLS tls = (TLS) o; + return Objects.equals(getHosts(), tls.getHosts()) && + Objects.equals(getSecretName(), tls.getSecretName()); + } + + @Override + public int hashCode() { + return Objects.hash(getHosts(), getSecretName()); + } + } + } } diff --git a/PHEE-operator/ys_values.yaml b/PHEE-operator/ys_values.yaml new file mode 100644 index 0000000..6cc1ab3 --- /dev/null +++ b/PHEE-operator/ys_values.yaml @@ -0,0 +1,3 @@ +ph-ee-engine: + importer_rdbms: + enabled: false \ No newline at end of file