Skip to content

Commit

Permalink
make servername configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Feb 14, 2025
1 parent 53480ad commit f12b0b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions neonvm/apis/neonvm/v1/virtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ type TLSProvisioning struct {

// This is required to set the duration before certificate expiration that the certificate is renewed
RenewBefore metav1.Duration `json:"renewBefore,omitempty"`

// This is the common name for the TLS certificate
ServerName string `json:"serverName,omitempty"`
}

func (spec *VirtualMachineSpec) Resources() VirtualMachineResources {
Expand Down
3 changes: 3 additions & 0 deletions neonvm/config/crd/bases/vm.neon.tech_virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3008,6 +3008,9 @@ spec:
description: This is required to set the duration before certificate
expiration that the certificate is renewed
type: string
serverName:
description: This is the common name for the TLS certificate
type: string
type: object
tolerations:
items:
Expand Down
7 changes: 2 additions & 5 deletions pkg/neonvm/controllers/vm_cert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ func (r *VMReconciler) deleteTmpSecret(ctx context.Context, vm *vmv1.VirtualMach
}

func certSpecCSR(vm *vmv1.VirtualMachine) (*x509.CertificateRequest, error) {
// TODO: configurable?
commonName := fmt.Sprintf("%s.%s.svc.cluster.local", vm.Name, vm.Namespace)

certSpec := certv1.CertificateSpec{
CommonName: commonName,
DNSNames: []string{commonName},
CommonName: vm.Spec.TLS.ServerName,
DNSNames: []string{vm.Spec.TLS.ServerName},
PrivateKey: &certv1.CertificatePrivateKey{
// TODO: can we support Ed25519?
Algorithm: certv1.ECDSAKeyAlgorithm,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/vm-tls/00-create-vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ spec:
renewBefore: 1h
expireAfter: 24h
certificateIssuer: "neon-ca-issuer"
serverName: "vm.neon.local"

0 comments on commit f12b0b0

Please sign in to comment.