简体   繁体   English

jkube 资源失败:未知类型 CRD

[英]jkube resource failed: Unknown type CRD

I am using jkube to deploy a springboot helloworld application on my kubernetes installation.我正在使用 jkube 在我的 kubernetes 安装上部署 springboot helloworld 应用程序。 I wanted to add a resource fragment defining a Traefik ingress route but k8s:resource fails with "Unknown type 'ingressroute'".我想添加一个定义 Traefik 入口路由的资源片段,但 k8s:resource 因“未知类型'ingressroute'”而失败。
IngressRoute has already been defined on the cluster using custom resource definition.已经使用自定义资源定义在集群上定义了 IngressRoute。

How do I write my fragment?如何编写我的片段?

The following works when i deploy it with kubectl.当我使用 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

I'm from Eclipse JKube team.我来自 Eclipse JKube 团队。 We have improved CustomResource support a lot in our recent v1.2.0 release.我们在最近的v1.2.0版本中改进了很多对 CustomResource 的支持。 Now you only need to worry about how you name your CustomResource fragment and Eclipse JKube would detect the CustomResourceDefinition for specified IngressRoute.现在您只需要担心如何命名您的 CustomResource 片段和 Eclipse JKube 将检测指定 IngressRoute 的 CustomResourceDefinition。

I think you would need to name CustomResource fragments with a *-cr.yml at the end.我认为您需要在末尾使用*-cr.yml命名 CustomResource 片段。 This is due to distinguishing them from standard Kubernetes resources.这是因为将它们与标准 Kubernetes 资源区分开来。 For example I added your IngressRoute fragment in my src/main/jkube like this:例如,我在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

Then you should be able to see your IngressRoute generated after k8s:resource phase:然后你应该能够看到在k8s:resource阶段之后生成的 IngressRoute:

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

You can then go ahead and apply these generated manifests to your Kubernetes Cluster with apply goal:然后,您可以提前 go 并将这些生成的清单应用到您的 Kubernetes 集群,应用目标:

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

I tried all this on this reproducer project and it seemed to be working okay for me: https://github.com/r0haaaan/jkube-custom-resource-fragments我在这个复制器项目上尝试了所有这些,它似乎对我来说工作正常: https://github.com/r0haaaan/jkube-custom-resource-fragments

@Rohan Kumar @罗汉库马尔

Thank you for your answer.谢谢您的回答。 I can built and deploy it, but as soon as I add a file to use my IngressRoute, then the k8s:resource target fails.我可以构建和部署它,但是只要我添加一个文件来使用我的 IngressRoute,那么 k8s:resource 目标就会失败。

I added files - one for each CRD with filename -cr.yml and added the following to the pom file:我添加了文件 - 每个 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>

Example IngressRoute definition:示例 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

But when running the k8s:resource I get the error:但是在运行 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