...
 
Commits (37)
......@@ -60,7 +60,7 @@ The entrypoint of the API is [`app.py`](backend/app.py).
### [`/api/v1/fortune`](backend/app.py)
Returns a fortune cookie read from a file on a volume. This file is generated by a separate container. See `manifests/backend/deployment-volume.yaml`
Returns a fortune cookie read from a file on a volume. This file is generated by a separate container. See `manifests/backend/solutions/deploy-volume.yml`
### [`/api/v1/metadata`](backend/metadata.py)
......
......@@ -9,6 +9,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /app
CMD ["python3", "app.py"]
ENV TIMBER_LISTEN_PORT=8080
EXPOSE 8080
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
......@@ -76,5 +76,6 @@ if configuration.readiness_probe_enabled:
return 'I am doing well!'
app.run(host='0.0.0.0', port=8080, debug=True)
app.run(host='0.0.0.0', port=configuration.listen_port, debug=True)
print('Hello, this is backend!') # So we can see it in the `kubectl` logs.
......@@ -16,10 +16,9 @@ redis_host = os.getenv('TIMBER_REDIS_HOST', 'redis')
# The possible options are `inmemory`, `storage`, `redis`
state = os.getenv('TIMBER_STATE', 'inmemory')
# Version
# This will be shown on the homepage.
version = os.getenv('TIMBER_VERSION', '1.0')
version = os.getenv('TIMBER_VERSION', '1.3')
liveness_probe_text = 'enabled and reachable at `/probe/liveness`'
readiness_probe_text = 'enabled and reachable at `/probe/readiness`'
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: timber-backend
spec:
replicas: 1
template:
spec:
containers:
- name: timber-backend
image: eu.gcr.io/container-solutions-workshops/timber/backend
ports:
- containerPort: 8080
resources:
- deployment.yaml
- service.yaml
commonLabels:
app: timber-hamish
---
apiVersion: v1
kind: Service
metadata:
name: timber-backend
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
apiVersion: apps/v1
kind: Deployment
metadata:
name: timber-frontend
spec:
replicas: 1
template:
spec:
containers:
- name: timber-frontend
image: eu.gcr.io/container-solutions-workshops/timber/frontend
ports:
- containerPort: 8080
env:
- {name: TIMBER_BACKEND_API_URL, value: "http://$(TIMBER_BACKEND_API_URL):8080"}
resources:
- deployment.yaml
- service.yaml
commonLabels:
app: timber-frontend
vars:
- name: TIMBER_BACKEND_API_URL
objref:
kind: Service
name: timber-backend
apiVersion: v1
apiVersion: v1
kind: Service
metadata:
name: timber-frontend
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
bases:
- ./backend/
- ./frontend/
---
apiVersion: v1
kind: ConfigMap
metadata:
name: timber-backend-config
data:
READINESS_PROBE: "enabled"
LIVENESS_PROBE: "enabled"
\ No newline at end of file
......@@ -17,6 +17,6 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: backend-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /backend/*
backend:
serviceName: timber-backend
servicePort: 8080
\ No newline at end of file
......@@ -2,9 +2,8 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: fortune-claim
annotations:
volume.beta.kubernetes.io/storage-class: "standard"
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
......
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: timber-backend
labels:
app: timber-backend
spec:
replicas: 1
selector:
matchLabels:
app: timber-backend
template:
metadata:
labels:
app: timber-backend
spec:
containers:
- name: timber-backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
- name: TIMBER_READINESS_PROBE_ENABLED
valueFrom:
configMapKeyRef:
name: timber-backend-config
key: READINESS_PROBE
- name: TIMBER_LIVENESS_PROBE_ENABLED
valueFrom:
configMapKeyRef:
name: timber-backend-config
key: LIVENESS_PROBE
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: timber-backend
labels:
app: timber-backend
spec:
replicas: 1
selector:
matchLabels:
app: timber-backend
template:
metadata:
labels:
app: timber-backend
spec:
containers:
- name: timber-backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
\ No newline at end of file
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
......@@ -17,11 +17,11 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
imagePullPolicy: Always
volumeMounts:
- name: fortune
mountPath: /data/fortune
mountPath: /data/fortune
ports:
- containerPort: 8080
env:
......@@ -39,8 +39,8 @@ spec:
image: luksa/fortune
volumeMounts:
- name: fortune
mountPath: /var/htdocs
mountPath: /var/htdocs
volumes:
- name: fortune
- name: fortune
persistentVolumeClaim:
claimName: fortune-claim
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
......@@ -18,10 +18,10 @@ spec:
volumes:
- name: "secret"
secret:
secretName: mysecret
secretName: mysecret
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......@@ -29,7 +29,7 @@ spec:
ports:
- containerPort: 8080
volumeMounts:
- mountPath: "/tmp/secret"
- mountPath: "/tmp/secret"
name: "secret"
readinessProbe:
httpGet:
......
......@@ -17,11 +17,11 @@ spec:
spec:
containers:
- name: timber-backend
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
imagePullPolicy: Always
volumeMounts:
- name: fortune
mountPath: /data/fortune
mountPath: /data/fortune
ports:
- containerPort: 8080
env:
......@@ -39,7 +39,7 @@ spec:
image: luksa/fortune
volumeMounts:
- name: fortune
mountPath: /var/htdocs
mountPath: /var/htdocs
volumes:
- name: fortune
- name: fortune
emptyDir: {}
......@@ -10,7 +10,7 @@ spec:
- port: 8080
targetPort: 8080
nodePort: 31000
name: backend
name: backend
selector:
app: timber-backend
type: NodePort
apiVersion: apps/v1
kind: Deployment
metadata:
name: broken-timber
labels:
app: broken-timber
spec:
replicas: 0
selector:
matchLabels:
app: broken-timber
template:
metadata:
labels:
app: broken-timber
tier: backend
spec:
containers:
- name: broken-timber
image: eu.gcr.io/container-solutions-workshops/timber/backend:3.14159
ports:
- containerPort: 8080
env:
- name: TIMBER_READINESS_PROBE_ENABLED
value: "enabled"
readinessProbe:
httpGet:
path: /neverready
port: 8080
scheme: HTTP
initialDelaySeconds: 5
timeoutSeconds: 5
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: broken-timber-svc
spec:
type: ClusterIP
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
tier: frontend
\ No newline at end of file
......@@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: timber-debugging
image: registry.gitlab.com/containersolutions/timber/backend
image: eu.gcr.io/container-solutions-workshops/timber/backend:v1.0
ports:
- containerPort: 8080
env:
......
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: graphite
name: graphite
spec:
replicas: 1
selector:
matchLabels:
run: graphite
strategy: {}
template:
metadata:
labels:
run: graphite
spec:
containers:
- image: graphiteapp/graphite-statsd
name: graphite
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 8125
name: statsd
protocol: UDP
resources: {}
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
labels:
run: graphite
name: graphite
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: statsd
port: 8125
protocol: UDP
targetPort: 8125
selector:
run: graphite
type: NodePort
\ No newline at end of file
......@@ -17,6 +17,6 @@ spec:
spec:
containers:
- name: timber-debugging
image: registry.gitlab.com/containersolutions/timber:non-existing-image
image: eu.gcr.io/container-solutions-workshops/timber:non-existing-image
ports:
- containerPort: 8080
......@@ -17,8 +17,15 @@ spec:
spec:
containers:
- name: timber-frontend
image: registry.gitlab.com/containersolutions/timber/frontend
image: eu.gcr.io/container-solutions-workshops/timber/frontend:v1.0
ports:
- containerPort: 8080
env:
- {name: TIMBER_BACKEND_API_URL, value: "http://timber-backend:8080"}
readinessProbe:
httpGet:
path: /
port: 8080
scheme: HTTP
initialDelaySeconds: 10
timeoutSeconds: 2
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: frontend-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: timber-frontend
servicePort: 8080
\ No newline at end of file
......@@ -12,4 +12,4 @@ spec:
targetPort: 8080
selector:
app: timber-frontend
type: LoadBalancer
type: LoadBalancer
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-fanout-ingress-canary
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "30"
spec:
rules:
- host: canary.u1.training.csol.cloud
http:
paths:
- path: /*
backend:
serviceName: timber-frontend-v2
servicePort: 8080
\ No newline at end of file
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gke-ingress
name: nginx-fanout-ingress
spec:
rules:
- http:
- host: timber.u1.training.csol.cloud
http:
paths:
- path: /
- path: /*
backend:
serviceName: timber-frontend
servicePort: 8080
- path: /backend/*
- path: /api
backend:
serviceName: timber-backend
servicePort: 8080
servicePort: 8080
\ No newline at end of file
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-virtual-host-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: front.u1.training.csol.cloud
http:
paths:
- backend:
serviceName: timber-frontend
servicePort: 8080
- host: back.u1.training.csol.cloud
http:
paths:
- backend:
serviceName: timber-backend
servicePort: 8080
\ No newline at end of file
......@@ -4,5 +4,5 @@ metadata:
name: single-service-ingress
spec:
backend:
serviceName: timber-backend
servicePort: 8080
serviceName: timber-frontend
servicePort: 8080
\ No newline at end of file
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: backend-stop-ingress
namespace: user1
name: backend-block-ingress
namespace: user1
spec:
podSelector:
matchLabels:
......
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: frontend-stop-egress
namespace: user1
name: frontend-block-egress
namespace: user1
spec:
podSelector:
matchLabels:
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: stress-demo
labels:
app: stress-demo
spec:
replicas: 2
selector:
matchLabels:
app: stress-demo
template:
metadata:
labels:
app: stress-demo
spec:
containers:
- name: stress
image: progrium/stress:latest
command: ["/usr/bin/stress"]
args: ["--cpu", "5", "--timeout", "600s"]
resources:
requests:
cpu: "100m"
memory: "100Mi"
limits:
cpu: "200m"
memory: "200Mi"
\ No newline at end of file
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: timber-debugging
name: stress-demo
labels:
app: timber-debugging
app: stress-demo
spec:
replicas: 1
replicas: 2
selector:
matchLabels:
app: timber-debugging
app: stress-demo
template:
metadata:
labels:
app: timber-debugging
app: stress-demo
spec:
containers:
- name: timber-debugging
image: registry.gitlab.com/containersolutions/api
ports:
- containerPort: 8080
resources:
requests:
memory: "128Gi"
cpu: "10"
- name: stress
image: progrium/stress:latest
command: ["/usr/bin/stress"]
args: ["--cpu", "5", "--timeout", "600s"]
\ No newline at end of file
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: stress-demo-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: stress-demo
minReplicas: 1
maxReplicas: 6
targetCPUUtilizationPercentage: 33
apiVersion: v1
kind: ResourceQuota
metadata:
name: mem-cpu-demo
spec:
hard:
requests.cpu: "1500m"
requests.memory: "750Mi"
limits.cpu: "2000m"
limits.memory: "1000Mi"
pods: "6"
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
labels:
app: quota-demo
name: quota-demo
spec:
ports:
- port: 8080
targetPort: 8080
name: backend
selector:
app: quota-demo
type: NodePort