Skip to content

Commit

Permalink
init eks ingress and cert-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheel-ui committed Jun 25, 2024
1 parent c86e78b commit 61f9a17
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ on:

jobs:

build:
deploy:
name: Build image
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install kubectl
uses: azure/setup-kubectl@v1
with:
version: 'v1.30.2'
id: install

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -34,5 +40,14 @@ jobs:
ECR_REPOSITORY: transactions
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
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-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 apply -f eks/service.yaml
11 changes: 11 additions & 0 deletions eks/aws-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: aws-auth
namespace: kube-system
data:
mapUsers: |
- userarn: arn:aws:iam::533267180684:user/github-ci
username: github-ci
groups:
- system:masters
22 changes: 22 additions & 0 deletions eks/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: transactions-api-deployment
labels:
app: transactions-api
spec:
replicas: 1
selector:
matchLabels:
app: transactions-api
template:
metadata:
labels:
app: transactions-api
spec:
containers:
- name: transactions-api
image: 533267180684.dkr.ecr.ap-south-1.amazonaws.com/transactions:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
30 changes: 30 additions & 0 deletions eks/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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: transactions-ingress
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
ingressClassName: nginx
rules:
- host: "api.test-transactions.me"
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: transactions-api-service
port:
number: 80
tls:
- hosts:
- api.test-transactions.me
secretName: transactions-api-cert
16 changes: 16 additions & 0 deletions eks/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt
spec:
acme:
email: [email protected]
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
# Secret resource that will be used to store the account's private key.
name: letsencrypt-account-private-key
# Add a single challenge solver, HTTP01 using nginx
solvers:
- http01:
ingress:
class: nginx
14 changes: 14 additions & 0 deletions eks/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: transactions-api-service
spec:
selector:
app: transactions-api
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
# change type to ClusterIP when using ingress
# type: ClusterIP

0 comments on commit 61f9a17

Please sign in to comment.