add k8s yaml and add steps in workflow

This commit is contained in:
Mona Lisa 2023-11-17 14:06:32 -05:00
parent 145c3b12ec
commit c6d328c8d1
2 changed files with 59 additions and 1 deletions

View file

@ -57,17 +57,22 @@ jobs:
./create_image.sh ./create_image.sh
docker push anglyuboslav/geth-smart-con docker push anglyuboslav/geth-smart-con
deploy_k8s_and_app: deploy_k8s_and_app:
needs: deploy_hardhat_project
if: ${{ github.event.label.name == 'CI:Deploy'}} if: ${{ github.event.label.name == 'CI:Deploy'}}
name: Deploy K8S Cluster in AWS and deploy GETH DEVENV name: Deploy K8S Cluster in AWS and deploy GETH DEVENV
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install kubectl
- name: Install kubectl
uses: azure/setup-kubectl@v2.0 uses: azure/setup-kubectl@v2.0
with: with:
version: 'v1.27.0' version: 'v1.27.0'
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: "1.6.3"
- name: configure aws credentials - name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3 uses: aws-actions/configure-aws-credentials@v3
@ -75,6 +80,25 @@ jobs:
role-to-assume: ${{ secrets.AWS_IAM_ROLE}} role-to-assume: ${{ secrets.AWS_IAM_ROLE}}
role-session-name: K8sBuildSession role-session-name: K8sBuildSession
aws-region: us-east-1 aws-region: us-east-1
- name: Test AWS access - name: Test AWS access
run: aws sts get-caller-identity run: aws sts get-caller-identity
- name: Create K8S cluster with TF
run: |
cd terraform/eks-terraform
terraform apply -auto-approve
- name: Apply YAML Manifest for the app and checks the app
run: |
kubectl apply -f geth-pod.yaml
sleep 60
kubectl get ns
kubectl get pods -n hardhat-geth
- name: Delete k8s cluster
run: |
cd terraform/eks-terraform
terraform destroy -auto-approve

34
geth-pod.yaml Normal file
View file

@ -0,0 +1,34 @@
apiVersion: v1
kind: Namespace
metadata:
name: hardhat-geth
---
apiVersion: v1
kind: Pod
metadata:
name: geth-pod
namespace: hardhat-geth
spec:
containers:
- name: geth-container
image: anglyuboslav/geth-smart-con
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: geth-service
namespace: hardhat-geth
spec:
selector:
app: geth-pod
ports:
- protocol: TCP
port: 3000
targetPort: 3000
type: LoadBalancer