@@ -62,6 +62,15 @@ func getKubeconfigMountPath(certName operatorv1alpha1.Certificate) string {
6262 return fmt .Sprintf ("/etc/kcp/%s-kubeconfig" , certName )
6363}
6464
65+ func getCacheServerKubeconfigMountPath () string {
66+ return "/etc/cache-server/kubeconfig"
67+ }
68+
69+ // getCacheServerCAMountPath has to match the code in the cacheserver package.
70+ func getCacheServerCAMountPath (caName operatorv1alpha1.CA ) string {
71+ return fmt .Sprintf ("/etc/cache-server/tls/ca/%s" , caName )
72+ }
73+
6574func DeploymentReconciler (rootShard * operatorv1alpha1.RootShard ) reconciling.NamedDeploymentReconcilerFactory {
6675 return func () (string , reconciling.DeploymentReconciler ) {
6776 return resources .GetRootShardDeploymentName (rootShard ), func (dep * appsv1.Deployment ) (* appsv1.Deployment , error ) {
@@ -132,6 +141,22 @@ func DeploymentReconciler(rootShard *operatorv1alpha1.RootShard) reconciling.Nam
132141 })
133142 }
134143
144+ // If an external CacheServer is meant to be used, mount its kubeconfig and the
145+ // certificate referenced in it.
146+ if ref := rootShard .Spec .Cache .Reference ; ref != nil {
147+ secretMounts = append (secretMounts , utils.SecretMount {
148+ VolumeName : "cache-server-kubeconfig" ,
149+ SecretName : resources .GetCacheServerKubeconfigName (ref .Name ),
150+ MountPath : getCacheServerKubeconfigMountPath (),
151+ })
152+
153+ secretMounts = append (secretMounts , utils.SecretMount {
154+ VolumeName : "cache-server-ca" ,
155+ SecretName : resources .GetCacheServerCAName (ref .Name , operatorv1alpha1 .RootCA ),
156+ MountPath : getCacheServerCAMountPath (operatorv1alpha1 .RootCA ),
157+ })
158+ }
159+
135160 volumes := []corev1.Volume {}
136161 volumeMounts := []corev1.VolumeMount {}
137162
@@ -212,5 +237,9 @@ func getArgs(rootShard *operatorv1alpha1.RootShard) []string {
212237 args = append (args , rootShard .Spec .ExtraArgs ... )
213238 }
214239
240+ if ref := rootShard .Spec .Cache .Reference ; ref != nil {
241+ args = append (args , fmt .Sprintf ("--cache-kubeconfig=%s/kubeconfig" , getCacheServerKubeconfigMountPath ()))
242+ }
243+
215244 return args
216245}
0 commit comments