@@ -155,7 +155,13 @@ func (k *KubernetesDriver) runContainer(
155155
156156 // env vars
157157 envVars := []corev1.EnvVar {}
158+ daemonConfig := ""
158159 for k , v := range options .Env {
160+ // filter out daemon config, that's going to be mounted through a secret
161+ if k == config .WorkspaceDaemonConfigExtraEnvVar {
162+ daemonConfig = v
163+ continue
164+ }
159165 envVars = append (envVars , corev1.EnvVar {
160166 Name : k ,
161167 Value : v ,
@@ -196,6 +202,16 @@ func (k *KubernetesDriver) runContainer(
196202 resources = parseResources (k .options .Resources , k .Log )
197203 }
198204
205+ // ensure daemon config secret
206+ daemonConfigSecretName := ""
207+ if daemonConfig != "" {
208+ daemonConfigSecretName = getDaemonSecretName (id )
209+ err = k .EnsureDaemonConfigSecret (ctx , daemonConfigSecretName , daemonConfig )
210+ if err != nil {
211+ return err
212+ }
213+ }
214+
199215 // ensure pull secrets
200216 pullSecretsCreated := false
201217 if k .options .KubernetesPullSecretsEnabled == "true" {
@@ -212,8 +228,8 @@ func (k *KubernetesDriver) runContainer(
212228 pod .Spec .ServiceAccountName = serviceAccount
213229 pod .Spec .NodeSelector = nodeSelector
214230 pod .Spec .InitContainers = initContainers
215- pod .Spec .Containers = getContainers (pod , options .Image , options .Entrypoint , options .Cmd , envVars , volumeMounts , capabilities , resources , options .Privileged , k .options .StrictSecurity )
216- pod .Spec .Volumes = getVolumes (pod , id )
231+ pod .Spec .Containers = getContainers (pod , options .Image , options .Entrypoint , options .Cmd , envVars , volumeMounts , capabilities , resources , options .Privileged , k .options .StrictSecurity , daemonConfigSecretName )
232+ pod .Spec .Volumes = getVolumes (pod , id , daemonConfigSecretName )
217233 // avoids a problem where attaching volumes with large repositories would cause an extremely long pod startup time
218234 // because changing the ownership of all files takes longer than the kubelet expects it to
219235 if pod .Spec .SecurityContext == nil {
@@ -311,7 +327,12 @@ func getContainers(
311327 resources corev1.ResourceRequirements ,
312328 privileged * bool ,
313329 strictSecurity string ,
330+ daemonConfigSecretName string ,
314331) []corev1.Container {
332+ volumeMounts = append (volumeMounts , corev1.VolumeMount {
333+ Name : "devpod-daemon-config" ,
334+ MountPath : "/var/run/secrets/devpod" ,
335+ })
315336 devPodContainer := corev1.Container {
316337 Name : DevContainerName ,
317338 Image : imageName ,
@@ -362,7 +383,7 @@ func getContainers(
362383 return retContainers
363384}
364385
365- func getVolumes (pod * corev1.Pod , id string ) []corev1.Volume {
386+ func getVolumes (pod * corev1.Pod , id string , daemonConfigSecretName string ) []corev1.Volume {
366387 volumes := []corev1.Volume {
367388 {
368389 Name : "devpod" ,
@@ -374,6 +395,17 @@ func getVolumes(pod *corev1.Pod, id string) []corev1.Volume {
374395 },
375396 }
376397
398+ if daemonConfigSecretName != "" {
399+ volumes = append (volumes , corev1.Volume {
400+ Name : "devpod-daemon-config" ,
401+ VolumeSource : corev1.VolumeSource {
402+ Secret : & corev1.SecretVolumeSource {
403+ SecretName : daemonConfigSecretName ,
404+ },
405+ },
406+ })
407+ }
408+
377409 if pod .Spec .Volumes != nil {
378410 volumes = append (volumes , pod .Spec .Volumes ... )
379411 }
@@ -467,6 +499,10 @@ func getPullSecretsName(workspaceID string) string {
467499 return fmt .Sprintf ("devpod-pull-secret-%s" , workspaceID )
468500}
469501
502+ func getDaemonSecretName (workspaceID string ) string {
503+ return fmt .Sprintf ("devpod-daemon-secret-%s" , workspaceID )
504+ }
505+
470506func optionsEqual (a , b * provider2.ProviderKubernetesDriverConfig ) bool {
471507 // copy a and b and the compare them without the context, config, namespace and podTimeout
472508 aCopy := * a
0 commit comments