dev-future-tech / product-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Product API

Updates

Added TestContainers for testing

To do

Setup AWS deployment strategy (terraform? cloud formation?) Test minimal viable configuration for the service

Basic Environment - Non Containerized

  • Security:

    • Service accounts

    • ?

  • EC2 instances (configure scale)

  • RDS database

  • Load Balancer / API Gateway

  • Networking

    • VPC (configure, default VPC used if not set)

    • Subnet

    • HA not configured by default (optional)

  • Monitoring (cloud watch or custom. perhaps set up basic monitoring tools and connect to that?)

Basic Environment - Containerized Minimal

  • Security:

    • Service accounts

    • ?

  • ECS instances

  • Container registry

  • RDS database

  • Load Balancer / API Gateway

  • Networking

    • VPC (configure, default VPC used if not set)

    • Subnet

    • HA not configured by default (optional)

  • Monitoring (cloud watch or custom. perhaps set up basic monitoring tools and connect to that?)

Notes

Looks the terraform github actions requires terraform cloud, so for this example we will default to CloudFormation

CloudFormation Requirements

  • ❏ IAM Policy that allows the user to:

    • ❏ Create an RDS instance

    • ❏ Create a single EC2 instance

  • ❏ Ability to create an RDS instance (PostgreSQL)

  • ❏ Ability to spin up an EC2 instance with

    • ❏ Java 17

    • ❏ Env vars for the spring datasource

      • spring.datasource.url

      • spring.datasource.username

      • spring.datasource.password

      • spring.liquibase.change-log=classpath:db/database-changelog.yml

    • ❏ Memory Requirements: -Xmx32m -Xss256k

Added Multi container pod setup and k8s files. Testing remote build

Minikube Ingress setup

Create a new kubedns resolver file at /etc/resolver/minikube-product:

domain store
nameserver 192.168.64.4 # minikube ip
search_order 1
timeout 5

Update the kube-dns ConfigMap:

$ kubectl edit configmap coredns -n kube-system
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
   Corefile: |
      .:53 {
          errors
          health {
              lameduck 5s
          }
          ready
          kubernetes cluster.local in-addr.arpa ip6.arpa {
              pods insecure
              fallthrough in-addr.arpa ip6.arpa
              ttl 30
          }
          prometheus :9153
          hosts {
              192.168.64.1 host.minikube.internal
              fallthrough
          }
          forward . /etc/resolv.conf {
              max_concurrent 1000
          }
          cache 30
          loop
          reload
          loadbalance
      }
      # Start New Entry
      store:53 {
          errors
          cache 30
          forward . 192.168.64.4  # minikube ip
      }
      # End New Entry
kind: ConfigMap
metadata:
    creationTimestamp: "2022-05-24T21:18:56Z"
    name: coredns
    namespace: kube-system
    resourceVersion: "899415"
    uid: 33179e56-b59b-4830-bc56-93c8970c62da

Then deploy the ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: product-api-ingress
  namespace: product-ns

spec:
  ingressClassName: nginx
  rules:
    - host: product.store
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: product-api-svc
                port:
                  number: 8090

You can then access the API directly through: http://product.store/

Created by Anthony Ikeda

About


Languages

Language:Java 100.0%