> For the complete documentation index, see [llms.txt](https://fufu.gitbook.io/kk8s/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fufu.gitbook.io/kk8s/task-memory/25.ingress-exposing-tcp.md).

# 需要額外的 非http 連線

在Ingress資源應用上，先前僅面向HTTP、HTTPS網站標準服務。\
現在已經可以針對TCP、UDP服務的應用上，透過ingress資源開放存取。

## TCP\UDP exposing

ingress是透過config-map資源取得TCP、UDP服務開放的對應，如官網範例

### TCP

指定`tcp:9000`對應內部`namespace:default`/`example-go:8080`

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
  9000: "default/example-go:8080"
```

### UDP

指定`udp:53`對應內部`kube-dns:53`服務

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: udp-services
  namespace: ingress-nginx
data:
  53: "kube-system/kube-dns:53"
```

### ingress service

下列Service範例，設定三種服務入口

* `http:80`
* `https:443`
* `proxied-tcp-9000:9000`，此入口會對應到 **config-map** 的`tcp-service.data.9000`

```yaml
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: 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
```

以上，簡略說明`ingress`除了常見的 http、https 服務之外，也可針對其他TCP、UDP開放入口服務。
