首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microk8s接入互联网,但不接入内部网络。

Microk8s接入互联网,但不接入内部网络。
EN

Stack Overflow用户
提问于 2022-10-11 20:53:27
回答 1查看 132关注 0票数 0

我刚刚在一个Ubuntu 22.04虚拟服务器上安装了vmware,并开始使用microk8s。服务器是本地网络的一部分,其中有一些服务器,包括处理网络的microsoft ADIIS服务器。

我已经在docker系统上安装了ubuntu,并且可以通过docker运行web应用程序的所有容器,没有问题。特别是,我有一个服务(一个容器),它连接到本地网络的windows AD服务器来验证web应用程序的用户。在主机上,它的工作没有问题,可以到达AD服务器和网络中的其他服务器,并执行所有必要的操作。

另一方面,当通过kubernetes通过microk8s运行时,所有服务都可以从本地网络到达,同时容器可以到达外部网络(在本地网络之外,例如www.google.com)。只有内部网络似乎是无法到达的,为此我总是会得到一个超时错误。

我尝试过的(但没有成功)

  • 外部服务https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors
  • 检查复制到容器中的主机上的dns解析。

备注

我不确定要运行什么样的命令才能提供有关配置的最有用的信息,所以我将迭代这个问题,用日志和其他有意义的信息扩展它。

谢谢

编辑11/10/2022

我启用了以下加载项

代码语言:javascript
复制
microk8s is running
high-availability: no
  datastore master nodes: 127.0.0.1:19001
  datastore standby nodes: none
addons:
  enabled:
    dns                  # (core) CoreDNS
    ha-cluster           # (core) Configure high availability on the current node
    helm                 # (core) Helm - the package manager for Kubernetes
    helm3                # (core) Helm 3 - the package manager for Kubernetes
    ingress              # (core) Ingress controller for external access
    metallb              # (core) Loadbalancer for your Kubernetes cluster

另一件奇怪的事情是,容器可以通过主机的ip地址(10.1.1.xxx)访问主机上的postgres数据库。

编辑2 12/10/2022

这是入口yaml文件

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  name: ingress
  namespace: ingress
spec:
  selector:
    name: nginx-ingress-microk8s
  type: LoadBalancer
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
    - name: https
      protocol: TCP
      port: 443
      targetPort: 443
---
#
# Ingress
#
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: main-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - http:
      paths:
      - path: /api/erp(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: erp-service
            port:
              number: 8000
      - path: /api/auth(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: auth-service
            port:
              number: 8000
      - path: /()(.*)
        pathType: Prefix
        backend:
          service:
            name: ui-service
            port:
              number: 3000

我可以访问UI,通过使用主机的ip/api/auth,我可以访问swagger/openapi的在线文档。1:https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-17 21:09:31

到目前为止,我还没有找到任何解决方案,只是绕过了请求,使用了一个“代理”endpoint,如

使用无选择服务和手动端点从InfluxDb吊舱访问外部microk8s数据库?

基本上,它创建了一个可以由集群访问的服务和指向外部资源的端点。

从答案中获取的实际源配置

代码语言:javascript
复制
kind: Service
apiVersion: v1
metadata:
  name: influxdb-service-lb
  #namespace: ingress
spec:
  type: LoadBalancer
  loadBalancerIP: 10.1.2.61
#  selector:
#    app: grafana
  ports:
  - name: http
    protocol: TCP
    port: 8086
    targetPort: 8086
---
apiVersion: v1
kind: Endpoints
metadata:
  name: influxdb-service-lb
subsets:
  - addresses:
      - ip: 10.1.2.220
    ports:
      - name: influx
        protocol: TCP
        port: 8086

如果我能找到解决方案,我会更新这个答案

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

https://stackoverflow.com/questions/74034004

复制
相关文章

相似问题

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