定义k3s traefik的入口管理

huangapple go评论50阅读模式
英文:

Defining Ingress for k3s traefik

问题

我运行的是k3s版本1.25.5,我想要将traefik定义为通过外部helm图表定义的一个服务的入口。我在寻找正确的入口定义时遇到了困难。我尝试使用下面的yaml文件,但出现错误提示:

error: resource mapping not found for name: "c8-ingress" namespace: "" from "zeebe-traefik.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
ensure CRDs are installed first

这似乎是因为yaml文件中使用了旧的apiVersion。如何正确实现呢?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: c8-ingress
  annotations:
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
  - http:
      paths:
      - path: "/"
        backend:
          serviceName: dev-zeebe-gateway
          servicePort: 26500

谢谢。

英文:

I am running k3s version 1.25.5 and I would like to define traefik as an ingress for one of the services defined through an external helm chart. I am struggling to find the right ingress definition. I tried with the below yaml file but that gives an error stating

error: resource mapping not found for name: "c8-ingress" namespace: "" from "zeebe-traefik.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
ensure CRDs are installed first

This seems to be because of the an old apiVersion used in the yaml file. How to do it the right way?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: c8-ingress
  annotations:
    kubernetes.io/ingress.class: "traefik"
spec:
  rules:
  - http:
      paths:
      - path: "/"
        backend:
          serviceName: dev-zeebe-gateway
          servicePort: 26500

Thanks.

答案1

得分: 2

你的示例使用了过时的Ingress定义。在v1.25.x中,你需要使用稳定的networking.k8s.io/v1 API,如这里所描述。

建议还要提供适当的命名空间。这对于文档很有用,但也是资源后端所需的。这样可以避免在每次kubectl apply时添加-n YOURNAMESPACE

在你的情况下,可能看起来像这样:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: c8-ingress
  namespace: YOURNAMESPACE
spec:
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: /
            backend:
              service:
                name: dev-zeebe-gateway
                port:
                  number: 26500

希望这有助于解决你的问题。

在许多情况下,你可以运行kubectl explain RESOURCE来获取有关给定API资源的有用链接和资源。

英文:

Your example is using an outdated Ingress definition. In v1.25.x you need to use the stable networking.k8s.io/v1 API, as described here.

It is also recommended to provide the fitting namespace. This is useful for documentation, but also required for resource backends. It will also avoid adding -n YOURNAMESPACE to every kubectl apply.

In your case, this may look something like:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: c8-ingress
  namespace: YOURNAMESPACE
spec:
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: /
            backend:
              service:
                name: dev-zeebe-gateway
                port:
                  number: 26500

I hope this helps to solve your issue.

In many cases, you can run kubectl explain RESOURCE to get useful links and resources for a given api-resource.

huangapple
  • 本文由 发表于 2023年2月6日 22:12:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75362448-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定