Deploying to Kubernetes

Dockerfile & app

from flask import Flask

app = Flask(__name__)

def index():
    return "Hello World with Python Flask!""", port=81)
FROM python:3.11


RUN pip install Flask

CMD ["python", ""]


Create the file deploy.yaml

defaultImage: nginx:latest redis: enabled: false # Enable Redis apps: - name: tiphyspy service: enabled: true type: ClusterIP port: 8000 hosts: - host: paths: ["/"] command: ["python", ""]

Github Actions

Setup the following .github/workflows/k8s.yml

name: Deploy on: push: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: deploy: name: Test, Build, Deploy runs-on: ubuntu-latest permissions: contents: read id-token: write env: ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} ECR_REPOSITORY: opszero IMAGE_TAG: ${{ github.sha }} steps: - name: Checkout uses: actions/[email protected] - name: Configure AWS credentials uses: aws-actions/[email protected] with: role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} aws-region: us-west-2 - name: Login to Amazon ECR id: login-ecr uses: aws-actions/[email protected] - name: Build, tag, and push image to Amazon ECR run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - name: Release Production env: CLUSTER_NAME: opszero run: | aws eks update-kubeconfig --name $CLUSTER_NAME helm repo add tiphys helm repo update helm upgrade --install tiphyspy tiphys/tiphys --timeout 10m -f ./deploy.yaml