Skip to content

Commit

Permalink
Add ARO HCP environment vars to CSI deployment
Browse files Browse the repository at this point in the history
This commit adds environment variables needed by a CSI deployment for
ARO HCP.

Signed-off-by: Bryan Cox <[email protected]>
  • Loading branch information
bryan-cox committed Oct 10, 2024
1 parent 548b4cb commit dd4cefe
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/operator/csidriveroperator/hypershift_deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ func (c *HyperShiftDeploymentController) Sync(ctx context.Context, syncCtx facto
return fmt.Errorf("failed to inject proxy data into deployment: %w", err)
}

// The existence of the environment variable, ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE, means this is an ARO HCP
// deployment. We need to pass along additional environment variables for ARO HCP in order to mount the backing
// certificates, related to the client IDs, in a volume on the azure-disk-csi-controller and a
// zure-file-csi-controller deployments.
if os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE") != "" {
envVars := []corev1.EnvVar{
{Name: "AZURE_CLIENT_ID_FOR_FILE", Value: os.Getenv("AZURE_CLIENT_ID_FOR_FILE")},
{Name: "AZURE_CLIENT_CERTIFICATE_PATH_FOR_FILE", Value: os.Getenv("AZURE_CLIENT_CERTIFICATE_PATH_FOR_FILE")},
{Name: "ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE", Value: os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_FILE")},

{Name: "AZURE_CLIENT_ID_FOR_DISK", Value: os.Getenv("AZURE_CLIENT_ID_FOR_DISK")},
{Name: "AZURE_CLIENT_CERTIFICATE_PATH_FOR_DISK", Value: os.Getenv("AZURE_CLIENT_CERTIFICATE_PATH_FOR_DISK")},
{Name: "ARO_HCP_SECRET_PROVIDER_CLASS_FOR_DISK", Value: os.Getenv("ARO_HCP_SECRET_PROVIDER_CLASS_FOR_DISK")},

{Name: "AZURE_TENANT_ID", Value: os.Getenv("AZURE_TENANT_ID")},
}

required.Spec.Template.Spec.Containers[0].Env = append(required.Spec.Template.Spec.Containers[0].Env, envVars...)
}

lastGeneration := resourcemerge.ExpectedDeploymentGeneration(requiredCopy, opStatus.Generations)
deployment, _, err := resourceapply.ApplyDeployment(ctx, c.mgmtClient.KubeClient.AppsV1(), c.eventRecorder, requiredCopy, lastGeneration)
if err != nil {
Expand Down

0 comments on commit dd4cefe

Please sign in to comment.