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

Change some code #112

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b6d5530
feat: add metrics and health
nadavsinai-philips Sep 29, 2022
6638870
chore: add database to ignore
nadavsinai-philips Sep 29, 2022
63e66a9
feat: debug setup + logging
nadavsinai-philips Sep 29, 2022
0db4f74
build: docker configuation
nadavsinai-philips Sep 29, 2022
5a1d89a
fix: port binding as per instructions
nadavsinai-philips Sep 29, 2022
18478c2
ci: add docker build and push action
nadavsinai-philips Sep 30, 2022
02a20bb
docs: add screenshots
nadavsinai-philips Sep 30, 2022
bf221cf
feat: k8s manifests
nadavsinai-philips Sep 30, 2022
0d29857
fix: deploy and add screenshot
nadavsinai-philips Sep 30, 2022
233c4f5
feat: helm chart development
nadavsinai-philips Sep 30, 2022
e3d3c4f
feat: argocd resources
nadavsinai-philips Sep 30, 2022
c9b97ff
fix: helm chart
nadavsinai-philips Sep 30, 2022
8f83d50
fix: helm chart
nadavsinai-philips Sep 30, 2022
60bb1d7
fix: helm namespace
nadavsinai-philips Sep 30, 2022
ef0060f
fix: helm service
nadavsinai-philips Sep 30, 2022
73c2637
chore: add screenshots
nadavsinai-philips Sep 30, 2022
599d542
feat: dynamic healthcheck
nadavsinai-philips Sep 30, 2022
e4b0096
feat: use versioned tags
nadavsinai-philips Sep 30, 2022
c452e42
feat: conditionals in helm
nadavsinai-philips Sep 30, 2022
265805e
refactor: move GH actions
nadavsinai-philips Sep 30, 2022
969c399
fix: changes as per code review
nadavsinai-philips Sep 30, 2022
b7dd992
Update values-prod.yaml
nadavsinai-philips Nov 24, 2022
e416b14
Update values-prod.yaml
nadavsinai-philips Nov 24, 2022
4a7e8c5
Update values-staging.yaml
nadavsinai-philips Nov 24, 2022
500780b
fix: return action back to place
nadavsinai-philips Nov 24, 2022
2b44c78
Create azure-update.yml
nadavsinai-philips Dec 6, 2022
f22471c
Update azure-update.yml
nadavsinai-philips Dec 6, 2022
81be89d
Update azure-update.yml
nadavsinai-philips Dec 6, 2022
7a379f9
Merge branch 'main' into work-on-action
nadavsinai-philips Dec 7, 2022
3ea17a4
Merge pull request #1 from nadavsinai-philips/work-on-action
nadavsinai-philips Dec 7, 2022
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
41 changes: 41 additions & 0 deletions .github/workflows/azure-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

name: Kubernetes Artifact Substitue
on:
workflow_dispatch:
inputs:
dockerTag:
description: 'Docker tag'
required: true
default: 'latest'
type: text

jobs:

update_manifests:

runs-on: "ubuntu-latest"
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Substitute artifacts
uses: Azure/k8s-artifact-substitute@v1
with:
# Path to the template manifest files which will be used for deployment.
# possibly this will be values.yaml for a helm template and we will then bake the helm https://github.com/marketplace/actions/helmfile-render
manifests: project/kubernetes
# Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test
images: "nadavsinai/techtrends:${{ event.input.dockerTag }}"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update deplotment to ${{ event.input.dockerTag }}"
committer: DeploymentBot <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: deploy-${{ event.input.dockerTag }}"
delete-branch: true
title: '[Deployment] Update version to ${{ event.input.dockerTag }}"'
48 changes: 48 additions & 0 deletions .github/workflows/techtrends-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "TechTrends - Package with Docker"
on:
push:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
nadavsinai/techtrends
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
push: true
context: "{{defaultContext}}:project"
tags: ${{ steps.meta.outputs.tags }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.myvenv/
__pycache__/
.vagrant/
database.db
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"cwd": "${fileDirname}",
"env": { "DEBUG": "True" },
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
8 changes: 8 additions & 0 deletions project/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.8
WORKDIR /usr/src/app
COPY techtrends/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY techtrends/ .
RUN [ "python", "init_db.py"]
EXPOSE 3111
CMD [ "python", "./app.py" ]
26 changes: 26 additions & 0 deletions project/argocd/argocd-server-nodeport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: argocd-server
app.kubernetes.io/part-of: argocd
name: argocd-server-nodeport
namespace: argocd
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
nodePort: 30007
- name: https
port: 443
protocol: TCP
targetPort: 8080
nodePort: 30008
selector:
app.kubernetes.io/name: argocd-server
sessionAffinity: None
type: NodePort
17 changes: 17 additions & 0 deletions project/argocd/helm-techtrends.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: techtrends-prod
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
helm:
valueFiles:
- values-prod.yaml
path: project/helm
repoURL: https://github.com/nadavsinai-philips/udacity-course-project-techtrends
targetRevision: HEAD
17 changes: 17 additions & 0 deletions project/argocd/helm-techtrends.staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: techtrends-staging
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
helm:
valueFiles:
- values-staging.yaml
path: project/helm
repoURL: https://github.com/nadavsinai-philips/udacity-course-project-techtrends
targetRevision: HEAD
29 changes: 23 additions & 6 deletions project/docker_commands
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
## Docker commands used to build the application
# TODO: insert the docker build command
## Docker commands used to build the application

sudo docker build -t techtrends .

## Docker commands used to run the application
# TODO: insert the docker run command

## Docker commands used to get the application logs
# TODO: insert the docker logs command
sudo docker run -d --rm --name techtrends -p 7111:3111 techtrends

## Docker commands used to get the application logs
sudo docker logs techtrends
## Logs from the container running the TechTrends application
# TODO: paste logs from the Docker container

# TODO: paste logs from the Docker container
````
* Serving Flask app 'app' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
WARNING:_internal - [2022-09-29 20:14:30,235] * Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
INFO:_internal - [2022-09-29 20:14:30,235] * Running on http://172.17.0.2:3111/ (Press CTRL+C to quit)
INFO:_internal - [2022-09-29 20:14:39,662] 192.168.50.1 - - [29/Sep/2022 20:14:39] "GET / HTTP/1.1" 200 -
INFO:_internal - [2022-09-29 20:14:39,674] 192.168.50.1 - - [29/Sep/2022 20:14:39] "GET /static/css/main.css HTTP/1.1" 304 -
INFO:app - [2022-09-29 20:14:42,019] Article 2 retrieved successfully: KubeCon + CloudNativeCon 2021
INFO:_internal - [2022-09-29 20:14:42,022] 192.168.50.1 - - [29/Sep/2022 20:14:42] "GET /2 HTTP/1.1" 200 -
INFO:_internal - [2022-09-29 20:14:42,040] 192.168.50.1 - - [29/Sep/2022 20:14:42] "GET /static/css/main.css HTTP/1.1" 304 -
````
9 changes: 9 additions & 0 deletions project/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
name: "techtrends"
version: 1.0.0
keywords:
- "techtrends"

maintainers:
- name: "Nadav Sinai"
email: "[email protected]"
34 changes: 34 additions & 0 deletions project/helm/templates/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: techtrends
name: techtrends
namespace: {{ .Values.namespace }}
spec:
replicas: {{.Values.replicaCount}}
selector:
matchLabels:
app: techtrends
strategy: {}
template:
metadata:
labels:
app: techtrends
spec:
containers:
- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
name: techtrends
ports:
- containerPort: {{.Values.containerPort}}
resources:
{{- toYaml .Values.resources | nindent 12 }}
livenessProbe:
httpGet:
path: {{.Values.livenessProbe.path | quote}}
port: {{ .Values.livenessProbe.port }}
readinessProbe:
httpGet:
path: {{.Values.readinessProbe.path | quote }}
port: {{ .Values.readinessProbe.port }}
status: {}
6 changes: 6 additions & 0 deletions project/helm/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
spec: {}
status: {}
23 changes: 23 additions & 0 deletions project/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: techtrends
name: techtrends
namespace: {{ .Values.namespace }}
spec:
ports:
- name: techtrends-svc
port: {{ .Values.service.port }}
protocol: {{.Values.service.protocol}}
{{ if .Values.service.targetPort }}
targetPort: {{.Values.service.targetPort}}
{{ else }}
targetPort: {{.Values.service.port}}
{{ end }}
selector:
app: techtrends
type: {{.Values.service.type}}
status:
loadBalancer: {}
14 changes: 14 additions & 0 deletions project/helm/values-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace: prod
service:
port: 7111
type: LoadBalancer
replicaCount: 3
image:
pullPolicy: Always
resources:
requests:
memory: "128Mi"
cpu: "350m"
limits:
memory: "256Mi"
cpu: "500m"
11 changes: 11 additions & 0 deletions project/helm/values-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace: staging
service:
port: 5111
replicaCount: 2
resources:
requests:
memory: "90Mi"
cpu: "300m"
limits:
memory: "128Mi"
cpu: "500m"
25 changes: 25 additions & 0 deletions project/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace: sandbox
service:
port: 4111
targetPort: 3111
protocol: TCP
type: ClusterIP
image:
repository: nadavsinai/techtrends
tag: latest
pullPolicy: IfNotPresent
replicaCount: 1
containerPort: 3111
livenessProbe:
path: /healthz
port: 3111
readinessProbe:
path: /healthz
port: 3111
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
39 changes: 39 additions & 0 deletions project/kubernetes/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: techtrends
name: techtrends
namespace: sandbox
spec:
replicas: 1
selector:
matchLabels:
app: techtrends
strategy: {}
template:
metadata:
labels:
app: techtrends
spec:
containers:
- image: nadavsinai/techtrends:latest
name: techtrends
ports:
- containerPort: 3111
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /healthz
port: 3111
readinessProbe:
httpGet:
path: /healthz
port: 3111
status: {}
Loading