繁体   English   中英

jkube 资源失败:未知类型 CRD

[英]jkube resource failed: Unknown type CRD

我正在使用 jkube 在我的 kubernetes 安装上部署 springboot helloworld 应用程序。 我想添加一个定义 Traefik 入口路由的资源片段,但 k8s:resource 因“未知类型'ingressroute'”而失败。
已经使用自定义资源定义在集群上定义了 IngressRoute。

如何编写我的片段?

当我使用 kubectl 部署它时,以下工作有效。

# IngresRoute
---
kind: IngressRoute
apiVersion: traefik.containo.us/v1alpha1
metadata:
  name: demo
  namespace: default

spec:
  entryPoints: 
    - web
  routes:
  - match: Host(`demo.domainname.com`)
    kind: Rule
    services:
    - name: demo
      port: 80

我来自 Eclipse JKube 团队。 我们在最近的v1.2.0版本中改进了很多对 CustomResource 的支持。 现在您只需要担心如何命名您的 CustomResource 片段和 Eclipse JKube 将检测指定 IngressRoute 的 CustomResourceDefinition。

我认为您需要在末尾使用*-cr.yml命名 CustomResource 片段。 这是因为将它们与标准 Kubernetes 资源区分开来。 例如,我在src/main/jkube中添加了您的IngressRoute片段,如下所示:

jkube-custom-resource-fragments : $ ls src/main/jkube/
ats-crd.yml  crontab-crd.yml  dummy-cr.yml         podset-crd.yaml      traefic-crd.yaml
ats-cr.yml   crontab-cr.yml   ingressroute-cr.yml  second-dummy-cr.yml  traefic-ingressroute2-cr.yml
crd.yaml     dummy-crd.yml    istio-crd.yaml       test2-cr.yml         virtualservice-cr.yml
jkube-custom-resource-fragments : $ ls src/main/jkube/traefic-ingressroute2-cr.yml 
src/main/jkube/traefic-ingressroute2-cr.yml

然后你应该能够看到在k8s:resource阶段之后生成的 IngressRoute:

$ mvn k8s:resource
...
$ cat target/classes/META-INF/jkube/kubernetes.yml

然后,您可以提前 go 并将这些生成的清单应用到您的 Kubernetes 集群,应用目标:

$ mvn k8s:apply
...
$ kubectl get ingressroute
NAME   AGE
demo   17s
foo    16s

我在这个复制器项目上尝试了所有这些,它似乎对我来说工作正常: https://github.com/r0haaaan/jkube-custom-resource-fragments

@罗汉库马尔

谢谢您的回答。 我可以构建和部署它,但是只要我添加一个文件来使用我的 IngressRoute,那么 k8s:resource 目标就会失败。

我添加了文件 - 每个 CRD 一个文件名 -cr.yml 并将以下内容添加到 pom 文件中:

<pre>
<resources>
    <customResourceDefinitions>
        <customResourceDefinition>traefikservices.traefik.containo.us</customResourceDefinition>
        <customResourceDefinition>tlsstores.traefik.containo.us</customResourceDefinition>
        <customResourceDefinition>tlsoptions.traefik.containo.us</customResourceDefinition>
        <customResourceDefinition>middlewares.traefik.containo.us</customResourceDefinition>
        <customResourceDefinition>ingressrouteudps.traefik.containo.us</customResourceDefinition>
        <customResourceDefinition>ingressroutetcps.traefik.containo.us</customResourceDefinition>
        <customResourceDefinitions>ingressroutes.traefik.containo.us</customResourceDefinitions>
    </customResourceDefinitions>
</resources>

示例 IngressRoute 定义:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: ingressroutes.traefik.containo.us

spec:
  group: traefik.containo.us
  version: v1alpha1
  names:
    kind: IngressRoute
    plural: ingressroutes
    singular: ingressroute
  scope: Namespaced

但是在运行 k8s:resource 时出现错误:

Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.0.2:resource (default-cli) on project demo:
Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.0.2:resource failed: Unknown type
'ingressroute' for file 005-ingressroute.yml. Must be one of : pr, lr, pv, project, replicaset, cronjob, ds,
statefulset, clusterrolebinding, pvc, limitrange, imagestreamtag, replicationcontroller, is, rb, rc, ingress, route,
projectrequest, job, rolebinding, rq, template, serviceaccount, bc, rs, rbr, role, pod, oauthclient, ns,
resourcequota, secret, persistemtvolumeclaim, istag, customerresourcedefinition, sa, persistentvolume, crb,
clusterrb, crd, deploymentconfig, configmap, deployment, imagestream, svc, rolebindingrestriction, cj, cm,
buildconfig, daemonset, cr, crole, pb, clusterrole, pd, policybinding, service, namespace, dc

暂无
暂无

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

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