kubernetes Ingess is 2 parts, service Ingress Ingress Controller and composition, is commonly used in Ingress Controller ingress-nginx, principle is:
Ingress Controller dynamically changes cluster-aware rules Ingress, and then read the dynamically generated Nginx configuration file, and finally injected into the pod running nginx, and then automatically reload, take effect.
With kubernetes Ingress layer 7 because it is scheduled to be unloaded directly https session, the rear end of the pod agent may be used directly plaintext http protocol.
The Service NodePort have to type, layer 4 is too scheduling, can not do this, but https is now a trend, so kubernetes Foreign Service was exposed when we still have to choose Ingress.
Here we have to look at the Ingress Deployment:
Schematic
1. Create a container and a back-end service
First, create a folder special place Igress have to get yaml file, mkdir Ingress
vim myapp.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp-ding
image: ikubernetes/myapp:v2
---
apiVersion: v1
kind: Service
metadata:
name: myapp
#等会ingress就靠这个来匹配
spec:
selector:
app: myapp
type: ClusterIP
ports:
- port: 80
targetPort: 80
2. Configure the ingress configuration file
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-ding
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: www.yang.com
#虚拟机主机域名
http:
paths:
- path:
backend:
serviceName: myapp
#代理后端的service 的name
servicePort: 80
#后端service的端口