项目作者: camptocamp

项目描述 :
Cert-manager issuer for the Puppet Certificate Authority
高级语言: Go
项目地址: git://github.com/camptocamp/puppetca-issuer.git
创建时间: 2020-08-31T15:54:41Z
项目社区:https://github.com/camptocamp/puppetca-issuer

开源协议:Apache License 2.0

下载


Puppet Certificate Authority Issuer

This is a Cert-Manager issuer for the Puppet CA.

cert-manager

cert-manager manages certificates in Kubernetes environment (among others) and keeps track of renewal requirements (https://cert-manager.io/). It supports various in-built issuers that issue the certificates to be managed by cert-manager.

Puppet CA Issuer

This project plugs into cert-manager as an external issuer that talks to the Puppet CA to get certificates issued for your Kubernetes environment.

Setup

Install cert-manager first (https://cert-manager.io/docs/installation/kubernetes/), version 0.16.1 or later.

Clone this repo and perform following steps to install controller:

  1. # make build
  2. # make docker
  3. # make deploy

Create secret that holds Puppet CA credentials:

  1. # cat secret.yaml
  2. apiVersion: v1
  3. kind: Secret
  4. metadata:
  5. name: puppetca-credentials
  6. namespace: puppetca-issuer-system
  7. data:
  8. url: <base64 encoding of url to the PuppetCA>
  9. cert: <base64 encoding of certificate to access the PuppetCA>
  10. key: <base64 encoding of private key to access the PuppetCA>
  11. cacert: <base64 encoding of CA certificate of the PuppetCA>

Note: While generating base64 encoding of above fields, ensure there is no newline character included in the encoded string. For example, following command could be used:

  1. echo -n "<access key>" | base64

Apply configuration to create secret:

  1. # kubectl apply -f secret.yaml

Create resource PuppetCAIssuer for our controller:

  1. # cat issuer.yaml
  2. apiVersion: certmanager.puppetca/v1alpha2
  3. kind: PuppetCAIssuer
  4. metadata:
  5. name: puppetca-issuer
  6. namespace: puppetca-issuer-system
  7. spec:
  8. provisioner:
  9. secretName: puppetca-credentials
  10. url:
  11. key: url
  12. cert:
  13. key: cert
  14. key:
  15. key: key
  16. cacert:
  17. key: cacert

Apply this configuration:

  1. # kubectl apply -f issuer.yaml
  2. # kubectl describe PuppetCAIssuer -n puppetca-issuer-system
  3. Name: puppetca-issuer
  4. Namespace: puppetca-issuer-system
  5. Labels: <none>
  6. Annotations: API Version: certmanager.puppetca/v1alpha2
  7. Kind: PuppetCAIssuer
  8. ...
  9. Spec:
  10. Provisioner:
  11. Url:
  12. key: url
  13. Cert:
  14. key: cert
  15. Key:
  16. key: key
  17. CaCert:
  18. key: cacert
  19. Status:
  20. Conditions:
  21. Last Transition Time: 2020-08-31T04:34:33Z
  22. Message: PuppetCAIssuer verified and ready to sign certificates
  23. Reason: Verified
  24. Status: True
  25. Type: Ready
  26. Events:
  27. Type Reason Age From Message
  28. ---- ------ ---- ---- -------
  29. Normal Verified 8m22s (x2 over 8m22s) puppetca-controller PuppetCAIssuer verified and ready to sign certificates

Now create certificate:

  1. # cat certificate.yaml
  2. apiVersion: cert-manager.io/v1alpha2
  3. kind: Certificate
  4. metadata:
  5. name: foo-puppet-cert
  6. namespace: puppetca-issuer-system
  7. spec:
  8. # The secret name to store the signed certificate
  9. secretName: puppet-certificate-foo
  10. # Common Name
  11. commonName: foo.com
  12. # DNS SAN
  13. dnsNames:
  14. - localhost
  15. - foo.com
  16. issuerRef:
  17. group: certmanager.puppetca
  18. kind: PuppetCAIssuer
  19. name: puppetca-issuer
  20. # This is required for the Puppet CA
  21. encodeUsagesInRequest: false
  1. # kubectl apply -f certificate.yaml
  2. # kubectl describe Certificate foo-puppet-cert -n puppetca-issuer-system
  3. Name: foo-puppet-cert
  4. Namespace: puppetca-issuer-system
  5. Labels: <none>
  6. Annotations: API Version: cert-manager.io/v1alpha3
  7. Kind: Certificate
  8. ...
  9. Spec:
  10. Common Name: foo.com
  11. Dns Names:
  12. localhost
  13. foo.com
  14. Encode Usages In Request: false
  15. Issuer Ref:
  16. Group: certmanager.puppetca
  17. Kind: PuppetCAIssuer
  18. Name: puppetca-issuer
  19. Secret Name: puppet-certificate-foo
  20. Status:
  21. Conditions:
  22. Last Transition Time: 2020-08-18T04:34:48Z
  23. Message: Certificate is up to date and has not expired
  24. Reason: Ready
  25. Status: True
  26. Type: Ready
  27. Not After: 2020-08-19T04:34:45Z
  28. Not Before: 2020-08-18T03:34:45Z
  29. Renewal Time: 2020-08-19T03:34:45Z
  30. Revision: 1
  31. Events:
  32. Type Reason Age From Message
  33. ---- ------ ---- ---- -------
  34. Normal Issuing 6m1s cert-manager Issuing certificate as Secret does not exist
  35. Normal Generated 6m cert-manager Stored new private key in temporary Secret resource "backend-puppetca-7m9sx"
  36. Normal Requested 6m cert-manager Created new CertificateRequest resource "backend-puppetca-m2gz5"
  37. Normal Issuing 5m51s cert-manager The certificate has been successfully issued

Check certificate and private key are present in secrets:

  1. # kubectl describe secrets puppet-certificate-foo -n puppetca-issuer-system
  2. Name: foo-puppet-cert
  3. Namespace: puppetca-issuer-system
  4. Labels: <none>
  5. Annotations: cert-manager.io/alt-names: localhost,foo.com
  6. cert-manager.io/certificate-name: foo-puppet-cert
  7. cert-manager.io/common-name: foo.com
  8. cert-manager.io/issuer-kind: PuppetCAIssuer
  9. cert-manager.io/issuer-name: puppetca-issuer
  10. cert-manager.io/uri-sans:
  11. Type: kubernetes.io/tls
  12. Data
  13. ====
  14. tls.key: xxxx bytes
  15. tls.crt: yyyy bytes