Skip to content

Commit 6007b29

Browse files
author
Ted Spinks
committed
Initial creation of 3 microservices
1 parent ff94c0f commit 6007b29

File tree

115 files changed

+3049
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3049
-3
lines changed

Diff for: .gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
.eggs
2-
.pytest_cache/
3-
minitwit.egg-info
1+
# macOS custom attributes file
2+
.DS_Store
3+
4+
# Codefresh CLI log
5+
**/venonalog.json

Diff for: Dockerfile renamed to buslog/Dockerfile

File renamed without changes.

Diff for: MANIFEST.in renamed to buslog/MANIFEST.in

File renamed without changes.

Diff for: README.MD renamed to buslog/README.MD

Diff for: README.rst renamed to buslog/README.rst

Diff for: buslog/chart/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: flaskr-buslogic
4+
version: 0.0.2
5+
appVersion: 268b6f1

Diff for: buslog/chart/templates/NOTES.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{{- if contains "NodePort" .Values.service.type }}
3+
Get the application URL by running these commands:
4+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
5+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
6+
echo http://$NODE_IP:$NODE_PORT/login
7+
{{- else if contains "LoadBalancer" .Values.service.type }}
8+
Get the application URL by running these commands:
9+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
10+
You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}'
11+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
12+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
13+
{{- else }}
14+
http://{{ .Release.Name }}.{{ .Values.basedomain }} to access your application
15+
{{- end }}

Diff for: buslog/chart/templates/_helpers.tpl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}

Diff for: buslog/chart/templates/deployment.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "fullname" . }}
5+
labels:
6+
draft: {{ default "draft-app" .Values.draft }}
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
app: {{ template "fullname" . }}
9+
spec:
10+
replicas: {{ .Values.replicaCount }}
11+
selector:
12+
matchLabels:
13+
app: {{ template "fullname" . }}
14+
template:
15+
metadata:
16+
annotations:
17+
buildID: "{{ .Values.buildID }}"
18+
labels:
19+
draft: {{ default "draft-app" .Values.draft }}
20+
app: {{ template "fullname" . }}
21+
spec:
22+
containers:
23+
- name: {{ .Chart.Name }}
24+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
25+
imagePullPolicy: {{ .Values.image.pullPolicy }}
26+
ports:
27+
- containerPort: {{ .Values.service.internalPort }}
28+
resources:
29+
{{ toYaml .Values.resources | indent 12 }}

Diff for: buslog/chart/templates/ingress.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: extensions/v1beta1
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "fullname" . }}
6+
labels:
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
spec:
9+
rules:
10+
- host: {{ .Release.Name }}.{{ .Values.basedomain }}
11+
http:
12+
paths:
13+
- path: /
14+
backend:
15+
serviceName: {{ template "fullname" . }}
16+
servicePort: {{ .Values.service.externalPort }}
17+
{{- end -}}

Diff for: buslog/chart/templates/service.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: "{{ template "name" . }}"
7+
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
app.kubernetes.io/managed-by: "{{ .Release.Service }}"
9+
app.kubernetes.io/instance: "{{ .Release.Name }}"
10+
spec:
11+
type: {{ .Values.service.type }}
12+
ports:
13+
- port: {{ .Values.service.externalPort }}
14+
targetPort: {{ .Values.service.internalPort }}
15+
protocol: TCP
16+
name: {{ .Values.service.name }}
17+
selector:
18+
app: {{ template "fullname" . }}

Diff for: buslog/chart/values-prod.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Values for deploying to the Prod environment
2+
# More replicas compared to QA
3+
replicaCount: 2
4+
resources:
5+
limits:
6+
cpu: 400m
7+
memory: 512Mi
8+
requests:
9+
cpu: 200m
10+
memory: 256Mi
11+
ingress:
12+
enabled: false

Diff for: buslog/chart/values-qa.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Values for deploying to the QA environment
2+
# Increased resource requests+limits compared to Test
3+
replicaCount: 1
4+
resources:
5+
limits:
6+
cpu: 400m
7+
memory: 512Mi
8+
requests:
9+
cpu: 200m
10+
memory: 256Mi
11+
ingress:
12+
enabled: false

Diff for: buslog/chart/values-test.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Values for deploying to the Test environment
2+
# Increased resource limits compared to default values.yaml
3+
replicaCount: 1
4+
resources:
5+
limits:
6+
cpu: 200m
7+
memory: 256Mi
8+
requests:
9+
cpu: 100m
10+
memory: 128Mi
11+
ingress:
12+
enabled: false

Diff for: buslog/chart/values.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Default values for Flaskr deployments
2+
replicaCount: 1
3+
image:
4+
pullPolicy: IfNotPresent
5+
repository: 336151728602.dkr.ecr.us-east-1.amazonaws.com/flaskr
6+
tag: main-268b6f1
7+
service:
8+
name: flaskr
9+
type: LoadBalancer
10+
externalPort: 80
11+
internalPort: 5000
12+
resources:
13+
limits:
14+
cpu: 100m
15+
memory: 128Mi
16+
requests:
17+
cpu: 100m
18+
memory: 128Mi
19+
ingress:
20+
enabled: false
File renamed without changes.
File renamed without changes.

Diff for: flaskr/auth.py renamed to buslog/flaskr/auth.py

File renamed without changes.

Diff for: flaskr/blog.py renamed to buslog/flaskr/blog.py

File renamed without changes.

Diff for: flaskr/db.py renamed to buslog/flaskr/db.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: setup.cfg renamed to buslog/setup.cfg

File renamed without changes.

Diff for: setup.py renamed to buslog/setup.py

File renamed without changes.
File renamed without changes.

Diff for: tests/data.sql renamed to buslog/tests/data.sql

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: ctrlr/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM python:3.8.2-alpine3.11
2+
3+
LABEL cf_account="salesdemo" \
4+
source="https://github.com/codefresh-contrib/salesdemo-flaskr"
5+
6+
ENV FLASK_APP=flaskr
7+
ENV FLASK_ENV=development
8+
9+
COPY . /app
10+
11+
WORKDIR /app
12+
13+
RUN pip install --editable .
14+
15+
RUN flask init-db
16+
17+
# Unit tests
18+
# RUN pip install pytest && pytest
19+
20+
EXPOSE 5000
21+
22+
CMD [ "flask", "run", "--host=0.0.0.0" ]

Diff for: ctrlr/MANIFEST.in

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include LICENSE
2+
include flaskr/schema.sql
3+
graft flaskr/static
4+
graft flaskr/templates
5+
graft tests
6+
global-exclude *.pyc

Diff for: ctrlr/README.MD

+23

Diff for: ctrlr/README.rst

+77

Diff for: ctrlr/chart/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: flaskr-ctrlr
4+
version: 0.0.2
5+
appVersion: 268b6f1

Diff for: ctrlr/chart/templates/NOTES.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{{- if contains "NodePort" .Values.service.type }}
3+
Get the application URL by running these commands:
4+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
5+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
6+
echo http://$NODE_IP:$NODE_PORT/login
7+
{{- else if contains "LoadBalancer" .Values.service.type }}
8+
Get the application URL by running these commands:
9+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
10+
You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}'
11+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
12+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
13+
{{- else }}
14+
http://{{ .Release.Name }}.{{ .Values.basedomain }} to access your application
15+
{{- end }}

Diff for: ctrlr/chart/templates/_helpers.tpl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}

Diff for: ctrlr/chart/templates/deployment.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "fullname" . }}
5+
labels:
6+
draft: {{ default "draft-app" .Values.draft }}
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
app: {{ template "fullname" . }}
9+
spec:
10+
replicas: {{ .Values.replicaCount }}
11+
selector:
12+
matchLabels:
13+
app: {{ template "fullname" . }}
14+
template:
15+
metadata:
16+
annotations:
17+
buildID: "{{ .Values.buildID }}"
18+
labels:
19+
draft: {{ default "draft-app" .Values.draft }}
20+
app: {{ template "fullname" . }}
21+
spec:
22+
containers:
23+
- name: {{ .Chart.Name }}
24+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
25+
imagePullPolicy: {{ .Values.image.pullPolicy }}
26+
ports:
27+
- containerPort: {{ .Values.service.internalPort }}
28+
resources:
29+
{{ toYaml .Values.resources | indent 12 }}

Diff for: ctrlr/chart/templates/ingress.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: extensions/v1beta1
3+
kind: Ingress
4+
metadata:
5+
name: {{ template "fullname" . }}
6+
labels:
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
spec:
9+
rules:
10+
- host: {{ .Release.Name }}.{{ .Values.basedomain }}
11+
http:
12+
paths:
13+
- path: /
14+
backend:
15+
serviceName: {{ template "fullname" . }}
16+
servicePort: {{ .Values.service.externalPort }}
17+
{{- end -}}

0 commit comments

Comments
 (0)