diff --git a/angular-frontend/Dockerfile b/angular-frontend/Dockerfile new file mode 100644 index 0000000..d00a0a2 --- /dev/null +++ b/angular-frontend/Dockerfile @@ -0,0 +1,53 @@ +# Build stage +FROM node:14-alpine AS build +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Runtime stage +FROM nginx:alpine + +# Remove default NGINX config +RUN rm /etc/nginx/conf.d/default.conf + +# Copy your custom config +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copy Angular build output +COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] + + +# # Use official Node.js image as the base image +# FROM node:14-alpine AS build + +# # Set the working directory in the container +# WORKDIR /usr/src/app + +# # Copy package.json and package-lock.json (if available) +# COPY package*.json ./ + +# # Install project dependencies +# RUN npm install + +# # Copy the rest of the application code +# COPY . . + +# # Build the Angular application +# RUN npm run build + +# # Use NGINX as the production server +# FROM nginx:alpine + +# # Copy the built artifact from the previous stage to NGINX web server directory +# COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html + +# # Expose port 80 to the outside world +# EXPOSE 80 + +# # Start NGINX server when the container starts +# CMD ["nginx", "-g", "daemon off;"] diff --git a/angular-frontend/nginx.conf b/angular-frontend/nginx.conf new file mode 100644 index 0000000..bd681a6 --- /dev/null +++ b/angular-frontend/nginx.conf @@ -0,0 +1,17 @@ +server { + listen 80; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /api/ { + proxy_pass http://backend:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} \ No newline at end of file diff --git a/angular-frontend/src/app/services/worker.service.ts b/angular-frontend/src/app/services/worker.service.ts index d64cc20..de5346d 100644 --- a/angular-frontend/src/app/services/worker.service.ts +++ b/angular-frontend/src/app/services/worker.service.ts @@ -9,7 +9,9 @@ import { Worker } from '../models/worker'; }) export class WorkerService { - private getUrl: string = "http://localhost:8080/api/v1/workers"; + // private getUrl: string = "http://54.83.90.121:8080/api/v1/workers"; + private getUrl = "/api/v1/workers"; + constructor(private _httpClient: HttpClient) { } diff --git a/angular-frontend/src/index.html b/angular-frontend/src/index.html index cde9439..166f7ba 100644 --- a/angular-frontend/src/index.html +++ b/angular-frontend/src/index.html @@ -2,7 +2,7 @@ - AngularFrontend + myAngularFrontend diff --git a/backend-argocd.yml b/backend-argocd.yml new file mode 100644 index 0000000..42f09a5 --- /dev/null +++ b/backend-argocd.yml @@ -0,0 +1,26 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: backend + namespace: argocd +spec: + project: default + + source: + repoURL: https://github.com/gauravrajlaxmi/angular-java.git + targetRevision: develop + path: helm/backend # ✅ IMPORTANT FIX + helm: + valueFiles: + - values.yaml + + destination: + server: https://kubernetes.default.svc + namespace: apps + + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..552870c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.9" + +services: + backend: + image: ${BACKEND_IMAGE} + container_name: spring_backend + ports: + - "8080:8080" + environment: + SPRING_DATASOURCE_URL: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?${DB_PARAMS} + SPRING_DATASOURCE_USERNAME: ${DB_USER} + SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD} + restart: always + + frontend: + image: ${FRONTEND_IMAGE} + container_name: angular_frontend + ports: + - "80:80" + depends_on: + - backend + restart: always diff --git a/frontend-argocd.yml b/frontend-argocd.yml new file mode 100644 index 0000000..3a87c3e --- /dev/null +++ b/frontend-argocd.yml @@ -0,0 +1,26 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: frontend + namespace: argocd +spec: + project: default + + source: + repoURL: https://github.com/gauravrajlaxmi/angular-java.git + targetRevision: develop + path: helm/frontend + helm: + valueFiles: + - values.yaml + + destination: + server: https://kubernetes.default.svc + namespace: apps + + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true \ No newline at end of file diff --git a/helm/backend/.helmignore b/helm/backend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/backend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/backend/Chart.yaml b/helm/backend/Chart.yaml new file mode 100644 index 0000000..60aa98f --- /dev/null +++ b/helm/backend/Chart.yaml @@ -0,0 +1,31 @@ +apiVersion: v2 +name: backend +description: Spring Boot Backend +type: application +version: 0.1.0 +appVersion: "1.0" + +# apiVersion: v2 +# name: backend +# description: A Helm chart for Kubernetes + +# # A chart can be either an 'application' or a 'library' chart. +# # +# # Application charts are a collection of templates that can be packaged into versioned archives +# # to be deployed. +# # +# # Library charts provide useful utilities or functions for the chart developer. They're included as +# # a dependency of application charts to inject those utilities and functions into the rendering +# # pipeline. Library charts do not define any templates and therefore cannot be deployed. +# type: application + +# # This is the chart version. This version number should be incremented each time you make changes +# # to the chart and its templates, including the app version. +# # Versions are expected to follow Semantic Versioning (https://semver.org/) +# version: 0.1.0 + +# # This is the version number of the application being deployed. This version number should be +# # incremented each time you make changes to the application. Versions are not expected to +# # follow Semantic Versioning. They should reflect the version the application is using. +# # It is recommended to use it with quotes. +# appVersion: "1.16.0" diff --git a/helm/backend/templates/configmap.yml b/helm/backend/templates/configmap.yml new file mode 100644 index 0000000..1acc89b --- /dev/null +++ b/helm/backend/templates/configmap.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: backend-config +data: + DB_HOST: {{ .Values.database.host | quote }} + DB_PORT: {{ .Values.database.port | quote }} + DB_NAME: {{ .Values.database.name | quote }} \ No newline at end of file diff --git a/helm/backend/templates/deployment.yml b/helm/backend/templates/deployment.yml new file mode 100644 index 0000000..4911170 --- /dev/null +++ b/helm/backend/templates/deployment.yml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend +spec: + replicas: {{ .Values.replicaCount }} + + selector: + matchLabels: + app: backend + + template: + metadata: + labels: + app: backend + + spec: + containers: + - name: backend + + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + + ports: + - containerPort: 8080 + + env: + + - name: DB_HOST + valueFrom: + configMapKeyRef: + name: backend-config + key: DB_HOST + + - name: DB_PORT + valueFrom: + configMapKeyRef: + name: backend-config + key: DB_PORT + + - name: DB_NAME + valueFrom: + configMapKeyRef: + name: backend-config + key: DB_NAME + + - name: DB_USERNAME + valueFrom: + secretKeyRef: + name: backend-secret + key: DB_USERNAME + + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: backend-secret + key: DB_PASSWORD + + resources: +{{ toYaml .Values.resources | indent 10 }} \ No newline at end of file diff --git a/helm/backend/templates/secret.yml b/helm/backend/templates/secret.yml new file mode 100644 index 0000000..eb1c2b5 --- /dev/null +++ b/helm/backend/templates/secret.yml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: backend-secret +type: Opaque + +stringData: + DB_USERNAME: {{ .Values.secret.username | quote }} + DB_PASSWORD: {{ .Values.secret.password | quote }} \ No newline at end of file diff --git a/helm/backend/templates/service.yml b/helm/backend/templates/service.yml new file mode 100644 index 0000000..9860dd9 --- /dev/null +++ b/helm/backend/templates/service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: backend + +spec: + selector: + app: backend + + ports: + - name: http + port: 8080 + targetPort: 8080 + + type: {{ .Values.service.type }} \ No newline at end of file diff --git a/helm/backend/values.yaml b/helm/backend/values.yaml new file mode 100644 index 0000000..f382bc0 --- /dev/null +++ b/helm/backend/values.yaml @@ -0,0 +1,190 @@ +replicaCount: 1 + +image: + repository: gauravrajlaxmi15/angular-backend + tag: "1.2" + pullPolicy: Always + +service: + type: ClusterIP + port: 8080 + +database: + host: springbackend.c4fuciai0wpt.us-east-1.rds.amazonaws.com + port: "3306" + name: springbackend + +secret: + username: admin + password: admin123 + +resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: 500m + memory: 1Gi + + +# # Default values for backend. +# # This is a YAML-formatted file. +# # Declare variables to be passed into your templates. + +# # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +# replicaCount: 1 + +# # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +# image: +# repository: nginx +# # This sets the pull policy for images. +# pullPolicy: IfNotPresent +# # Overrides the image tag whose default is the chart appVersion. +# tag: "" + +# # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +# imagePullSecrets: [] +# # This is to override the chart name. +# nameOverride: "" +# fullnameOverride: "" + +# # This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +# serviceAccount: +# # Specifies whether a service account should be created +# create: true +# # Automatically mount a ServiceAccount's API credentials? +# automount: true +# # Annotations to add to the service account +# annotations: {} +# # The name of the service account to use. +# # If not set and create is true, a name is generated using the fullname template +# name: "" + +# # This is for setting Kubernetes Annotations to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +# podAnnotations: {} +# # This is for setting Kubernetes Labels to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +# podLabels: {} + +# podSecurityContext: {} +# # fsGroup: 2000 + +# securityContext: {} +# # capabilities: +# # drop: +# # - ALL +# # readOnlyRootFilesystem: true +# # runAsNonRoot: true +# # runAsUser: 1000 + +# # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +# service: +# # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types +# type: ClusterIP +# # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports +# port: 80 + +# # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +# ingress: +# enabled: false +# className: "" +# annotations: {} +# # kubernetes.io/ingress.class: nginx +# # kubernetes.io/tls-acme: "true" +# hosts: +# - host: chart-example.local +# paths: +# - path: / +# pathType: ImplementationSpecific +# tls: [] +# # - secretName: chart-example-tls +# # hosts: +# # - chart-example.local + +# # -- Expose the service via gateway-api HTTPRoute +# # Requires Gateway API resources and suitable controller installed within the cluster +# # (see: https://gateway-api.sigs.k8s.io/guides/) +# httpRoute: +# # HTTPRoute enabled. +# enabled: false +# # HTTPRoute annotations. +# annotations: {} +# # Which Gateways this Route is attached to. +# parentRefs: +# - name: gateway +# sectionName: http +# # namespace: default +# # Hostnames matching HTTP header. +# hostnames: +# - chart-example.local +# # List of rules and filters applied. +# rules: +# - matches: +# - path: +# type: PathPrefix +# value: /headers +# # filters: +# # - type: RequestHeaderModifier +# # requestHeaderModifier: +# # set: +# # - name: My-Overwrite-Header +# # value: this-is-the-only-value +# # remove: +# # - User-Agent +# # - matches: +# # - path: +# # type: PathPrefix +# # value: /echo +# # headers: +# # - name: version +# # value: v2 + +# resources: {} +# # We usually recommend not to specify default resources and to leave this as a conscious +# # choice for the user. This also increases chances charts run on environments with little +# # resources, such as Minikube. If you do want to specify resources, uncomment the following +# # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +# # limits: +# # cpu: 100m +# # memory: 128Mi +# # requests: +# # cpu: 100m +# # memory: 128Mi + +# # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http + +# # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +# autoscaling: +# enabled: false +# minReplicas: 1 +# maxReplicas: 100 +# targetCPUUtilizationPercentage: 80 +# # targetMemoryUtilizationPercentage: 80 + +# # Additional volumes on the output Deployment definition. +# volumes: [] +# # - name: foo +# # secret: +# # secretName: mysecret +# # optional: false + +# # Additional volumeMounts on the output Deployment definition. +# volumeMounts: [] +# # - name: foo +# # mountPath: "/etc/foo" +# # readOnly: true + +# nodeSelector: {} + +# tolerations: [] + +# affinity: {} diff --git a/helm/frontend/.helmignore b/helm/frontend/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/frontend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/frontend/Chart.yaml b/helm/frontend/Chart.yaml new file mode 100644 index 0000000..67cc864 --- /dev/null +++ b/helm/frontend/Chart.yaml @@ -0,0 +1,30 @@ +apiVersion: v2 +name: frontend +description: Angular Frontend +type: application +version: 0.1.0 +appVersion: "1.0" +# apiVersion: v2 +# name: frontend +# description: A Helm chart for Kubernetes + +# # A chart can be either an 'application' or a 'library' chart. +# # +# # Application charts are a collection of templates that can be packaged into versioned archives +# # to be deployed. +# # +# # Library charts provide useful utilities or functions for the chart developer. They're included as +# # a dependency of application charts to inject those utilities and functions into the rendering +# # pipeline. Library charts do not define any templates and therefore cannot be deployed. +# type: application + +# # This is the chart version. This version number should be incremented each time you make changes +# # to the chart and its templates, including the app version. +# # Versions are expected to follow Semantic Versioning (https://semver.org/) +# version: 0.1.0 + +# # This is the version number of the application being deployed. This version number should be +# # incremented each time you make changes to the application. Versions are not expected to +# # follow Semantic Versioning. They should reflect the version the application is using. +# # It is recommended to use it with quotes. +# appVersion: "1.16.0" diff --git a/helm/frontend/templates/deployment.yml b/helm/frontend/templates/deployment.yml new file mode 100644 index 0000000..d9fd82b --- /dev/null +++ b/helm/frontend/templates/deployment.yml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend + +spec: + replicas: {{ .Values.replicaCount }} + + selector: + matchLabels: + app: frontend + + template: + metadata: + labels: + app: frontend + + spec: + containers: + - name: frontend + + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + + ports: + - containerPort: 80 + + resources: +{{ toYaml .Values.resources | indent 10 }} \ No newline at end of file diff --git a/helm/frontend/templates/service.yml b/helm/frontend/templates/service.yml new file mode 100644 index 0000000..8480aaa --- /dev/null +++ b/helm/frontend/templates/service.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend + +spec: + selector: + app: frontend + + ports: + - port: 80 + targetPort: 80 + + type: {{ .Values.service.type }} \ No newline at end of file diff --git a/helm/frontend/values.yaml b/helm/frontend/values.yaml new file mode 100644 index 0000000..750acdc --- /dev/null +++ b/helm/frontend/values.yaml @@ -0,0 +1,181 @@ +replicaCount: 1 + +image: + repository: gauravrajlaxmi15/angular-frontend + tag: "1.1" + pullPolicy: Always + +service: + type: ClusterIP + port: 80 + +resources: + requests: + cpu: 100m + memory: 128Mi + + limits: + cpu: 200m + memory: 256Mi + +# # Default values for frontend. +# # This is a YAML-formatted file. +# # Declare variables to be passed into your templates. + +# # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +# replicaCount: 1 + +# # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +# image: +# repository: nginx +# # This sets the pull policy for images. +# pullPolicy: IfNotPresent +# # Overrides the image tag whose default is the chart appVersion. +# tag: "" + +# # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +# imagePullSecrets: [] +# # This is to override the chart name. +# nameOverride: "" +# fullnameOverride: "" + +# # This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +# serviceAccount: +# # Specifies whether a service account should be created +# create: true +# # Automatically mount a ServiceAccount's API credentials? +# automount: true +# # Annotations to add to the service account +# annotations: {} +# # The name of the service account to use. +# # If not set and create is true, a name is generated using the fullname template +# name: "" + +# # This is for setting Kubernetes Annotations to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +# podAnnotations: {} +# # This is for setting Kubernetes Labels to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +# podLabels: {} + +# podSecurityContext: {} +# # fsGroup: 2000 + +# securityContext: {} +# # capabilities: +# # drop: +# # - ALL +# # readOnlyRootFilesystem: true +# # runAsNonRoot: true +# # runAsUser: 1000 + +# # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +# service: +# # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types +# type: ClusterIP +# # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports +# port: 80 + +# # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +# ingress: +# enabled: false +# className: "" +# annotations: {} +# # kubernetes.io/ingress.class: nginx +# # kubernetes.io/tls-acme: "true" +# hosts: +# - host: chart-example.local +# paths: +# - path: / +# pathType: ImplementationSpecific +# tls: [] +# # - secretName: chart-example-tls +# # hosts: +# # - chart-example.local + +# # -- Expose the service via gateway-api HTTPRoute +# # Requires Gateway API resources and suitable controller installed within the cluster +# # (see: https://gateway-api.sigs.k8s.io/guides/) +# httpRoute: +# # HTTPRoute enabled. +# enabled: false +# # HTTPRoute annotations. +# annotations: {} +# # Which Gateways this Route is attached to. +# parentRefs: +# - name: gateway +# sectionName: http +# # namespace: default +# # Hostnames matching HTTP header. +# hostnames: +# - chart-example.local +# # List of rules and filters applied. +# rules: +# - matches: +# - path: +# type: PathPrefix +# value: /headers +# # filters: +# # - type: RequestHeaderModifier +# # requestHeaderModifier: +# # set: +# # - name: My-Overwrite-Header +# # value: this-is-the-only-value +# # remove: +# # - User-Agent +# # - matches: +# # - path: +# # type: PathPrefix +# # value: /echo +# # headers: +# # - name: version +# # value: v2 + +# resources: {} +# # We usually recommend not to specify default resources and to leave this as a conscious +# # choice for the user. This also increases chances charts run on environments with little +# # resources, such as Minikube. If you do want to specify resources, uncomment the following +# # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +# # limits: +# # cpu: 100m +# # memory: 128Mi +# # requests: +# # cpu: 100m +# # memory: 128Mi + +# # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http + +# # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +# autoscaling: +# enabled: false +# minReplicas: 1 +# maxReplicas: 100 +# targetCPUUtilizationPercentage: 80 +# # targetMemoryUtilizationPercentage: 80 + +# # Additional volumes on the output Deployment definition. +# volumes: [] +# # - name: foo +# # secret: +# # secretName: mysecret +# # optional: false + +# # Additional volumeMounts on the output Deployment definition. +# volumeMounts: [] +# # - name: foo +# # mountPath: "/etc/foo" +# # readOnly: true + +# nodeSelector: {} + +# tolerations: [] + +# affinity: {} diff --git a/helm/ingress/.helmignore b/helm/ingress/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/ingress/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/ingress/Chart.yaml b/helm/ingress/Chart.yaml new file mode 100644 index 0000000..f4db49e --- /dev/null +++ b/helm/ingress/Chart.yaml @@ -0,0 +1,31 @@ +apiVersion: v2 +name: ingress +description: Application Ingress +type: application +version: 0.1.0 +appVersion: "1.0" + +# apiVersion: v2 +# name: ingress +# description: A Helm chart for Kubernetes + +# # A chart can be either an 'application' or a 'library' chart. +# # +# # Application charts are a collection of templates that can be packaged into versioned archives +# # to be deployed. +# # +# # Library charts provide useful utilities or functions for the chart developer. They're included as +# # a dependency of application charts to inject those utilities and functions into the rendering +# # pipeline. Library charts do not define any templates and therefore cannot be deployed. +# type: application + +# # This is the chart version. This version number should be incremented each time you make changes +# # to the chart and its templates, including the app version. +# # Versions are expected to follow Semantic Versioning (https://semver.org/) +# version: 0.1.0 + +# # This is the version number of the application being deployed. This version number should be +# # incremented each time you make changes to the application. Versions are not expected to +# # follow Semantic Versioning. They should reflect the version the application is using. +# # It is recommended to use it with quotes. +# appVersion: "1.16.0" diff --git a/helm/ingress/templates/ingress.yml b/helm/ingress/templates/ingress.yml new file mode 100644 index 0000000..875c876 --- /dev/null +++ b/helm/ingress/templates/ingress.yml @@ -0,0 +1,32 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress + +metadata: + name: employee-ingress + +spec: + ingressClassName: nginx + + rules: + - host: {{ .Values.host }} + + http: + paths: + + - path: / + pathType: Prefix + + backend: + service: + name: frontend + port: + number: 80 + + - path: /api + pathType: Prefix + + backend: + service: + name: backend + port: + number: 8080 \ No newline at end of file diff --git a/helm/ingress/values.yaml b/helm/ingress/values.yaml new file mode 100644 index 0000000..2175ad1 --- /dev/null +++ b/helm/ingress/values.yaml @@ -0,0 +1,163 @@ +host: employee.local + +# # Default values for ingress. +# # This is a YAML-formatted file. +# # Declare variables to be passed into your templates. + +# # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +# replicaCount: 1 + +# # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +# image: +# repository: nginx +# # This sets the pull policy for images. +# pullPolicy: IfNotPresent +# # Overrides the image tag whose default is the chart appVersion. +# tag: "" + +# # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +# imagePullSecrets: [] +# # This is to override the chart name. +# nameOverride: "" +# fullnameOverride: "" + +# # This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +# serviceAccount: +# # Specifies whether a service account should be created +# create: true +# # Automatically mount a ServiceAccount's API credentials? +# automount: true +# # Annotations to add to the service account +# annotations: {} +# # The name of the service account to use. +# # If not set and create is true, a name is generated using the fullname template +# name: "" + +# # This is for setting Kubernetes Annotations to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +# podAnnotations: {} +# # This is for setting Kubernetes Labels to a Pod. +# # For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +# podLabels: {} + +# podSecurityContext: {} +# # fsGroup: 2000 + +# securityContext: {} +# # capabilities: +# # drop: +# # - ALL +# # readOnlyRootFilesystem: true +# # runAsNonRoot: true +# # runAsUser: 1000 + +# # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +# service: +# # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types +# type: ClusterIP +# # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports +# port: 80 + +# # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +# ingress: +# enabled: false +# className: "" +# annotations: {} +# # kubernetes.io/ingress.class: nginx +# # kubernetes.io/tls-acme: "true" +# hosts: +# - host: chart-example.local +# paths: +# - path: / +# pathType: ImplementationSpecific +# tls: [] +# # - secretName: chart-example-tls +# # hosts: +# # - chart-example.local + +# # -- Expose the service via gateway-api HTTPRoute +# # Requires Gateway API resources and suitable controller installed within the cluster +# # (see: https://gateway-api.sigs.k8s.io/guides/) +# httpRoute: +# # HTTPRoute enabled. +# enabled: false +# # HTTPRoute annotations. +# annotations: {} +# # Which Gateways this Route is attached to. +# parentRefs: +# - name: gateway +# sectionName: http +# # namespace: default +# # Hostnames matching HTTP header. +# hostnames: +# - chart-example.local +# # List of rules and filters applied. +# rules: +# - matches: +# - path: +# type: PathPrefix +# value: /headers +# # filters: +# # - type: RequestHeaderModifier +# # requestHeaderModifier: +# # set: +# # - name: My-Overwrite-Header +# # value: this-is-the-only-value +# # remove: +# # - User-Agent +# # - matches: +# # - path: +# # type: PathPrefix +# # value: /echo +# # headers: +# # - name: version +# # value: v2 + +# resources: {} +# # We usually recommend not to specify default resources and to leave this as a conscious +# # choice for the user. This also increases chances charts run on environments with little +# # resources, such as Minikube. If you do want to specify resources, uncomment the following +# # lines, adjust them as necessary, and remove the curly braces after 'resources:'. +# # limits: +# # cpu: 100m +# # memory: 128Mi +# # requests: +# # cpu: 100m +# # memory: 128Mi + +# # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http + +# # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +# autoscaling: +# enabled: false +# minReplicas: 1 +# maxReplicas: 100 +# targetCPUUtilizationPercentage: 80 +# # targetMemoryUtilizationPercentage: 80 + +# # Additional volumes on the output Deployment definition. +# volumes: [] +# # - name: foo +# # secret: +# # secretName: mysecret +# # optional: false + +# # Additional volumeMounts on the output Deployment definition. +# volumeMounts: [] +# # - name: foo +# # mountPath: "/etc/foo" +# # readOnly: true + +# nodeSelector: {} + +# tolerations: [] + +# affinity: {} diff --git a/ingress-argocd.yml b/ingress-argocd.yml new file mode 100644 index 0000000..94a2bdc --- /dev/null +++ b/ingress-argocd.yml @@ -0,0 +1,23 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: ingress + namespace: argocd +spec: + project: default + + source: + repoURL: https://github.com/gauravrajlaxmi/angular-java.git + targetRevision: develop + path: helm/ingress + + destination: + server: https://kubernetes.default.svc + namespace: apps + + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true \ No newline at end of file diff --git a/kind-config.yml b/kind-config.yml new file mode 100644 index 0000000..609f42f --- /dev/null +++ b/kind-config.yml @@ -0,0 +1,17 @@ +kind: Cluster + +apiVersion: kind.x-k8s.io/v1alpha4 + +nodes: + +- role: control-plane + + extraPortMappings: + + - containerPort: 80 + hostPort: 80 + protocol: TCP + + - containerPort: 443 + hostPort: 443 + protocol: TCP diff --git a/spring-backend/Dockerfile b/spring-backend/Dockerfile new file mode 100644 index 0000000..49f209c --- /dev/null +++ b/spring-backend/Dockerfile @@ -0,0 +1,37 @@ +# Build stage +FROM maven:3.9.6-eclipse-temurin-8 AS build +WORKDIR /app +COPY pom.xml . +COPY src ./src +RUN mvn clean package -DskipTests + +# Runtime stage +FROM eclipse-temurin:8-jre +WORKDIR /app +COPY --from=build /app/target/spring-backend-v1.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] + + +# # Use Ubuntu as base image +# FROM ubuntu:latest + +# # Install dependencies +# RUN apt-get update && \ +# apt-get install -y openjdk-8-jdk maven && \ +# rm -rf /var/lib/apt/lists/* + +# # Set the working directory in the container +# WORKDIR /app + +# # Copy the Maven project directory into the container +# COPY . /app + +# # Build the Maven project +# RUN mvn clean package -Dmaven.test.skip=true + +# # Expose the port the application runs on +# EXPOSE 8080 + +# # Command to run the application +# CMD ["java", "-jar", "target/spring-backend-v1.jar"] diff --git a/spring-backend/pom.xml b/spring-backend/pom.xml index 03ae237..9c3ad3f 100644 --- a/spring-backend/pom.xml +++ b/spring-backend/pom.xml @@ -1,12 +1,13 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent 2.7.4 - + com.example spring-backend @@ -33,10 +34,15 @@ runtime true - + + + org.mariadb.jdbc + mariadb-java-client + 3.4.1 org.projectlombok @@ -67,4 +73,4 @@ - + \ No newline at end of file diff --git a/spring-backend/src/main/resources/application.properties b/spring-backend/src/main/resources/application.properties index 10c4f6d..53a58cb 100644 --- a/spring-backend/src/main/resources/application.properties +++ b/spring-backend/src/main/resources/application.properties @@ -1,5 +1,24 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/springbackend?useSSL=false -spring.datasource.username=springbackend -spring.datasource.password=springbackend +# spring.datasource.url=jdbc:mysql://springbackend1.c9ssayqq8va2.us-east-1.rds.amazonaws.com:3306/springbackend?useSSL=false +#spring.datasource.username=admin +#spring.datasource.password=admin123 + +#spring.jpa.generate-ddl=true + +# spring.datasource.url=jdbc:mariadb://${DB_HOST}:${DB_PORT}/${DB_NAME} +spring.datasource.url=jdbc:mariadb://${DB_HOST}:${DB_PORT}/${DB_NAME}?sslMode=trust + +spring.datasource.username=${DB_USERNAME} + +spring.datasource.password=${DB_PASSWORD} + +spring.jpa.hibernate.ddl-auto=update + +spring.jpa.database-platform=org.hibernate.dialect.MariaDBDialect +spring.jpa.hibernate.ddl-auto=update +# spring.datasource.url=${SPRING_DATASOURCE_URL} +# spring.datasource.username=${SPRING_DATASOURCE_USERNAME} +# spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} + +# spring.jpa.generate-ddl=true +# spring.jpa.hibernate.ddl-auto=update -spring.jpa.generate-ddl=true \ No newline at end of file