Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit b5855b0

Browse files
committed
- Adds enableMeshRootCertificate to featureFlag values
- Allows manager to set issuer ID - Removes unnecessary newline Signed-off-by: jaellio <[email protected]>
1 parent d5b6645 commit b5855b0

12 files changed

+49
-63
lines changed

charts/osm/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ The following table lists the configurable parameters of the osm chart and their
9393
| osm.enableReconciler | bool | `false` | Enable reconciler for OSM's CRDs and mutating webhook |
9494
| osm.enforceSingleMesh | bool | `true` | Enforce only deploying one mesh in the cluster |
9595
| osm.envoyLogLevel | string | `"error"` | Log level for the Envoy proxy sidecar. Non developers should generally never set this value. In production environments the LogLevel should be set to `error` |
96-
| osm.experimental | object | `{"enableMeshRootCertificate":false}` | Experimental values. Behavior is not supported. |
97-
| osm.experimental.enableMeshRootCertificate | bool | `false` | Enable the MeshRootCertificate to configure the OSM certificate provider. |
9896
| osm.featureFlags.enableAsyncProxyServiceMapping | bool | `false` | Enable async proxy-service mapping |
9997
| osm.featureFlags.enableEgressPolicy | bool | `true` | Enable OSM's Egress policy API. When enabled, fine grained control over Egress (external) traffic is enforced |
10098
| osm.featureFlags.enableEnvoyActiveHealthChecks | bool | `false` | Enable Envoy active health checks |
10199
| osm.featureFlags.enableIngressBackendPolicy | bool | `true` | Enables OSM's IngressBackend policy API. When enabled, OSM will use the IngressBackend API allow ingress traffic to mesh backends |
100+
| osm.featureFlags.enableMeshRootCertificate | bool | `false` | Enable the MeshRootCertificate to configure the OSM certificate provider |
102101
| osm.featureFlags.enableRetryPolicy | bool | `false` | Enable Retry Policy for automatic request retries |
103102
| osm.featureFlags.enableSnapshotCacheMode | bool | `false` | Enables SnapshotCache feature for Envoy xDS server. |
104103
| osm.featureFlags.enableWASMStats | bool | `true` | Enable extra Envoy statistics generated by a custom WASM extension |

charts/osm/templates/osm-bootstrap-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
"--osm-version", "{{ .Chart.AppVersion }}",
6262
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6363
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
64-
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
64+
"--enable-mesh-root-certificate={{.Values.osm.featureFlags.enableMeshRootCertificate}}",
6565
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6666
"--vault-host", "{{.Values.osm.vault.host}}",
6767
"--vault-port", "{{.Values.osm.vault.port}}",

charts/osm/templates/osm-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
"--validator-webhook-config", "{{ include "osm.validatorWebhookConfigName" . }}",
6262
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6363
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
64-
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
64+
"--enable-mesh-root-certificate={{.Values.osm.featureFlags.enableMeshRootCertificate}}",
6565
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6666
"--vault-host", "{{ required "osm.vault.host is required when osm.certificateProvider.kind==vault" .Values.osm.vault.host }}",
6767
"--vault-port", "{{.Values.osm.vault.port}}",

charts/osm/templates/osm-injector-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ spec:
5858
"--webhook-timeout", "{{.Values.osm.injector.webhookTimeoutSeconds}}",
5959
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6060
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
61-
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
61+
"--enable-mesh-root-certificate={{.Values.osm.featureFlags.enableMeshRootCertificate}}",
6262
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6363
"--vault-host", "{{.Values.osm.vault.host}}",
6464
"--vault-port", "{{.Values.osm.vault.port}}",

charts/osm/templates/preset-mesh-root-certificate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.osm.experimental.enableMeshRootCertificate }}
1+
{{- if .Values.osm.featureFlags.enableMeshRootCertificate }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/osm/values.schema.json

+11-19
Original file line numberDiff line numberDiff line change
@@ -438,24 +438,6 @@
438438
"envoyproxy/envoy-windows:v1.22.1@sha256:92733f8e5beae5c45df204a0e13edbd29e99adf962d1b1c7869b197d85c64bd0"
439439
]
440440
},
441-
"experimental": {
442-
"$id": "#/properties/osm/properties/experimental",
443-
"type": "object",
444-
"title": "The experimental schema",
445-
"description": "Parameters that are unsupported by OSM",
446-
"additionalProperties": false,
447-
"properties": {
448-
"enableMeshRootCertificate": {
449-
"$id": "#/properties/osm/properties/experimental/properties/enableMeshRootCertificate",
450-
"type": "boolean",
451-
"title": "Enable the MeshRootCertificate",
452-
"description": "Using the MeshRootCertificate to configure the OSM certificate provider is not supported",
453-
"examples": [
454-
false
455-
]
456-
}
457-
}
458-
},
459441
"trustDomain": {
460442
"$id": "#/properties/osm/properties/trustDomain",
461443
"type": "string",
@@ -1001,7 +983,8 @@
1001983
"enableIngressBackendPolicy",
1002984
"enableEnvoyActiveHealthChecks",
1003985
"enableSnapshotCacheMode",
1004-
"enableRetryPolicy"
986+
"enableRetryPolicy",
987+
"enableMeshRootCertificate"
1005988
],
1006989
"properties": {
1007990
"enableWASMStats": {
@@ -1066,6 +1049,15 @@
10661049
"examples": [
10671050
true
10681051
]
1052+
},
1053+
"enableMeshRootCertificate": {
1054+
"$id": "#/properties/osm/properties/featureFlags/properties/enableMeshRootCertificate",
1055+
"type": "boolean",
1056+
"title": "Enable the MeshRootCertificate",
1057+
"description": "Enable the MeshRootCertificate to configure the OSM certificate provider.",
1058+
"examples": [
1059+
false
1060+
]
10691061
}
10701062
},
10711063
"additionalProperties": false

charts/osm/values.yaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ osm:
167167
# The specified tolerations allow pods to schedule onto nodes with matching taints.
168168
tolerations: []
169169

170-
# -- Experimental values. Behavior is not supported.
171-
experimental:
172-
# -- Enable the MeshRootCertificate to configure the OSM certificate provider.
173-
enableMeshRootCertificate: false
174-
175170
# -- The trust domain to use as part of the common name when requesting new certificates.
176171
trustDomain: cluster.local
177172

@@ -203,7 +198,6 @@ osm:
203198
# -- The Kubernetes secret key with the value bring the Vault token
204199
key: ""
205200

206-
207201
#
208202
# -- cert-manager.io configuration
209203
certmanager:
@@ -488,6 +482,8 @@ osm:
488482
enableSnapshotCacheMode: false
489483
# -- Enable Retry Policy for automatic request retries
490484
enableRetryPolicy: false
485+
# -- Enable the MeshRootCertificate to configure the OSM certificate provider
486+
enableMeshRootCertificate: false
491487

492488
# -- Node tolerations applied to control plane pods.
493489
# The specified tolerations allow pods to schedule onto nodes with matching taints.

pkg/certificate/fake_manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ var (
2020

2121
type fakeMRCClient struct{}
2222

23-
func (c *fakeMRCClient) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (Issuer, pem.RootCertificate, string, error) {
24-
return &fakeIssuer{}, pem.RootCertificate("rootCA"), "fake-issuer-1", nil
23+
func (c *fakeMRCClient) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (Issuer, pem.RootCertificate, error) {
24+
return &fakeIssuer{}, pem.RootCertificate("rootCA"), nil
2525
}
2626

2727
// List returns the single, pre-generated MRC. It is intended to implement the certificate.MRCClient interface.

pkg/certificate/manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ func (m *Manager) handleMRCEvent(mrcClient MRCClient, event MRCEvent) error {
121121
return nil
122122
}
123123

124-
client, ca, clientID, err := mrcClient.GetCertIssuerForMRC(mrc)
124+
client, ca, err := mrcClient.GetCertIssuerForMRC(mrc)
125125
if err != nil {
126126
return err
127127
}
128128

129-
c := &issuer{Issuer: client, ID: clientID, CertificateAuthority: ca}
129+
c := &issuer{Issuer: client, ID: mrc.Name, CertificateAuthority: ca}
130130
switch {
131131
case mrc.Status.State == constants.MRCStateActive:
132132
m.mu.Lock()

pkg/certificate/providers/config.go

+23-24
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,35 @@ func NewCertificateManagerFromMRC(ctx context.Context, kubeClient kubernetes.Int
103103
}
104104

105105
// GetCertIssuerForMRC returns a certificate.Issuer generated from the provided MRC.
106-
func (c *MRCProviderGenerator) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, pem.RootCertificate, string, error) {
106+
func (c *MRCProviderGenerator) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, pem.RootCertificate, error) {
107107
p := mrc.Spec.Provider
108108
var issuer certificate.Issuer
109-
var id string
110109
var err error
111110
switch {
112111
case p.Tresor != nil:
113-
issuer, id, err = c.getTresorOSMCertificateManager(mrc)
112+
issuer, err = c.getTresorOSMCertificateManager(mrc)
114113
case p.Vault != nil:
115-
issuer, id, err = c.getHashiVaultOSMCertificateManager(mrc)
114+
issuer, err = c.getHashiVaultOSMCertificateManager(mrc)
116115
case p.CertManager != nil:
117-
issuer, id, err = c.getCertManagerOSMCertificateManager(mrc)
116+
issuer, err = c.getCertManagerOSMCertificateManager(mrc)
118117
default:
119-
return nil, nil, "", fmt.Errorf("Unknown certificate provider: %+v", p)
118+
return nil, nil, fmt.Errorf("Unknown certificate provider: %+v", p)
120119
}
121120

122121
if err != nil {
123-
return nil, nil, "", err
122+
return nil, nil, err
124123
}
125124

126125
ca, err := c.caExtractorFunc(issuer)
127126
if err != nil {
128-
return nil, nil, "", fmt.Errorf("error generating init cert: %w", err)
127+
return nil, nil, fmt.Errorf("error generating init cert: %w", err)
129128
}
130129

131-
return issuer, ca, id, nil
130+
return issuer, ca, nil
132131
}
133132

134133
// getTresorOSMCertificateManager returns a certificate manager instance with Tresor as the certificate provider
135-
func (c *MRCProviderGenerator) getTresorOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, string, error) {
134+
func (c *MRCProviderGenerator) getTresorOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, error) {
136135
var err error
137136
var rootCert *certificate.Certificate
138137

@@ -142,20 +141,20 @@ func (c *MRCProviderGenerator) getTresorOSMCertificateManager(mrc *v1alpha2.Mesh
142141
// Regardless of success or failure, all instances can proceed to load the same CA.
143142
rootCert, err = tresor.NewCA(constants.CertificationAuthorityCommonName, constants.CertificationAuthorityRootValidityPeriod, rootCertCountry, rootCertLocality, rootCertOrganization)
144143
if err != nil {
145-
return nil, "", errors.New("Failed to create new Certificate Authority with cert issuer tresor")
144+
return nil, errors.New("Failed to create new Certificate Authority with cert issuer tresor")
146145
}
147146

148147
if rootCert.GetPrivateKey() == nil {
149-
return nil, "", errors.New("Root cert does not have a private key")
148+
return nil, errors.New("Root cert does not have a private key")
150149
}
151150

152151
rootCert, err = k8s.GetCertificateFromSecret(mrc.Namespace, mrc.Spec.Provider.Tresor.CA.SecretRef.Name, rootCert, c.kubeClient)
153152
if err != nil {
154-
return nil, "", fmt.Errorf("Failed to synchronize certificate on Secrets API : %w", err)
153+
return nil, fmt.Errorf("Failed to synchronize certificate on Secrets API : %w", err)
155154
}
156155

157156
if rootCert.GetPrivateKey() == nil {
158-
return nil, "", fmt.Errorf("Root cert does not have a private key: %w", certificate.ErrInvalidCertSecret)
157+
return nil, fmt.Errorf("Root cert does not have a private key: %w", certificate.ErrInvalidCertSecret)
159158
}
160159

161160
tresorClient, err := tresor.New(
@@ -164,14 +163,14 @@ func (c *MRCProviderGenerator) getTresorOSMCertificateManager(mrc *v1alpha2.Mesh
164163
c.KeyBitSize,
165164
)
166165
if err != nil {
167-
return nil, "", fmt.Errorf("failed to instantiate Tresor as a Certificate Manager: %w", err)
166+
return nil, fmt.Errorf("failed to instantiate Tresor as a Certificate Manager: %w", err)
168167
}
169168

170-
return tresorClient, mrc.Name, nil
169+
return tresorClient, nil
171170
}
172171

173172
// getHashiVaultOSMCertificateManager returns a certificate manager instance with Hashi Vault as the certificate provider
174-
func (c *MRCProviderGenerator) getHashiVaultOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, string, error) {
173+
func (c *MRCProviderGenerator) getHashiVaultOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, error) {
175174
provider := mrc.Spec.Provider.Vault
176175

177176
// A Vault address would have the following shape: "http://vault.default.svc.cluster.local:8200"
@@ -184,7 +183,7 @@ func (c *MRCProviderGenerator) getHashiVaultOSMCertificateManager(mrc *v1alpha2.
184183
log.Debug().Msgf("Attempting to get Vault token from secret %s", provider.Token.SecretKeyRef.Name)
185184
vaultToken, err = getHashiVaultOSMToken(&provider.Token.SecretKeyRef, c.kubeClient)
186185
if err != nil {
187-
return nil, "", err
186+
return nil, err
188187
}
189188
}
190189

@@ -194,10 +193,10 @@ func (c *MRCProviderGenerator) getHashiVaultOSMCertificateManager(mrc *v1alpha2.
194193
provider.Role,
195194
)
196195
if err != nil {
197-
return nil, "", fmt.Errorf("error instantiating Hashicorp Vault as a Certificate Manager: %w", err)
196+
return nil, fmt.Errorf("error instantiating Hashicorp Vault as a Certificate Manager: %w", err)
198197
}
199198

200-
return vaultClient, mrc.Name, nil
199+
return vaultClient, nil
201200
}
202201

203202
// getHashiVaultOSMToken returns the Hashi Vault token from the secret specified in the provided secret key reference
@@ -216,11 +215,11 @@ func getHashiVaultOSMToken(secretKeyRef *v1alpha2.SecretKeyReferenceSpec, kubeCl
216215
}
217216

218217
// getCertManagerOSMCertificateManager returns a certificate manager instance with cert-manager as the certificate provider
219-
func (c *MRCProviderGenerator) getCertManagerOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, string, error) {
218+
func (c *MRCProviderGenerator) getCertManagerOSMCertificateManager(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, error) {
220219
provider := mrc.Spec.Provider.CertManager
221220
client, err := cmversionedclient.NewForConfig(c.kubeConfig)
222221
if err != nil {
223-
return nil, "", fmt.Errorf("Failed to build cert-manager client set: %s", err)
222+
return nil, fmt.Errorf("Failed to build cert-manager client set: %s", err)
224223
}
225224

226225
cmClient, err := certmanager.New(
@@ -234,8 +233,8 @@ func (c *MRCProviderGenerator) getCertManagerOSMCertificateManager(mrc *v1alpha2
234233
c.KeyBitSize,
235234
)
236235
if err != nil {
237-
return nil, "", fmt.Errorf("error instantiating Jetstack cert-manager client: %w", err)
236+
return nil, fmt.Errorf("error instantiating Jetstack cert-manager client: %w", err)
238237
}
239238

240-
return cmClient, mrc.Name, nil
239+
return cmClient, nil
241240
}

pkg/certificate/providers/tresor/fake/fake.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ const (
2222

2323
type fakeMRCClient struct{}
2424

25-
func (c *fakeMRCClient) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, pem.RootCertificate, string, error) {
25+
func (c *fakeMRCClient) GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (certificate.Issuer, pem.RootCertificate, error) {
2626
rootCertCountry := "US"
2727
rootCertLocality := "CA"
2828
ca, err := tresor.NewCA("Fake Tresor CN", 1*time.Hour, rootCertCountry, rootCertLocality, rootCertOrganization)
2929
if err != nil {
30-
return nil, nil, "", err
30+
return nil, nil, err
3131
}
3232
issuer, err := tresor.New(ca, rootCertOrganization, 2048)
33-
return issuer, pem.RootCertificate("rootCA"), "issuer-1", err
33+
return issuer, pem.RootCertificate("rootCA"), err
3434
}
3535

3636
// List returns the single, pre-generated MRC. It is intended to implement the certificate.MRCClient interface.

pkg/certificate/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type MRCClient interface {
123123
MRCEventBroker
124124

125125
// GetCertIssuerForMRC returns an Issuer based on the provided MRC.
126-
GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (Issuer, pem.RootCertificate, string, error)
126+
GetCertIssuerForMRC(mrc *v1alpha2.MeshRootCertificate) (Issuer, pem.RootCertificate, error)
127127
}
128128

129129
// MRCEventType is a type alias for a string describing the type of MRC event

0 commit comments

Comments
 (0)