diff --git a/docker/simple/k8s/README.md b/docker/simple/k8s/README.md index 597b65fb..f67e96cd 100644 --- a/docker/simple/k8s/README.md +++ b/docker/simple/k8s/README.md @@ -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://: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. diff --git a/docker/simple/k8s/images/traefik-svc.png b/docker/simple/k8s/images/traefik-svc.png new file mode 100644 index 00000000..13b79e62 Binary files /dev/null and b/docker/simple/k8s/images/traefik-svc.png differ diff --git a/docker/simple/k8s/ingress.yml b/docker/simple/k8s/ingress.yml new file mode 100644 index 00000000..0c608e82 --- /dev/null +++ b/docker/simple/k8s/ingress.yml @@ -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 diff --git a/docker/simple/k8s/tailchat.yml b/docker/simple/k8s/tailchat.yml index 836be947..f35c8b77 100644 --- a/docker/simple/k8s/tailchat.yml +++ b/docker/simple/k8s/tailchat.yml @@ -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