http,https端口
1 | apiVersion: extensions/v1beta1 |
执行:
1 | kubectl apply -f ingress-kubernetes-dashboard.yaml |
具体说明
- kubernetes.io/ingress.class: “nginx”:Inginx Ingress Controller 根据该注解自动发现 Ingress;
- nginx.ingress.kubernetes.io/backend-protocol: Controller 向后端 Service 转发时使用 HTTPS 协议
- secretName: kube-dasboard-ssl:https 证书 Secret;
- host: ks.hongda.com:对外访问的域名;
- serviceName: kubernetes-dashboard:集群对外暴露的 Service 名称;
- servicePort: 443:service 监听的端口;
注意:创建的 Ingress 必须要和对外暴露的 Service 在同一命名空间下!
ConfigMap暴露TCP端口
Ingress 不支持TCP 和 UDP 服务,可以通过 Ingress controller 来实现
默认的yaml中已经设置:
1 | spec: |
通过 tcp-services-configmap.yaml 设置映射tcp, 通过 udp-services-configmap.yaml 映射udp
- tcp-services-configmap.yaml
1
2
3
4
5
6
7
8apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
2181: "kafka/kafka-zookeeper:2181"
9092: "kafka/kafka:9092" - udp-services-configmap.yaml
1
2
3
4
5
6
7apiVersion: v1
kind: ConfigMap
metadata:
name: udp-services
namespace: ingress-nginx
data:
53: "kube-system/kube-dns:53"Ingress服务公开端口
更新Ingress安装文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
- name: https
port: 443
targetPort: 443
protocol: TCP
- name: proxied-tcp-9000
port: 9000
targetPort: 9000
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
更新:
1 | helm upgrade nginx-ingress stable/nginx-ingress \ |
查看:
1 | [root@master home]# netstat -ano |grep 2181 |
这样暴露以后就可以直接调用zk,连接地址:
1 | zk.hongda.com:2181 |