ArgoCD – Could not | load secring: open /home/argocd/.gnupg/secring.gpg

I am facing an issue with argoCD version v2.8.6+6f7af53 when trying to decrypt a secrets.yaml (after editing the GPG key). Following are the steps that we followed to use GPG keys to decrypt secret files:

  1. Modify the argocd-repo-server deployment in argocd namespace

    # kubectl edit deployment argocd-repo-server -n argocd

    • Created these additional volumes in argocd-repo-server deployment

      volumes:
        - name: gnupg-home
          emptyDir: {}
        - name: pgp-secret-volume
          secret:
            defaultMode: 420
            secretName: pgp-secret
      
    • Added the following volumeMounts to the argocd-sidecar container in argocd-repo-server deployment

      volumeMounts:
           - mountPath: /home/pgp/
             name: pgp-secret-volume
           - mountPath: /home/argocd/.gnupg
             name: gnupg-home
      
    • Added the following env variable in sidecar container in argocd-repo-server deployment

      - name: GNUPGHOME
        value: /home/argocd/.gnupg
      
  2. Created Kubernetes secret

    # gpg --export-secret-keys --armor **************************** > secrets.asc
    # kubectl create secret generic pgp-secret --from-file=./secrets.asc -n argocd
    
  3. Modified the argocd-cmp-cm configmap in argocd namespace and added the following line:

    && gpg --import --batch --yes /home/pgp/secrets.asc
    
    # kubectl edit cm argocd-cmp-cm -n argocd
       discover:
         fileName: '*.yaml*'
       generate:
         command: ["/bin/sh", "-c"]
         args: ["if [ "$ARGOCD_ENV_SOP_FILE" != "" ];then sops -d sop.yaml > secrets.yaml && helm template -f values.yaml -f plainValues.yaml -f secrets.yaml -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME .; elif [ "$ARGOCD_ENV_VALUE_FILE" != "" ];then helm template -f values.yaml -f plainValues.yaml -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME .; else helm template -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME . ;fi"]
       init:
         command: ["/bin/sh", "-c"]
         args: ["echo "$ARGOCD_ENV_VALUE_FILE" > plainValues.yaml && echo "$ARGOCD_ENV_SOP_FILE" > sop.yaml && gpg --import --batch --yes /home/pgp/secrets.asc "]
    
  4. Restart the argocd-repo-server deployment

    # kubectl rollout restart deployment argocd-repo-server -n argocd
    

Initially argoCD was able to decrypt the files, but after a month GPG key got expired. Then we edited the key to extend the validity by 1 year. Then updated the kubernetes secret with the new key. After this, argoCD was not able to decrypt the files and it gave the following error.

Failed to load target state: failed to generate manifest for source 1 of 1: rpc error: code = Unknown desc = Manifest generation error (cached): plugin sidecar failed. error generating manifests in cmp: rpc error: code = Unknown desc = error generating manifests: `/bin/sh -c "if [ "$ARGOCD_ENV_SOP_FILE" != "" ];then sops -d sop.yaml > secrets.yaml && helm template -f values.yaml -f plainValues.yaml -f secrets.yaml -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME .; elif [ "$ARGOCD_ENV_VALUE_FILE" != "" ];then helm template -f values.yaml -f plainValues.yaml -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME .; else helm template -n $ARGOCD_APP_NAMESPACE $ARGOCD_APP_NAME . ;fi"` failed exit status 128: Failed to get the data key required to decrypt the SOPS file. Group 0: FAILED 13C31EF908C85F7E452F3223E5513A803E3341EE: FAILED - | could not decrypt data key with PGP key: | github.com/ProtonMail/go-crypto/openpgp error: Could not | load secring: open /home/argocd/.gnupg/secring.gpg: no such | file or directory; GPG binary error: exit status 2 Recovery failed because no master key was able to decrypt the file. In order for SOPS to recover the file, at least one key has to be successful, but none were.

Then I logged into the repo-server container and checked that the user did not have permission to the /home/argocd/.gnupg/ folder. As a workaround I made the following changes to the repo-server deployment under repo-server and sidecar container manifest.

securityContext:
    runAsNonRoot: false

After this the error was not observed and it was able to successfully sync the apps.

I know that this setting is not advised, how to fix the error without making changes to the securityContext?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật