简体   繁体   English

Kubernetes - docker 驱动程序上的入口 - minikube 1.16

[英]Kubernetes - Ingress on docker driver - minikube 1.16

I'm trying to setup ingress on docker driver for minikube 1.16 on windows 10 home (build 19042).我正在尝试在 windows 10 home(build 19042)上为 minikube 1.16 的 docker 驱动程序设置入口。 Ingress on docker driver wasn't supported before but it is now on minikube 1.16: https://github.com/kubernetes/minikube/pull/9761以前不支持 docker 驱动程序的入口,但它现在在 minikube 1.16 上: https://github.com/kubernetes/minikube/pull/9761

I've been trying something by myself but i got ERR_CONNECTION_REFUSED when connecting to the ingress at 127.0.0.1 OR kubernetes.docker.internal我一直在自己尝试一些事情,但是当连接到127.0.0.1kubernetes.docker.internal的入口时,我得到了ERR_CONNECTION_REFUSED

Steps:脚步:

  1. minikube start minikube 启动
  2. minikube addons enable ingress minikube 插件启用入口
  3. create deployment创建部署
  4. create ClusterIP创建集群IP
  5. Ingress config入口配置

Here is my configuration:这是我的配置:

#cluster ip service
apiVersion: v1
kind: Service
metadata:
  name: client-cluster-ip-service
spec:
  type: ClusterIP
  selector:
    component: web
  ports:
  - port: 3000
    targetPort: 3000

# not posting deployment code because it's not relevant, but there is a deployment with selector 'component:web' and it's exposing port 3000.


#ingress service
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: kubernetes.docker.internal
      http:
        paths:
          - path: /?(.*)
            pathType: Prefix
            backend:
              service:
                name: client-cluster-ip-service
                port:
                  number: 3000

I have dns redirect in hosts file.我在主机文件中有 dns 重定向。

I've also tried "minikube tunnel" on another terminal but no luck either.我还在另一个终端上尝试过“minikube 隧道”,但也没有运气。

Thanks!谢谢!

There is a mistake in your ingress object definition under rules field: rules字段下的入口 object 定义中有错误:

  rules:
    - host: kubernetes.docker.internal
    - http:
        paths:

The exact problem is the - sing in front the http which makes the host and http separate arrays.确切的问题是-http前面唱歌,这使得hosthttp分开 arrays。

Take a look how your converter yaml looks like in json:看看您的转换器 yaml 在 json 中的样子:

{
  "spec": {
    "rules": [
      {
        "host": "kubernetes.docker.internal"
      },
      {
        "http": {
          "paths": [
            {
              "path": "/?(.*)",
              "pathType": "Prefix",
              "backend": {
---

This is how annotations looks like with your ingress definition.这就是注解在入口定义中的样子。

spec:
  rules:
    - host: kubernetes.docker.internal
      http:
        paths:
          - path: /?(.*)
            pathType: Prefix

And now notice how this yaml converted to json looks like:现在注意这个 yaml 转换为 json 的样子:

{
  "spec": {
    "rules": [
      {
        "host": "kubernetes.docker.internal",
        "http": {
          "paths": [
            {
              "path": "/?(.*)",
              "pathType": "Prefix",
              "backend": {
---

You can easily visualize this even better using yaml-viewer您可以使用yaml-viewer轻松地更好地可视化这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM