K8s traefik (ingess) Publishing Service-practice
Traefik (ingess) Publishing Service of K8s
The previous article describes the installation and deployment of traefik as an ingress service based on K8s cluster, and briefly demonstrates the publishing service. This article will describe in detail how to publish the business service in conjunction with traefik.
Installation and deployment reference:
Https://blog.51cto.com/michaelkang/2429929
The version introduces traefik:v1.7k8s:v1.15.1 Rapid deployment traefik
If your K8s cluster has been deployed and you want to deploy traefik quickly, execute the command as follows:
Kubectl create-f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yamlkubectl create-f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml executes successfully. In the browser data, you can see the management page of traefik at the IP address of a node node: port 8080. Start writing a business yaml file in practice
If you are not familiar with yaml, look here: https://blog.51cto.com/michaelkang/2429745
-# configure deploymentkind: DeploymentapiVersion: extensions/v1beta1metadata:# set dm name name: dm-pttest# add tag pttest labels: app: pttestspec:# declare through replicas the number of pod is 2 replicas: select controlled pod selector: matchLabels: app: pttest# define pod template: metadata:# in template and label pod app=pttest labels: app: pttestspec: Containers:# declares the container name Note that it is not a pod name, but the pod name should be defined in metadata-name: myapp image: ikubernetes/myapp:v1 ports:-containerPort: 80 Murmuri # Service configuration apiVersion: Service declare a Service resource object kind: Servicemetadata:#pod name name: svcpttest labels: app: pttest annotations:# check the error rate returned by the back-end service, which is greater than% 50 Kick out the cluster traefik.backend.circuitbreaker: "NetworkErrorRatio () > 0.5" spec: ports:-name: http port: 80 selector: app: pttest---# configuration ingressapiVersion: extensions/v1beta1kind: Ingressmetadata: name: myapp-traefik-ingress annotations: kubernetes.io/ingress.class: traefikspec: rules:-host: pttest.pt.com http: paths:-path: / # specify the backend service backend: ServiceName: svcpttest servicePort: 80 Verification Service # View Service [root@kubm-02 traefik] # kubectl get svc-o wideNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGE SELECTORsvcpttest ClusterIP 10.245.148.114 80/TCP 2m12s app=pttest