Skip to content

Commit

Permalink
deploy grpc and http to eks
Browse files Browse the repository at this point in the history
  • Loading branch information
phamlequang committed Oct 29, 2023
1 parent 42c6148 commit 7e8c483
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to production

on:
push:
branches: [ release ]
branches: [ master ]

jobs:

Expand Down Expand Up @@ -44,12 +44,12 @@ jobs:
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
- name: Update kube config
run: aws eks update-kubeconfig --name simple-bank --region eu-west-1
run: aws eks update-kubeconfig --name simple-bank-eks --region eu-west-1

- name: Deploy image to Amazon EKS
run: |
kubectl apply -f eks/aws-auth.yaml
kubectl apply -f eks/deployment.yaml
kubectl rollout restart -f eks/deployment.yaml
kubectl apply -f eks/service.yaml
kubectl apply -f eks/issuer.yaml
kubectl apply -f eks/ingress.yaml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ COPY start.sh .
COPY wait-for.sh .
COPY db/migration ./db/migration

EXPOSE 8080
EXPOSE 8080 9090
CMD [ "/app/main" ]
ENTRYPOINT [ "/app/start.sh" ]
2 changes: 1 addition & 1 deletion eks/aws-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: kube-system
data:
mapUsers: |
- userarn: arn:aws:iam::095420225348:user/github-ci
- userarn: arn:aws:iam::760486049168:user/github-ci
username: github-ci
groups:
- system:masters
5 changes: 4 additions & 1 deletion eks/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ spec:
spec:
containers:
- name: simple-bank-api
image: 095420225348.dkr.ecr.eu-west-1.amazonaws.com/simplebank:latest
image: 760486049168.dkr.ecr.eu-west-1.amazonaws.com/simplebank:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
name: http-server
- containerPort: 9090
name: grpc-server
25 changes: 25 additions & 0 deletions eks/ingress-grpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: simple-bank-ingress-grpc
annotations:
cert-manager.io/cluster-issuer: letsencrypt
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
spec:
ingressClassName: nginx
rules:
- host: "gapi.simplebanktest.com"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: simple-bank-api-service
port:
number: 90
tls:
- hosts:
- gapi.simplebanktest.com
secretName: simple-bank-gapi-cert
13 changes: 3 additions & 10 deletions eks/ingress.yaml → eks/ingress-http.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx
spec:
controller: k8s.io/ingress-nginx
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: simple-bank-ingress
name: simple-bank-ingress-http
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
ingressClassName: nginx
rules:
- host: "api.simple-bank.org"
- host: "api.simplebanktest.com"
http:
paths:
- pathType: Prefix
Expand All @@ -26,5 +19,5 @@ spec:
number: 80
tls:
- hosts:
- api.simple-bank.org
- api.simplebanktest.com
secretName: simple-bank-api-cert
6 changes: 6 additions & 0 deletions eks/ingress-nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: nginx
spec:
controller: k8s.io/ingress-nginx
2 changes: 1 addition & 1 deletion eks/issuer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
solvers:
- http01:
ingress:
class: nginx
ingressClassName: nginx
7 changes: 6 additions & 1 deletion eks/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
targetPort: http-server
name: http-service
- protocol: TCP
port: 90
targetPort: grpc-server
name: grpc-service
type: ClusterIP

0 comments on commit 7e8c483

Please sign in to comment.