返回顶部

argocd + kustomize 报错“rpc error: code = Unknown desc = Manifest generation error (cached)”

argocd + kustomize 报错“rpc error: code = Unknown desc = Manifest generation error (cached)”

 报错内容

报错内容为:rpc error: code = Unknown desc = Manifest generation error (cached): `kustomize build .xiaowangTech/4.0/frontend/dingding-pc/manifests/overlays/test` failed exit status 1: # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.Error: no matches for Id Ingress.v1.networking.k8s.io/dingding-pc-ingress.test; failed to find unique target for patch Ingress.v1.networking.k8s.io/dingding-pc-ingress.test

原因分析

配置test环境时ingress配置没有和base里面想匹配,导致报错并且SYNC STATUS状态为Unknown

解决方案

经过对比发现,配置test环境的ingress和base里面的ingress不匹配,即test环境的ingress和base里面的ingress相同,再通过test环境的kustomization.yaml进行替换,最后解决问题

 

 

$cat ding/manifests/base/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    description: ding
    kubernetes.io/ingress.class: test-ingress-internet
    kubernetes.io/ingress.rule-mix: "true"
    nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
    nginx.ingress.kubernetes.io/cors-allow-methods: PUT, GET, POST, OPTIONS
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/enable-cors: "true"
  name: ding-ingress
  namespace: dev
spec:
  rules:
    - host: ding-dev.weirui.com
      http:
        paths:
          - backend:
              service:
                name: dev-ding-svc
                port:
                  number: 80
            pathType: ImplementationSpecific
...




$cat ding/manifests/overlays/test/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ding-ingress
  namespace: dev
spec:
  rules:
    - host: ding-test.weirui.com
      http:
        paths:
          - backend:
              service:
                name: test-ding-svc
                port:
                  number: 80
            pathType: ImplementationSpecific
...



$cat ding/manifests/overlays/test/kustomization.yaml
# 生成test环境namespace
namespace: test
# 生成test环境的前缀“test-”
namePrefix: test-
# 指向base主目录

# 指向同级生产配置目录的·yaml资源
patchesStrategicMerge:
  - replica.yaml
  - image.yaml
  - volumes.yaml
  - ingress.yaml
  # 指定对应的deployment文件
  # 修改同级目录的port.yaml
#将key,value传递到生成的configmap

configMapGenerator:
  - name: ding-config
    files:
      - default.conf
generatorOptions:
  disableNameSuffixHash: true
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../../base

 

posted @ 2023-07-08 15:44  九尾cat  阅读(564)  评论(0编辑  收藏  举报