[英]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.