Documentation ¶
Index ¶
- Constants
- Variables
- func CanAddAnnotationToSecret(deplHash string, secret *unstructured.Unstructured) bool
- func CertificateToPem(certificateDER []byte) []byte
- func GenerateCACert(certValidityDuration time.Duration) (*KeyPair, *PemPair, error)
- func GeneratePrivateKey() (*rsa.PrivateKey, error)
- func GenerateRootCASecretName(props CertificateProps) string
- func GenerateTLSPairSecretName(props CertificateProps) string
- func IsKyvernoInRollingUpdate(deploy map[string]interface{}, logger logr.Logger) bool
- func IsTLSPairShouldBeUpdated(tlsPair *PemPair) bool
- func PrivateKeyToPem(rsaKey *rsa.PrivateKey) []byte
- func ReadRootCASecret(restConfig *rest.Config, client *client.Client) (result []byte, err error)
- type CertRenewer
- func (c *CertRenewer) Client() *client.Client
- func (c *CertRenewer) ClientConfig() *rest.Config
- func (c *CertRenewer) InitTLSPemPair() (*PemPair, error)
- func (c *CertRenewer) RollingUpdate() error
- func (c *CertRenewer) ValidCert() (bool, error)
- func (c *CertRenewer) WriteCACertToSecret(caPEM *PemPair, props CertificateProps) error
- func (c *CertRenewer) WriteTLSPairToSecret(props CertificateProps, pemPair *PemPair) error
- type CertificateProps
- type KeyPair
- type PemPair
Constants ¶
const ( // ManagedByLabel is added to Kyverno managed secrets ManagedByLabel string = "cert.kyverno.io/managed-by" MasterDeploymentUID string = "cert.kyverno.io/master-deployment-uid" SelfSignedAnnotation string = "self-signed-cert" RootCAKey string = "rootCA.crt" )
const CertRenewalInterval time.Duration = 12 * time.Hour
CertRenewalInterval is the renewal interval for rootCA
const CertValidityDuration time.Duration = 365 * 24 * time.Hour
CertValidityDuration is the valid duration for a new cert
Variables ¶
var ErrorsNotFound = "root CA certificate not found"
Functions ¶
func CanAddAnnotationToSecret ¶ added in v1.5.4
func CanAddAnnotationToSecret(deplHash string, secret *unstructured.Unstructured) bool
func CertificateToPem ¶ added in v1.3.0
CertificateToPem ...
func GenerateCACert ¶ added in v1.2.0
GenerateCACert creates the self-signed CA cert and private key it will be used to sign the webhook server certificate
func GeneratePrivateKey ¶ added in v1.3.0
func GeneratePrivateKey() (*rsa.PrivateKey, error)
GeneratePrivateKey Generates RSA private key
func GenerateRootCASecretName ¶ added in v1.5.4
func GenerateRootCASecretName(props CertificateProps) string
func GenerateTLSPairSecretName ¶ added in v1.5.4
func GenerateTLSPairSecretName(props CertificateProps) string
func IsKyvernoInRollingUpdate ¶ added in v1.4.0
IsKyvernoInRollingUpdate returns true if Kyverno is in rolling update
func IsTLSPairShouldBeUpdated ¶ added in v1.1.0
IsTLSPairShouldBeUpdated checks if TLS pair has expited and needs to be updated
func PrivateKeyToPem ¶ added in v1.3.0
func PrivateKeyToPem(rsaKey *rsa.PrivateKey) []byte
PrivateKeyToPem Creates PEM block from private key object
Types ¶
type CertRenewer ¶ added in v1.3.5
type CertRenewer struct {
// contains filtered or unexported fields
}
CertRenewer creates rootCA and pem pair to register webhook configurations and webhook server renews RootCA at the given interval
func NewCertRenewer ¶ added in v1.3.5
func NewCertRenewer(client *client.Client, clientConfig *rest.Config, certRenewalInterval, certValidityDuration time.Duration, serverIP string, log logr.Logger) *CertRenewer
NewCertRenewer returns an instance of CertRenewer
func (*CertRenewer) Client ¶ added in v1.4.0
func (c *CertRenewer) Client() *client.Client
func (*CertRenewer) ClientConfig ¶ added in v1.4.0
func (c *CertRenewer) ClientConfig() *rest.Config
func (*CertRenewer) InitTLSPemPair ¶ added in v1.3.5
func (c *CertRenewer) InitTLSPemPair() (*PemPair, error)
InitTLSPemPair Loads or creates PEM private key and TLS certificate for webhook server. Created pair is stored in cluster's secret. Returns struct with key/certificate pair.
func (*CertRenewer) RollingUpdate ¶ added in v1.3.5
func (c *CertRenewer) RollingUpdate() error
RollingUpdate triggers a rolling update of Kyverno pod. It is used when the rootCA is renewed, the restart of Kyverno pod will register webhook server with new cert
func (*CertRenewer) ValidCert ¶ added in v1.3.5
func (c *CertRenewer) ValidCert() (bool, error)
ValidCert validates the CA Cert
func (*CertRenewer) WriteCACertToSecret ¶ added in v1.3.5
func (c *CertRenewer) WriteCACertToSecret(caPEM *PemPair, props CertificateProps) error
WriteCACertToSecret stores the CA cert in secret
func (*CertRenewer) WriteTLSPairToSecret ¶ added in v1.3.5
func (c *CertRenewer) WriteTLSPairToSecret(props CertificateProps, pemPair *PemPair) error
WriteTLSPairToSecret Writes the pair of TLS certificate and key to the specified secret. Updates existing secret or creates new one.
type CertificateProps ¶ added in v1.3.0
type CertificateProps struct { Service string Namespace string APIServerHost string ServerIP string }
CertificateProps Properties of TLS certificate which should be issued for webhook server
func GetTLSCertProps ¶ added in v1.3.5
func GetTLSCertProps(configuration *rest.Config) (certProps CertificateProps, err error)
GetTLSCertProps provides the TLS Certificate Properties
type KeyPair ¶ added in v1.2.0
type KeyPair struct { Cert *x509.Certificate Key *rsa.PrivateKey }
KeyPair ...
type PemPair ¶ added in v1.3.0
PemPair The pair of TLS certificate corresponding private key, both in PEM format
func GenerateCertPem ¶ added in v1.2.0
func GenerateCertPem(caCert *KeyPair, props CertificateProps, serverIP string, certValidityDuration time.Duration) (*PemPair, error)
GenerateCertPem takes the results of GenerateCACert and uses it to create the PEM-encoded public certificate and private key, respectively