diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..65b414b --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: underwater-app-github + labels: + app: octopus-underwater-app +spec: + selector: + matchLabels: + app: octopus-underwater-app + replicas: 3 + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: octopus-underwater-app + spec: + containers: + - name: octopus-underwater-app + image: public.ecr.aws/f9l8r7z1/octopus-underwater-app-nick:latest + ports: + - containerPort: 80 + protocol: TCP + imagePullPolicy: Always diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3907c7f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,57 @@ +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +name: AWS ECR push0 + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Install Octopus CLI + uses: OctopusDeploy/install-octopus-cli-action@v1.1.1 + with: + version: latest + - name: Checkout + uses: actions/checkout@v2 + + - 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: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push the image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.REPO_NAME }} + IMAGE_TAG: "latest" + + run: | + # Build a docker container and push it to ECR + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + echo "Pushing image to ECR..." + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + + - name: Update kube config + run: aws eks update-kubeconfig --name octopus --region us-east-1 + + - name: Deploy to EKS1 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: "latest" + run: | + sed -i.bak "s|DOCKER_IMAGE|$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG|g" manifest/git-deployment.yml && \ + kubectl apply -f manifest/git-deployment.yml + kubectl apply -f manifest/service.yml diff --git a/manifest/git-deployment.yml b/manifest/git-deployment.yml new file mode 100644 index 0000000..563c170 --- /dev/null +++ b/manifest/git-deployment.yml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: underwater-app-github1 + labels: + app: octopus-underwater-app +spec: + selector: + matchLabels: + app: octopus-underwater-app + replicas: 3 + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: octopus-underwater-app + spec: + containers: + - name: octopus-underwater-app + image: 432030471883.dkr.ecr.us-east-1.amazonaws.com/octopus-underwater-app-docker-nick:latest + ports: + - containerPort: 80 + protocol: TCP + imagePullPolicy: Always diff --git a/manifest/service.yml b/manifest/service.yml new file mode 100644 index 0000000..8cf076f --- /dev/null +++ b/manifest/service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: kubernetes-octopus-underwater-app + labels: + app: octopus-underwater-app +spec: + selector: + app: octopus-underwater-app + + ports: + - port: 28015 + targetPort: 80 + + type: LoadBalancer