首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要帮助为hcloud-cloud- controller -manager配置Nginx入口控制器

需要帮助为hcloud-cloud- controller -manager配置Nginx入口控制器
EN

Stack Overflow用户
提问于 2021-06-01 01:56:52
回答 1查看 379关注 0票数 0

我正在尝试跟随this suggestion使用Hetzner load balancer作为Nginx的入口控制器。

具有以下配置的helm install ingress-nginx

代码语言:javascript
复制
controller:
  config:
    use-proxy-protocol: "true"
  replicaCount: 3
  service:
    type: LoadBalancer
    annotations:
      load-balancer.hetzner.cloud/name: nginx-controller-new
      load-balancer.hetzner.cloud/location: hel1
      load-balancer.hetzner.cloud/use-private-ip: true
      load-balancer.hetzner.cloud/algorithm-type: least_connections
      load-balancer.hetzner.cloud/uses-proxyprotocol: true
      load-balancer.hetzner.cloud/hostname: somehost.com

部署:

代码语言:javascript
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: echo1
spec:
  selector:
    matchLabels:
      app: echo1
  replicas: 3
  template:
    metadata:
      labels:
        app: echo1
    spec:
      containers:
        - name: echo1
          image: hashicorp/http-echo
          args:
            - "-text=echo1"
          ports:
            - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: echo-service
spec:
  selector:
    app: echo1
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 5678
  ipFamilyPolicy: PreferDualStack

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: echo-service
                port:
                  number: 80
      host: somehost.com

安装后,Hetzner负载均衡器配置成功,但无法检测到服务:

我现在有点不知所措。如何将echo1应用连接到入口-nginx-控制器服务?我查看了Echo1,但我找不到像service.selector这样的东西来针对Echo1的服务并使其公开可用。有人能帮我吗?还有别的选择吗?

EN

回答 1

Stack Overflow用户

发布于 2021-07-16 19:16:44

我不是Kubernetes大师(更像是菜鸟),但我是用L4负载均衡器工作的。

必须将注释设置到您的Ingress:

代码语言:javascript
复制
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx

在不使用nginx-ingress的情况下使用它,这对我很有效(没有使用您的标签进行测试)

代码语言:javascript
复制
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  name: "nginx-hello-world"
  labels:
    app: "hello-world"
spec:
  selector:
    matchLabels:
      app: "hello-world"
  strategy:
    type: "Recreate"
  template:
    metadata:
      labels:
        app: "hello-world"
    spec:
      containers:
        - image: "rancher/hello-world"
          name: "nginx-hello-world"
          imagePullPolicy: "Always"
          ports:
            - containerPort: 80
              name: "http"

用于HTTP的服务(用于测试您的部署)

代码语言:javascript
复制
---
apiVersion: "v1"
kind: Service
metadata:
  name: "nginx-hello-world"
  labels:
    app: "hello-world"
  annotations:
    load-balancer.hetzner.cloud/name: lb-development
    load-balancer.hetzner.cloud/hostname: somehost.com
    load-balancer.hetzner.cloud/protocol:   http
    load-balancer.hetzner.cloud/health-check-port: 10254
spec:
  type: LoadBalancer
  selector:
    app: "hello-world"
  ports:
    - name: "http"
      port: 80
      targetPort: 80

对于SSL

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  name: nginx-hello-world
  labels:
    app: hello-world
  annotations:
    load-balancer.hetzner.cloud/hostname: somehost.com
    load-balancer.hetzner.cloud/http-certificates: managed-certificate-1-wildcard-somehost.com
    load-balancer.hetzner.cloud/name: lb-development
    load-balancer.hetzner.cloud/protocol: https
spec: 
  ports:
  - name: https
    nodePort: 32725
    port: 443
    protocol: TCP
    targetPort: 80
  selector:
    app: hello-world
  type: LoadBalancer
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67778384

复制
相关文章

相似问题

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