chore: add k8s ingress router(traefik) and health check

health check help us if pod not ready, dont add into load balance list
pull/90/head
moonrailgun 2 years ago
parent 43cc8e34a3
commit 1856be3539

@ -6,7 +6,13 @@ Its doc will tell you how to deploy `Tailchat` in kubeneters.
kubectl apply -f namespace.yml -f pv.yml -f mongo.yml -f minio.yml -f redis.yml -f tailchat.yml
```
if you wanna delete all resource, just replace `apply` to `delete`.
### Delete
if you wanna delete all resource, just delete namespace.
```bash
kubectl delete -f namespace.yml
```
## Setup one by one
@ -63,3 +69,44 @@ kubectl run -it --rm test-pod --image=busybox --restart=Never
```
wget -q -O - http://<tailchat-cluster-ip>:11000/health
```
## Router and Load Balance
For example, we use traefik.
### Install Traefik provider
```bash
helm repo add traefik https://helm.traefik.io/traefik
helm install traefik traefik/traefik -n tailchat
```
### Apply Ingress Config
```bash
kubectl apply -f ingress.yml
```
### Check Status
```bash
kubectl get services -n tailchat
```
If every is ok, its should be like this:
![](./images/traefik-svc.png)
### Set DNS record
```bash
sudo vim /etc/hosts
```
append this record:
```
127.0.0.1 tailchat.internal.com
```
Now you can open browser and view `http://tailchat.internal.com` to open tailchat in k8s.

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
namespace: tailchat
annotations:
traefik.ingress.kubernetes.io/routing-type: edge
spec:
rules:
- host: tailchat.internal.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: tailchat-service
port:
number: 11000

@ -37,6 +37,22 @@ spec:
value: com.msgbyte.tailchat
ports:
- containerPort: 11000
livenessProbe:
httpGet:
path: /health
port: 11000
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 2
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 11000
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 2
failureThreshold: 3
resources:
requests:
cpu: 50m

Loading…
Cancel
Save