Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try #5

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/infracost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# The GitHub Actions docs (https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on)
# describe other options for 'on', 'pull_request' is a good default.
on: [pull_request]
env:
# If you use private modules you'll need this env variable to use
# the same ssh-agent socket value across all jobs & steps.
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
jobs:
infracost:
name: Infracost
runs-on: ubuntu-latest
permissions:
contents: read
# Required to post comments
pull-requests: write

env:
TF_ROOT: examples/terraform-project/code
# If you're using Terraform Cloud/Enterprise and have variables or private modules stored
# on there, specify the following to automatically retrieve the variables:
# INFRACOST_TERRAFORM_CLOUD_TOKEN: ${{ secrets.TFC_TOKEN }}
# INFRACOST_TERRAFORM_CLOUD_HOST: app.terraform.io # Change this if you're using Terraform Enterprise

steps:
# If you use private modules, add an environment variable or secret
# called GIT_SSH_KEY with your private key, so Infracost can access
# private repositories (similar to how Terraform/Terragrunt does).
# - name: add GIT_SSH_KEY
# run: |
# ssh-agent -a $SSH_AUTH_SOCK
# mkdir -p ~/.ssh
# echo "${{ secrets.GIT_SSH_KEY }}" | tr -d '\r' | ssh-add -
# ssh-keyscan github.com >> ~/.ssh/known_hosts

- name: Setup Infracost
uses: infracost/actions/setup@v2
# See https://github.com/infracost/actions/tree/master/setup for other inputs
# If you can't use this action, see Docker images in https://infracost.io/cicd
with:
api-key: ${{ secrets.INFRACOST_API_KEY }}

# Checkout the base branch of the pull request (e.g. main/master).
- name: Checkout base branch
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.base.ref }}'

# Generate Infracost JSON file as the baseline.
- name: Generate Infracost cost estimate baseline
run: |
infracost breakdown --path=${TF_ROOT} \
--format=json \
--out-file=/tmp/infracost-base.json

# Checkout the current PR branch so we can create a diff.
- name: Checkout PR branch
uses: actions/checkout@v3

# Generate an Infracost diff and save it to a JSON file.
- name: Generate Infracost diff
run: |
infracost diff --path=${TF_ROOT} \
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json

# Posts a comment to the PR using the 'update' behavior.
# This creates a single comment and updates it. The "quietest" option.
# The other valid behaviors are:
# delete-and-new - Delete previous comments and create a new one.
# hide-and-new - Minimize previous comments and create a new one.
# new - Create a new cost estimate comment on every push.
# See https://www.infracost.io/docs/features/cli_commands/#comment-on-pull-requests for other options.
- name: Post Infracost comment
run: |
infracost comment github --path=/tmp/infracost.json \
--repo=$GITHUB_REPOSITORY \
--github-token=${{github.token}} \
--pull-request=${{github.event.pull_request.number}} \
--behavior=update
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ FROM python:3.7.5

WORKDIR /app
COPY . .
RUN pip install flask
RUN python -m pip install -r requirements.txt
RUN pip install flask
RUN python -m pip install -r requirements.txt
ENV FLASK_APP=main.py
ENV FLASK_ENV=development

Expand Down
17 changes: 10 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ services:
- 3305:3306
restart: on-failure
volumes:
- mariadb:/var/lib/mysql
# command: flask run

- mariadb-notes:/var/lib/mysql

app:
image: python_app
build: .
environment:
DB_HOST: db
DB_PORT: '3306'
DB_NAME: note
DB_USERNAME: note
DB_PASSWORD: note
ports:
- 5001:5000
depends_on:
- db




volumes:
mariadb:
mariadb-notes:
driver: local
214 changes: 214 additions & 0 deletions flask-depl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask-app
labels:
app: flask
spec:
replicas: 1
selector:
matchLabels:
app: flask
template:
metadata:
labels:
app: flask
spec:
# nodeName: luna.pride.improwised.dev
# initContainers:
# - command: ["flask", "db", "upgrade"]
# image: ankitjilka31/flask-note:1.2.2
# name: flask-migrate
# envFrom:
# - configMapRef:
# name: db-config
# - secretRef:
# name: maria-secret
# # env:
# # - name: DB_HOST
# # value: maria-service

# # - name: DB_NAME
# # value: mydb

# # - name: DB_USERNAME
# # value: hello

# # - name: DB_PASSWORD
# # value: hello

# # - name: DB_PORT
# # value: '3306'

# # - name: PORT
# # value: '5000'

containers:
- name: flask-container
image: ankitjilka31/flask-note:1.3
ports:
- containerPort: 5000
envFrom:
- configMapRef:
name: db-config
- secretRef:
name: maria-secret

# env:
# - name: DB_USERNAME
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: MARIADB_USER
# - name: DB_PASSWORD
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: MARIADB_PASSWORD
# - name: DB_HOST
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : host
# - name: DB_NAME
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : dbName
# - name: DB_USERNAME
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: maria-username
# - name: DB_PASSWORD
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: maria-password
# - name: DB_PORT
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : dbPort
# - name: PORT
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : port

# - name: DB_HOST
# value: maria-service

# - name: DB_NAME
# value: mydb

# - name: DB_USERNAME
# value: hello

# - name: DB_PASSWORD
# value: hello

# - name: DB_PORT
# value: '3306'

# - name: PORT
# value: '5000'

---

apiVersion: v1
kind: Service
metadata:
name: flask-app-service
spec:
selector:
app: flask
type: LoadBalancer
ports:
- protocol: TCP
port: 8081
targetPort: 5000



---


apiVersion: batch/v1
kind: Job
metadata:
name: db-up-job
spec:
ttlSecondsAfterFinished: 0
template:
spec:
nodeName: luna.pride.improwised.dev
containers:
- name: flask-container
image: ankitjilka31/flask-note:1.3.0
command: ["flask", "db", "upgrade"]


envFrom:
- configMapRef:
name: db-config
- secretRef:
name: maria-secret

# env:
# - name: DB_HOST
# value: maria-service

# - name: DB_NAME
# value: mydb

# - name: DB_USERNAME
# value: hello

# - name: DB_PASSWORD
# value: hello

# - name: DB_PORT
# value: '3306'

# - name: PORT
# value: '5000'


restartPolicy: Never

# env:
# - name: DB_HOST
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : DB_HOST
# - name: DB_NAME
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : DB_NAME
# - name: DB_USERNAME
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: MARIADB_USER
# - name: DB_PASSWORD
# valueFrom:
# secretKeyRef:
# name: maria-secret
# key: MARIADB_PASSWORD
# - name: DB_PORT
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : DB_PORT
# - name: PORT
# valueFrom :
# configMapKeyRef :
# name : db-config
# key : PORT




29 changes: 29 additions & 0 deletions ingress-single.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-ex
annotations:
ingress.kubernetes.io/ssl-redirect: "false"
spec:
ingressClassName: traefik
rules:
- host: "myapps.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: flask-app-service
port:
number: 8081
- host: "myappskhush.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: appservice
port:
number: 80
Loading