From 7e8c48316241bfed67e0f0d1cc829285db158cdf Mon Sep 17 00:00:00 2001 From: Quang Pham Date: Sun, 29 Oct 2023 09:36:19 +0100 Subject: [PATCH] deploy grpc and http to eks --- .github/workflows/deploy.yml | 6 +++--- Dockerfile | 2 +- eks/aws-auth.yaml | 2 +- eks/deployment.yaml | 5 ++++- eks/ingress-grpc.yaml | 25 +++++++++++++++++++++++++ eks/{ingress.yaml => ingress-http.yaml} | 13 +++---------- eks/ingress-nginx.yaml | 6 ++++++ eks/issuer.yaml | 2 +- eks/service.yaml | 7 ++++++- 9 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 eks/ingress-grpc.yaml rename eks/{ingress.yaml => ingress-http.yaml} (66%) create mode 100644 eks/ingress-nginx.yaml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b2303de0..89944829 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Deploy to production on: push: - branches: [ release ] + branches: [ master ] jobs: @@ -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 diff --git a/Dockerfile b/Dockerfile index 70aa57f8..21de61a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/eks/aws-auth.yaml b/eks/aws-auth.yaml index 89aabc39..1661ce18 100644 --- a/eks/aws-auth.yaml +++ b/eks/aws-auth.yaml @@ -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 diff --git a/eks/deployment.yaml b/eks/deployment.yaml index e80c7bc5..f053d383 100644 --- a/eks/deployment.yaml +++ b/eks/deployment.yaml @@ -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 diff --git a/eks/ingress-grpc.yaml b/eks/ingress-grpc.yaml new file mode 100644 index 00000000..71fed91c --- /dev/null +++ b/eks/ingress-grpc.yaml @@ -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 diff --git a/eks/ingress.yaml b/eks/ingress-http.yaml similarity index 66% rename from eks/ingress.yaml rename to eks/ingress-http.yaml index 0f963779..170d0e2f 100644 --- a/eks/ingress.yaml +++ b/eks/ingress-http.yaml @@ -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 @@ -26,5 +19,5 @@ spec: number: 80 tls: - hosts: - - api.simple-bank.org + - api.simplebanktest.com secretName: simple-bank-api-cert diff --git a/eks/ingress-nginx.yaml b/eks/ingress-nginx.yaml new file mode 100644 index 00000000..2a68f085 --- /dev/null +++ b/eks/ingress-nginx.yaml @@ -0,0 +1,6 @@ +apiVersion: networking.k8s.io/v1 +kind: IngressClass +metadata: + name: nginx +spec: + controller: k8s.io/ingress-nginx diff --git a/eks/issuer.yaml b/eks/issuer.yaml index debc36b1..534107b4 100644 --- a/eks/issuer.yaml +++ b/eks/issuer.yaml @@ -13,4 +13,4 @@ spec: solvers: - http01: ingress: - class: nginx + ingressClassName: nginx diff --git a/eks/service.yaml b/eks/service.yaml index e8e99726..1b3504bb 100644 --- a/eks/service.yaml +++ b/eks/service.yaml @@ -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