From 6e5229df22098b019248c9c01ae6f569783cf839 Mon Sep 17 00:00:00 2001 From: Quang Pham Date: Sat, 28 Oct 2023 16:58:56 +0200 Subject: [PATCH] deploy grpc to eks --- .github/workflows/deploy.yml | 20 ++++++++++---------- Dockerfile | 2 +- eks/aws-auth.yaml | 2 +- eks/deployment.yaml | 6 +++++- eks/ingress.yaml | 10 ++++++---- eks/install.sh | 2 ++ eks/issuer.yaml | 2 +- eks/service.yaml | 7 ++++++- 8 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 eks/install.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 828bbed2..b2303de0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -43,13 +43,13 @@ jobs: docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . docker push -a $ECR_REGISTRY/$ECR_REPOSITORY - # - name: Update kube config - # run: aws eks update-kubeconfig --name simple-bank --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 apply -f eks/service.yaml - # kubectl apply -f eks/issuer.yaml - # kubectl apply -f eks/ingress.yaml + - name: Update kube config + run: aws eks update-kubeconfig --name simple-bank --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 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..f82d97ba 100644 --- a/eks/deployment.yaml +++ b/eks/deployment.yaml @@ -16,7 +16,11 @@ 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.yaml b/eks/ingress.yaml index 0f963779..a2ebc5b4 100644 --- a/eks/ingress.yaml +++ b/eks/ingress.yaml @@ -8,13 +8,15 @@ spec: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: simple-bank-ingress + 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: "api.simple-bank.org" + - host: "api.simplebanktest.com" http: paths: - pathType: Prefix @@ -23,8 +25,8 @@ spec: service: name: simple-bank-api-service port: - number: 80 + number: 90 tls: - hosts: - - api.simple-bank.org + - api.simplebanktest.com secretName: simple-bank-api-cert diff --git a/eks/install.sh b/eks/install.sh new file mode 100644 index 00000000..251822c1 --- /dev/null +++ b/eks/install.sh @@ -0,0 +1,2 @@ +kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/aws/deploy.yaml +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.1/cert-manager.yaml \ No newline at end of file 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