feat: allow specifying runtime class in runner spec (#580)
This allows using the `runtimeClassName` directive in the runner's spec. One of the use-cases for this is Kata Containers, which use `runtimeClassName` in a pod spec as an indicator that the pod should run inside a Kata container. This allows us a greater degree of pod isolation.
This commit is contained in:
		
							parent
							
								
									30ab0c0b71
								
							
						
					
					
						commit
						7523ea44f1
					
				|  | @ -771,7 +771,7 @@ spec: | ||||||
|       # - https://cloud.google.com/container-registry/docs/pulling-cached-images |       # - https://cloud.google.com/container-registry/docs/pulling-cached-images | ||||||
|       dockerRegistryMirror: https://mirror.gcr.io/ |       dockerRegistryMirror: https://mirror.gcr.io/ | ||||||
|       # false (default) = Docker support is provided by a sidecar container deployed in the runner pod. |       # false (default) = Docker support is provided by a sidecar container deployed in the runner pod. | ||||||
|       # true = No docker sidecar container is deployed in the runner pod but docker can be used within teh runner container instead. The image summerwind/actions-runner-dind is used by default. |       # true = No docker sidecar container is deployed in the runner pod but docker can be used within the runner container instead. The image summerwind/actions-runner-dind is used by default. | ||||||
|       dockerdWithinRunnerContainer: true |       dockerdWithinRunnerContainer: true | ||||||
|       # Docker sidecar container image tweaks examples below, only applicable if dockerdWithinRunnerContainer = false |       # Docker sidecar container image tweaks examples below, only applicable if dockerdWithinRunnerContainer = false | ||||||
|       dockerdContainerResources: |       dockerdContainerResources: | ||||||
|  | @ -805,6 +805,10 @@ spec: | ||||||
|       dockerVolumeMounts: |       dockerVolumeMounts: | ||||||
|         - mountPath: /var/lib/docker |         - mountPath: /var/lib/docker | ||||||
|           name: docker-extra |           name: docker-extra | ||||||
|  |       # Optional name of the container runtime configuration that should be used for pods. | ||||||
|  |       # This must match the name of a RuntimeClass resource available on the cluster. | ||||||
|  |       # More info: https://kubernetes.io/docs/concepts/containers/runtime-class | ||||||
|  |       runtimeClassName: "runc" | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ### Runner Labels | ### Runner Labels | ||||||
|  |  | ||||||
|  | @ -107,6 +107,11 @@ type RunnerSpec struct { | ||||||
| 	HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` | 	HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` | ||||||
| 	// +optional
 | 	// +optional
 | ||||||
| 	VolumeSizeLimit *resource.Quantity `json:"volumeSizeLimit,omitempty"` | 	VolumeSizeLimit *resource.Quantity `json:"volumeSizeLimit,omitempty"` | ||||||
|  | 
 | ||||||
|  | 	// RuntimeClassName is the container runtime configuration that containers should run under.
 | ||||||
|  | 	// More info: https://kubernetes.io/docs/concepts/containers/runtime-class
 | ||||||
|  | 	// +optional
 | ||||||
|  | 	RuntimeClassName *string `json:"runtimeClassName,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ValidateRepository validates repository field.
 | // ValidateRepository validates repository field.
 | ||||||
|  |  | ||||||
|  | @ -791,6 +791,11 @@ func (in *RunnerSpec) DeepCopyInto(out *RunnerSpec) { | ||||||
| 		x := (*in).DeepCopy() | 		x := (*in).DeepCopy() | ||||||
| 		*out = &x | 		*out = &x | ||||||
| 	} | 	} | ||||||
|  | 	if in.RuntimeClassName != nil { | ||||||
|  | 		in, out := &in.RuntimeClassName, &out.RuntimeClassName | ||||||
|  | 		*out = new(string) | ||||||
|  | 		**out = **in | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunnerSpec.
 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunnerSpec.
 | ||||||
|  |  | ||||||
|  | @ -688,6 +688,9 @@ spec: | ||||||
|                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                           type: object |                           type: object | ||||||
|                       type: object |                       type: object | ||||||
|  |                     runtimeClassName: | ||||||
|  |                       description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |                       type: string | ||||||
|                     securityContext: |                     securityContext: | ||||||
|                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|                       properties: |                       properties: | ||||||
|  |  | ||||||
|  | @ -685,6 +685,9 @@ spec: | ||||||
|                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                           type: object |                           type: object | ||||||
|                       type: object |                       type: object | ||||||
|  |                     runtimeClassName: | ||||||
|  |                       description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |                       type: string | ||||||
|                     securityContext: |                     securityContext: | ||||||
|                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|                       properties: |                       properties: | ||||||
|  |  | ||||||
|  | @ -650,6 +650,9 @@ spec: | ||||||
|                   description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                   description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                   type: object |                   type: object | ||||||
|               type: object |               type: object | ||||||
|  |             runtimeClassName: | ||||||
|  |               description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |               type: string | ||||||
|             securityContext: |             securityContext: | ||||||
|               description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |               description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|               properties: |               properties: | ||||||
|  |  | ||||||
|  | @ -688,6 +688,9 @@ spec: | ||||||
|                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                           type: object |                           type: object | ||||||
|                       type: object |                       type: object | ||||||
|  |                     runtimeClassName: | ||||||
|  |                       description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |                       type: string | ||||||
|                     securityContext: |                     securityContext: | ||||||
|                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|                       properties: |                       properties: | ||||||
|  |  | ||||||
|  | @ -685,6 +685,9 @@ spec: | ||||||
|                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                           description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                           type: object |                           type: object | ||||||
|                       type: object |                       type: object | ||||||
|  |                     runtimeClassName: | ||||||
|  |                       description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |                       type: string | ||||||
|                     securityContext: |                     securityContext: | ||||||
|                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |                       description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|                       properties: |                       properties: | ||||||
|  |  | ||||||
|  | @ -650,6 +650,9 @@ spec: | ||||||
|                   description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' |                   description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||||||
|                   type: object |                   type: object | ||||||
|               type: object |               type: object | ||||||
|  |             runtimeClassName: | ||||||
|  |               description: 'RuntimeClassName is the container runtime configuration that containers should run under. More info: https://kubernetes.io/docs/concepts/containers/runtime-class' | ||||||
|  |               type: string | ||||||
|             securityContext: |             securityContext: | ||||||
|               description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. |               description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext.  Field values of container.securityContext take precedence over field values of PodSecurityContext. | ||||||
|               properties: |               properties: | ||||||
|  |  | ||||||
|  | @ -910,6 +910,10 @@ func (r *RunnerReconciler) newPod(runner v1alpha1.Runner) (corev1.Pod, error) { | ||||||
| 		pod.Spec.HostAliases = runner.Spec.HostAliases | 		pod.Spec.HostAliases = runner.Spec.HostAliases | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if runner.Spec.RuntimeClassName != nil { | ||||||
|  | 		pod.Spec.RuntimeClassName = runner.Spec.RuntimeClassName | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if err := ctrl.SetControllerReference(&runner, &pod, r.Scheme); err != nil { | 	if err := ctrl.SetControllerReference(&runner, &pod, r.Scheme); err != nil { | ||||||
| 		return pod, err | 		return pod, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue