Follow up to #2054: move magic strings into constants (#2122)

Follow up to #2054: move magic strings into constants

Signed-off-by: Alejandro Pedraza <alejandro@buoyant.io>
This commit is contained in:
Alejandro Pedraza 2019-01-22 14:53:24 -05:00 committed by GitHub
parent a5628780f7
commit eacc09b7ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 13 deletions

View File

@ -292,7 +292,7 @@ func injectPodSpec(t *v1.PodSpec, identity k8s.TLSIdentity, controlPlaneDNSNameO
yes := true yes := true
configMapVolume := v1.Volume{ configMapVolume := v1.Volume{
Name: "linkerd-trust-anchors", Name: k8s.TLSTrustAnchorVolumeName,
VolumeSource: v1.VolumeSource{ VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{ ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{Name: k8s.TLSTrustAnchorConfigMapName}, LocalObjectReference: v1.LocalObjectReference{Name: k8s.TLSTrustAnchorConfigMapName},
@ -301,7 +301,7 @@ func injectPodSpec(t *v1.PodSpec, identity k8s.TLSIdentity, controlPlaneDNSNameO
}, },
} }
secretVolume := v1.Volume{ secretVolume := v1.Volume{
Name: "linkerd-secrets", Name: k8s.TLSSecretsVolumeName,
VolumeSource: v1.VolumeSource{ VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{ Secret: &v1.SecretVolumeSource{
SecretName: identity.ToSecretName(), SecretName: identity.ToSecretName(),

View File

@ -33,6 +33,8 @@ type installConfig struct {
CreatedByAnnotation string CreatedByAnnotation string
ProxyAPIPort uint ProxyAPIPort uint
EnableTLS bool EnableTLS bool
TLSTrustAnchorVolumeName string
TLSSecretsVolumeName string
TLSTrustAnchorConfigMapName string TLSTrustAnchorConfigMapName string
ProxyContainerName string ProxyContainerName string
TLSTrustAnchorFileName string TLSTrustAnchorFileName string
@ -174,6 +176,8 @@ func validateAndBuildConfig(options *installOptions) (*installConfig, error) {
CreatedByAnnotation: k8s.CreatedByAnnotation, CreatedByAnnotation: k8s.CreatedByAnnotation,
ProxyAPIPort: options.proxyAPIPort, ProxyAPIPort: options.proxyAPIPort,
EnableTLS: options.enableTLS(), EnableTLS: options.enableTLS(),
TLSTrustAnchorVolumeName: k8s.TLSTrustAnchorVolumeName,
TLSSecretsVolumeName: k8s.TLSSecretsVolumeName,
TLSTrustAnchorConfigMapName: k8s.TLSTrustAnchorConfigMapName, TLSTrustAnchorConfigMapName: k8s.TLSTrustAnchorConfigMapName,
ProxyContainerName: k8s.ProxyContainerName, ProxyContainerName: k8s.ProxyContainerName,
TLSTrustAnchorFileName: k8s.TLSTrustAnchorFileName, TLSTrustAnchorFileName: k8s.TLSTrustAnchorFileName,

View File

@ -39,6 +39,8 @@ func TestRender(t *testing.T) {
CreatedByAnnotation: "CreatedByAnnotation", CreatedByAnnotation: "CreatedByAnnotation",
ProxyAPIPort: 123, ProxyAPIPort: 123,
EnableTLS: true, EnableTLS: true,
TLSTrustAnchorVolumeName: "TLSTrustAnchorVolumeName",
TLSSecretsVolumeName: "TLSSecretsVolumeName",
TLSTrustAnchorConfigMapName: "TLSTrustAnchorConfigMapName", TLSTrustAnchorConfigMapName: "TLSTrustAnchorConfigMapName",
ProxyContainerName: "ProxyContainerName", ProxyContainerName: "ProxyContainerName",
TLSTrustAnchorFileName: "TLSTrustAnchorFileName", TLSTrustAnchorFileName: "TLSTrustAnchorFileName",

View File

@ -1218,7 +1218,7 @@ spec:
runAsUser: 2103 runAsUser: 2103
volumeMounts: volumeMounts:
- mountPath: /var/linkerd-io/trust-anchors - mountPath: /var/linkerd-io/trust-anchors
name: linkerd-trust-anchors name: TLSTrustAnchorVolumeName
readOnly: true readOnly: true
- mountPath: /var/linkerd-io/identity - mountPath: /var/linkerd-io/identity
name: webhook-secrets name: webhook-secrets
@ -1450,18 +1450,18 @@ data:
terminationMessagePolicy: FallbackToLogsOnError terminationMessagePolicy: FallbackToLogsOnError
volumeMounts: volumeMounts:
- mountPath: /var/linkerd-io/trust-anchors - mountPath: /var/linkerd-io/trust-anchors
name: linkerd-trust-anchors name: TLSTrustAnchorVolumeName
readOnly: true readOnly: true
- mountPath: /var/linkerd-io/identity - mountPath: /var/linkerd-io/identity
name: linkerd-secrets name: TLSSecretsVolumeName
readOnly: true readOnly: true
TLSTrustAnchorVolumeSpecFileName: | TLSTrustAnchorVolumeSpecFileName: |
name: linkerd-trust-anchors name: TLSTrustAnchorVolumeName
configMap: configMap:
name: TLSTrustAnchorConfigMapName name: TLSTrustAnchorConfigMapName
optional: true optional: true
TLSIdentityVolumeSpecFileName: | TLSIdentityVolumeSpecFileName: |
name: linkerd-secrets name: TLSSecretsVolumeName
secret: secret:
secretName: "" # this value will be computed by the webhook secretName: "" # this value will be computed by the webhook
optional: true optional: true

View File

@ -144,7 +144,7 @@ func uninjectPodSpec(t *v1.PodSpec, report *injectReport) {
volumes := []v1.Volume{} volumes := []v1.Volume{}
for _, volume := range t.Volumes { for _, volume := range t.Volumes {
// TODO: move those strings to constants // TODO: move those strings to constants
if volume.Name != "linkerd-trust-anchors" && volume.Name != "linkerd-secrets" { if volume.Name != k8s.TLSTrustAnchorVolumeName && volume.Name != k8s.TLSSecretsVolumeName {
volumes = append(volumes, volume) volumes = append(volumes, volume)
} }
} }

View File

@ -922,7 +922,7 @@ spec:
- name: proxy-injector - name: proxy-injector
containerPort: 8443 containerPort: 8443
volumeMounts: volumeMounts:
- name: linkerd-trust-anchors - name: {{.TLSTrustAnchorVolumeName}}
mountPath: /var/linkerd-io/trust-anchors mountPath: /var/linkerd-io/trust-anchors
readOnly: true readOnly: true
- name: webhook-secrets - name: webhook-secrets
@ -1117,18 +1117,18 @@ data:
terminationMessagePolicy: FallbackToLogsOnError terminationMessagePolicy: FallbackToLogsOnError
volumeMounts: volumeMounts:
- mountPath: /var/linkerd-io/trust-anchors - mountPath: /var/linkerd-io/trust-anchors
name: linkerd-trust-anchors name: {{.TLSTrustAnchorVolumeName}}
readOnly: true readOnly: true
- mountPath: /var/linkerd-io/identity - mountPath: /var/linkerd-io/identity
name: linkerd-secrets name: {{.TLSSecretsVolumeName}}
readOnly: true readOnly: true
{{.TLSTrustAnchorVolumeSpecFileName}}: | {{.TLSTrustAnchorVolumeSpecFileName}}: |
name: linkerd-trust-anchors name: {{.TLSTrustAnchorVolumeName}}
configMap: configMap:
name: {{.TLSTrustAnchorConfigMapName}} name: {{.TLSTrustAnchorConfigMapName}}
optional: true optional: true
{{.TLSIdentityVolumeSpecFileName}}: | {{.TLSIdentityVolumeSpecFileName}}: |
name: linkerd-secrets name: {{.TLSSecretsVolumeName}}
secret: secret:
secretName: "" # this value will be computed by the webhook secretName: "" # this value will be computed by the webhook
optional: true optional: true

View File

@ -104,6 +104,14 @@ const (
// proxy-injector ConfigMap that contains the proxy-init container spec. // proxy-injector ConfigMap that contains the proxy-init container spec.
ProxyInitSpecFileName = "proxy-init.yaml" ProxyInitSpecFileName = "proxy-init.yaml"
// TLSTrustAnchorVolumeName is the name of the trust anchor volume,
// used when injecting a proxy with TLS enabled.
TLSTrustAnchorVolumeName = "linkerd-trust-anchors"
// TLSSecretsVolumeName is the name of the volume holding the secrets,
// when injecting a proxy with TLS enabled.
TLSSecretsVolumeName = "linkerd-secrets"
// TLSTrustAnchorVolumeSpecFileName is the name (key) within the // TLSTrustAnchorVolumeSpecFileName is the name (key) within the
// proxy-injector ConfigMap that contains the trust anchors volume spec. // proxy-injector ConfigMap that contains the trust anchors volume spec.
TLSTrustAnchorVolumeSpecFileName = "linkerd-trust-anchors.yaml" TLSTrustAnchorVolumeSpecFileName = "linkerd-trust-anchors.yaml"