From 28028922315b664e16986c4552296030014837f3 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Sun, 23 Dec 2018 22:11:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0nginx-ingress=20manifests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nginx-ingress/nginx-ingress-svc.yaml | 44 +++++++++++++++++++ .../ingress/nginx-ingress/nginx-ingress.yaml | 8 ++++ .../nginx-ingress/tcp-services-configmap.yaml | 12 +++++ .../nginx-ingress/udp-services-configmap.yaml | 11 +++++ 4 files changed, 75 insertions(+) create mode 100644 manifests/ingress/nginx-ingress/nginx-ingress-svc.yaml create mode 100644 manifests/ingress/nginx-ingress/tcp-services-configmap.yaml create mode 100644 manifests/ingress/nginx-ingress/udp-services-configmap.yaml diff --git a/manifests/ingress/nginx-ingress/nginx-ingress-svc.yaml b/manifests/ingress/nginx-ingress/nginx-ingress-svc.yaml new file mode 100644 index 0000000..6acd9bc --- /dev/null +++ b/manifests/ingress/nginx-ingress/nginx-ingress-svc.yaml @@ -0,0 +1,44 @@ +apiVersion: 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: NodePort + ports: + - name: http + port: 80 + targetPort: 80 + protocol: TCP + # 集群hosts文件中设置的 NODE_PORT_RANGE 作为 NodePort的可用范围 + # 从默认20000~40000之间选一个可用端口,让ingress-controller暴露给外部的访问 + nodePort: 23456 + - name: https + port: 443 + targetPort: 443 + protocol: TCP + # 集群hosts文件中设置的 NODE_PORT_RANGE 作为 NodePort的可用范围 + # 从默认20000~40000之间选一个可用端口,让ingress-controller暴露https + nodePort: 23457 + - name: test-mysql + port: 3306 + targetPort: 3306 + protocol: TCP + nodePort: 23306 + - name: test-mysql-read + port: 3307 + targetPort: 3307 + protocol: TCP + nodePort: 23307 + - name: test-dns + port: 53 + targetPort: 53 + protocol: UDP + nodePort: 20053 + selector: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + diff --git a/manifests/ingress/nginx-ingress/nginx-ingress.yaml b/manifests/ingress/nginx-ingress/nginx-ingress.yaml index d5b82c6..48bb0fc 100644 --- a/manifests/ingress/nginx-ingress/nginx-ingress.yaml +++ b/manifests/ingress/nginx-ingress/nginx-ingress.yaml @@ -240,6 +240,14 @@ spec: containerPort: 80 - name: https containerPort: 443 + # hostPort可以直接使用node节点的网络端口暴露服务 + #- name: mysql + # containerPort: 3306 + # hostPort: 3306 + #- name: dns + # containerPort: 53 + # hostPort: 53 + # protocol: UDP livenessProbe: failureThreshold: 3 httpGet: diff --git a/manifests/ingress/nginx-ingress/tcp-services-configmap.yaml b/manifests/ingress/nginx-ingress/tcp-services-configmap.yaml new file mode 100644 index 0000000..3a97132 --- /dev/null +++ b/manifests/ingress/nginx-ingress/tcp-services-configmap.yaml @@ -0,0 +1,12 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: tcp-services + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +data: + 3306: "mariadb/mydb-mariadb:3306" + 3307: "mariadb/mydb-mariadb-slave:3306" + diff --git a/manifests/ingress/nginx-ingress/udp-services-configmap.yaml b/manifests/ingress/nginx-ingress/udp-services-configmap.yaml new file mode 100644 index 0000000..d75383f --- /dev/null +++ b/manifests/ingress/nginx-ingress/udp-services-configmap.yaml @@ -0,0 +1,11 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: udp-services + namespace: ingress-nginx + labels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx +data: + 53: "kube-system/kube-dns:53" +