简介IngressAn API object that manages external access to the services in a cluster, typically HTTP.Ingress can provide load balancing, SSL termination and name-based virtual hosting.TerminologyNode: A ...
简介Ingress Terminology
What is Ingress? internet
|
[ Ingress ]
--|-----|--
[ Services ] An ingress can be configured to give services externally-reachable URLs, load balance traffic, terminate SSL, and offer name based virtual hosting. An ingress controller is responsible for fulfilling the ingress, usually with a loadbalancer, though it may also configure your edge router or additional frontends to help handle the traffic. Prerequisites Ingress controllers 官网部署方法https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/cloud-generic.yaml 部署ingress-controller[root@elasticsearch01 ingree-nginx]# kubectl create -f mandatory.yaml
namespace/ingress-nginx created
configmap/nginx-configuration created
configmap/tcp-services created
configmap/udp-services created
serviceaccount/nginx-ingress-serviceaccount created
clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created
role.rbac.authorization.k8s.io/nginx-ingress-role created
rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created
clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created
deployment.extensions/nginx-ingress-controller created 报错 排错 [root@elasticsearch01 ingree-nginx]# vim /k8s/kubernetes/cfg/kube-apiserver
[root@elasticsearch01 ingree-nginx]# systemctl restart kube-apiserver.service
[root@elasticsearch01 ingree-nginx]# systemctl status kube-apiserver.service
● kube-apiserver.service - Kubernetes API Server
Loaded: loaded (/usr/lib/systemd/system/kube-apiserver.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-01-07 11:30:07 CST; 7s ago
Docs: https://github.com/kubernetes/kubernetes
Main PID: 12796 (kube-apiserver)
CGroup: /system.slice/kube-apiserver.service
└─12796 /k8s/kubernetes/bin/kube-apiserver --logtostderr=true --v=4 --etcd-servers=https://10.2.8.44:2379,https://10.2.... 检查状态 [root@elasticsearch01 ingree-nginx]# kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/nginx-ingress-controller-565dfd6dff-vj52t 1/1 Running 0 2m36s 部署svc[root@elasticsearch01 ingree-nginx]# kubectl create -f cloud-generic.yaml 测试功能之前dashboard是通过nodeport暴露,现在使用ingress方式,注意ingress后端是https,需要添加如下配置 apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true" 生成ingress-secret证书 [root@elasticsearch01 ingress-nginx]# kubectl -n kube-system create secret tls ingress-secret --key /certs/dashboard.key --cert /certs/dashboard.crt
secret/ingress-secret created 创建ingress服务 [root@elasticsearch01 ~]# cat /k8s/yaml/ingress-nginx/k8s.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kube-system
annotations:
nginx.ingress.kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
tls:
- hosts:
- dashboard.minminmsn.com
secretName: ingress-secret
rules:
- host: dashboard.minminmsn.com
http:
paths:
- path: /
backend:
serviceName: kubernetes-dashboard
servicePort: 443
[root@elasticsearch01 ingree-nginx]# kubectl create -f k8s.yaml
ingress.extensions/dashboard-ingress created [root@elasticsearch01 ingree-nginx]# kubectl get ingress -n ingress-nginx
NAME HOSTS ADDRESS PORTS AGE
dashboard-ingress dashboard.zhidaoauto.com 80 2m51s
[root@elasticsearch01 ingree-nginx]# kubectl describe ingress dashboard-ingress -n ingress-nginx
Name: dashboard-ingress
Namespace: ingress-nginx
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
dashboard.zhidaoauto.com
kubernetes-dashboard:443 (10.254.73.2:8443)
Annotations:
ingress.kubernetes.io/ssl-passthrough: true
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 3m3s nginx-ingress-controller Ingress ingress-nginx/dashboard-ingress
Normal CREATE 3m3s nginx-ingress-controller Ingress ingress-nginx/dashboard-ingress 网页浏览 访问效果如下 补充准入控制器 LimitRanger:此准入控制器将确保所有资源请求不会超过 namespace 的 LimitRange。 |
墨染ART / 2019-01-12
墨染ART / 2019-01-12
Wotchin / 2019-01-12
李政一 / 2019-01-12
李政一 / 2019-01-12