diff --git a/.github/workflows/kubernetes.yml b/.github/workflows/kubernetes.yml new file mode 100644 index 0000000..9b8fe2e --- /dev/null +++ b/.github/workflows/kubernetes.yml @@ -0,0 +1,65 @@ +# This is a basic workflow to help you get started with Actions +# +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.REGION }} + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + + - name: Install helm + uses: azure/setup-helm@v4.2.0 + + - name: Update kubeconfig + run: | + aws eks update-kubeconfig --region us-east-1 --name alameen-eks-cluster + kubectl config set-context --current --namespace=sock-shop + kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.crds.yaml + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.1/cert-manager.yaml + + + - name: add helm charts + run: | + helm repo add ingress https://kubernetes.github.io/ingress-nginx + helm repo add prometheus https://prometheus-community.github.io/helm-charts + + + - name: Update helm charts + run: helm repo update + + - name: install helm charts + run: | + + helm upgrade --install prometheus prometheus/kube-prometheus-stack + helm upgrade --install ingress ingress/ingress-nginx + + - name: run manifest files + run: kubectl apply -f kubernetes/. \ No newline at end of file diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 0000000..46910ce --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,58 @@ +# This is a basic workflow to help you get started with Actions + +name: terraform + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: [ "terraform" ] + + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.REGION }} + + + - name: Create s3 bucket + run: aws s3 mb s3://sockshop-terraform-state-bucket + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + + - name: Install helm + uses: azure/setup-helm@v4.2.0 + + + - name: setup terraform + uses: hashicorp/setup-terraform@v2 + + - name: Create EKS cluster + run: | + terraform -chdir=terraform/ init + terraform -chdir=terraform apply --auto-approve + + + + - name: Update kubeconfig + run: | + aws eks update-kubeconfig --region us-east-1 --name alameen-eks-cluster + kubectl create namespace sock-shop \ No newline at end of file