Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection to RDS #24

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/deploy-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ jobs:
- name: Deploy to EKS
env:
IMAGE_NAME: "${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest"
RDS_ENDPOINT: "${{ secrets.RDS_ENDPOINT }}"
run: |
cat kubernetes/aws/rds-service.yml | sed "s/\$RDS_ENDPOINT/$RDS_ENDPOINT/g" | kubectl apply -f - && \
cat kubernetes/aws/deployment.yml | envsubst | kubectl apply -f - && \
kubectl apply -f kubernetes/aws/service.yml
25 changes: 25 additions & 0 deletions kubernetes/aws/alb-ingress-controller-yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: alb-ingress-controller
name: alb-ingress-controller
namespace: kube-system
spec:
selector:
matchLabels:
app.kubernetes.io/name: alb-ingress-controller
template:
metadata:
labels:
app.kubernetes.io/name: alb-ingress-controller
spec:
containers:
- name: alb-ingress-controller
args:
- --ingress-class=alb
- --cluster-name=$CLUSTER_NAME
- --aws-vpc-id=$VPC_ID
- --aws-region=$AWS_REGION
image: docker.io/amazon/aws-alb-ingress-controller:v1.1.6
serviceAccountName: alb-ingress-controller
52 changes: 52 additions & 0 deletions kubernetes/aws/eks-cluster-role.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: alb-ingress-controller
name: alb-ingress-controller
rules:
- apiGroups:
- ""
- extensions
resources:
- configmaps
- endpoints
- events
- ingresses
- ingresses/status
- services
verbs:
- create
- get
- list
- update
- watch
- patch
- apiGroups:
- ""
- extensions
resources:
- nodes
- pods
- secrets
- services
- namespaces
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: alb-ingress-controller
name: alb-ingress-controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: alb-ingress-controller
subjects:
- kind: ServiceAccount
name: alb-ingress-controller
namespace: kube-system
30 changes: 13 additions & 17 deletions kubernetes/aws/ingress.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
labels:
app.kubernetes.io/component: controller
name: nginx
annotations:
ingressclass.kubernetes.io/is-default-class: "true"
spec:
controller: k8s.io/ingress-nginx
---
apiVersion: networking.k8s.io/v1
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
kubernetes.io/ingress.class: alb
name: authentication-api-ingress
labels:
app: authentication-api-ingress
spec:
defaultBackend:
service:
name: authentication-api-service
port:
number: 80
rules:
- http:
paths:
- backend:
serviceName: authentication-api-service
servicePort: 80
path: /*
13 changes: 13 additions & 0 deletions kubernetes/aws/rds-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: rds-service
name: rds-service
spec:
externalName: $RDS_ENDPOINT
selector:
app: rds-service
type: ExternalName
status:
loadBalancer: {}
15 changes: 14 additions & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ resource "aws_db_subnet_group" "authentication_db_sng" {

resource "aws_db_instance" "authentication_db" {
allocated_storage = var.db_storage
db_name = "${var.db_name}${var.infra_env}"
identifier = "${var.db_name}-${var.infra_env}"
db_name = var.db_schema_name
engine = "postgres"
engine_version = "16.2"
instance_class = var.db_instance_type
Expand Down Expand Up @@ -378,4 +379,16 @@ resource "aws_eks_fargate_profile" "auth_cluster_fargate_profile" {
selector {
namespace = "default"
}

selector {
namespace = "kube-system"
}

selector {
namespace = "kube-public"
}

selector {
namespace = "kube-node-lease"
}
}
Loading