首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Minikube Ingress不解析,但minikube IP解析

Minikube Ingress不解析,但minikube IP解析
EN

Stack Overflow用户
提问于 2020-07-29 16:03:39
回答 1查看 457关注 0票数 0

在Windows 10的minikube集群中,我正在运行一个简单的pod,其中包含来自本地镜像注册表的镜像。我还运行了一个简单的nodeport服务。当我尝试使用:30080从浏览器访问容器时,它是可用的。

但是,现在我想设置一个入口控制器,因为我想设置一个域,而不是使用IP访问它。入口适用于一些简单的东西,如基本的nginx pod,但不适用于我正在尝试使用的这个pod。我之前在docker-compose中使用了jwilder/nginx-proxy,它有一些conf文件需要附加到conf.d目录中。然而,由于我要迁移到Kubernetes,我想完全省略conf文件和反向代理镜像。

现在,在主机fie更新之后,可以通过curl到达该域,该域也是可also通的,然而,它根本无法在浏览器上到达。

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    io.kompose.service: api
  name: api
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: api
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        io.kompose.service: api
    spec:
      containers:
      - env:
        - name: DEV_PORT
          value: "80"
        image: localhost:5000/api:2.3
        imagePullPolicy: "IfNotPresent"
        name: api
        resources: {}
      restartPolicy: Always
      serviceAccountName: ""
status: {}

Service.yaml

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: C:\Users\***kompose.exe
      convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: api
  name: api
spec:
  selector:
    io.kompose.service: api
  type: NodePort
  ports:
  - name: "http"
    port: 80
    targetPort: 80
    nodePort: 30080

Ingress.yaml

代码语言:javascript
复制
 apiVersion: networking.k8s.io/v1beta1 # for versions before 1.14 use extensions/v1beta1
 kind: Ingress
 metadata:
   name: tls-ingress
 spec:
   tls:
     - secretName: oaky-tls
       hosts: 
         - api.localhost
   rules:
   - host: api.localhost
     http:
       paths:
       - path: /
         backend:
           serviceName: api
           servicePort: 80

我已经检查过了,TLS的秘密是可用的,我不理解这里的问题,真的希望能得到一些帮助。

EN

回答 1

Stack Overflow用户

发布于 2020-08-04 16:38:26

解决方法: Chrome忽略了etc主机文件,所以我做了以下操作:

  • 切换到火狐,URL立即生效。
  • 添加了注释来表示这个类:

kubernetes.io/ingress.class: nginx

  • 添加了注释,以确保请求被重定向到ssl

nginx.ingress.kubernetes.io/ssl-redirect:"true"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63149039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档