add kubernetes configuration
This commit is contained in:
7
12-deploying-containers/README.md
Normal file
7
12-deploying-containers/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Deploying containers
|
||||||
|
|
||||||
|
So many options!
|
||||||
|
|
||||||
|
- Railway
|
||||||
|
- Docker Swarm
|
||||||
|
- Kubernetes
|
||||||
@ -2,7 +2,7 @@ version: '3.7'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
client-react:
|
client-react:
|
||||||
image: sidpalas/devops-directive-docker-course-client-react-nginx:6
|
image: sidpalas/devops-directive-docker-course-client-react-nginx:5
|
||||||
deploy:
|
deploy:
|
||||||
mode: replicated
|
mode: replicated
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
|||||||
8
12-deploying-containers/kubernetes/Makefile
Normal file
8
12-deploying-containers/kubernetes/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.PHONY: deploy-postgres
|
||||||
|
deploy-postgres:
|
||||||
|
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||||
|
helm install db bitnami/postgresql --set auth.postgresPassword=foobarbaz
|
||||||
|
|
||||||
|
.PHONY: deploy-app
|
||||||
|
deploy-app:
|
||||||
|
kubectl apply -f .
|
||||||
56
12-deploying-containers/kubernetes/api-golang.yml
Normal file
56
12-deploying-containers/kubernetes/api-golang.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: api-golang
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: api-golang
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 8080
|
||||||
|
targetPort: 8080
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: api-golang
|
||||||
|
labels:
|
||||||
|
app: api-golang
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: api-golang
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: api-golang
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: api-golang
|
||||||
|
image: sidpalas/devops-directive-docker-course-api-golang:7
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "8080"
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: database-url
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
protocol: TCP
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /ping
|
||||||
|
port: 8080
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "100Mi"
|
||||||
|
requests:
|
||||||
|
memory: "100Mi"
|
||||||
|
cpu: "50m"
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
privileged: false
|
||||||
|
securityContext:
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
56
12-deploying-containers/kubernetes/api-node.yml
Normal file
56
12-deploying-containers/kubernetes/api-node.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: api-node
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: api-node
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 3000
|
||||||
|
targetPort: 3000
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: api-node
|
||||||
|
labels:
|
||||||
|
app: api-node
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: api-node
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: api-node
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: api-node
|
||||||
|
image: sidpalas/devops-directive-docker-course-api-node:8
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "3000"
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: database-url
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
protocol: TCP
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /ping
|
||||||
|
port: 3000
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "100Mi"
|
||||||
|
requests:
|
||||||
|
memory: "100Mi"
|
||||||
|
cpu: "50m"
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
privileged: false
|
||||||
|
securityContext:
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
11
12-deploying-containers/kubernetes/ingress.yml
Normal file
11
12-deploying-containers/kubernetes/ingress.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: primary
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
defaultBackend:
|
||||||
|
service:
|
||||||
|
name: client-react-nginx
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
37
12-deploying-containers/kubernetes/nginx-kubernetes.conf
Normal file
37
12-deploying-containers/kubernetes/nginx-kubernetes.conf
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
# Kubernetes dns server
|
||||||
|
resolver kube-dns.kube-system.svc.cluster.local valid=5s;
|
||||||
|
|
||||||
|
location /ping {
|
||||||
|
access_log off;
|
||||||
|
add_header 'Content-Type' 'text/plain';
|
||||||
|
return 200 "pong";
|
||||||
|
}
|
||||||
|
location /api/golang/ {
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Server $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
|
set $api_golang_upstream api-golang.default.svc.cluster.local:8080/;
|
||||||
|
proxy_pass http://$api_golang_upstream;
|
||||||
|
}
|
||||||
|
location /api/node/ {
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Server $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
|
set $api_node_upstream api-node.default.svc.cluster.local:3000/;
|
||||||
|
proxy_pass http://$api_node_upstream;
|
||||||
|
}
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
include /etc/nginx/extra-conf.d/*.conf;
|
||||||
|
}
|
||||||
8
12-deploying-containers/kubernetes/secrets.yml
Normal file
8
12-deploying-containers/kubernetes/secrets.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# ⛔️ DONT PUT SECRET FILES IN VCS
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
type: Opaque
|
||||||
|
metadata:
|
||||||
|
name: database-url
|
||||||
|
stringData:
|
||||||
|
DATABASE_URL: postgres://postgres:foobarbaz@db-postgresql:5432/postgres
|
||||||
Reference in New Issue
Block a user