mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-01 19:53:48 +00:00
feat(k8s): k8s priority class name config (#5391)
This commit is contained in:
parent
0eb10d1e04
commit
147256e3a8
4 changed files with 18 additions and 0 deletions
|
@ -404,3 +404,12 @@ Determines if containers must be required to run as non-root users.
|
|||
- Default: none
|
||||
|
||||
Secret names to pull images from private repositories. See, how to [Pull an Image from a Private Registry](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/).
|
||||
|
||||
---
|
||||
|
||||
### BACKEND_K8S_PRIORITY_CLASS
|
||||
|
||||
- Name: `WOODPECKER_BACKEND_K8S_PRIORITY_CLASS`
|
||||
- Default: none, which will use the default priority class configured in Kubernetes
|
||||
|
||||
Which [Kubernetes PriorityClass](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/priority-class-v1/) to assign to created job pods.
|
||||
|
|
|
@ -95,4 +95,10 @@ var Flags = []cli.Flag{
|
|||
Usage: "whether to allow existing Kubernetes secrets to be referenced from steps",
|
||||
Value: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_PRIORITY_CLASS"),
|
||||
Name: "backend-k8s-priority-class",
|
||||
Usage: "which kubernetes priority class to assign to created job pods",
|
||||
Value: "",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ type config struct {
|
|||
ImagePullSecretNames []string
|
||||
SecurityContext SecurityContextConfig
|
||||
NativeSecretsAllowFromStep bool
|
||||
PriorityClassName string
|
||||
}
|
||||
|
||||
func (c *config) GetNamespace(orgID int64) string {
|
||||
|
@ -103,6 +104,7 @@ func configFromCliContext(ctx context.Context) (*config, error) {
|
|||
StorageClass: c.String("backend-k8s-storage-class"),
|
||||
VolumeSize: c.String("backend-k8s-volume-size"),
|
||||
StorageRwx: c.Bool("backend-k8s-storage-rwx"),
|
||||
PriorityClassName: c.String("backend-k8s-priority-class"),
|
||||
PodLabels: make(map[string]string), // just init empty map to prevent nil panic
|
||||
PodLabelsAllowFromStep: c.Bool("backend-k8s-pod-labels-allow-from-step"),
|
||||
PodAnnotations: make(map[string]string), // just init empty map to prevent nil panic
|
||||
|
|
|
@ -173,6 +173,7 @@ func podSpec(step *types.Step, config *config, options BackendOptions, nsp nativ
|
|||
RestartPolicy: v1.RestartPolicyNever,
|
||||
RuntimeClassName: options.RuntimeClassName,
|
||||
ServiceAccountName: options.ServiceAccountName,
|
||||
PriorityClassName: config.PriorityClassName,
|
||||
HostAliases: hostAliases(step.ExtraHosts),
|
||||
NodeSelector: nodeSelector(options.NodeSelector, config.PodNodeSelector, step.Environment["CI_SYSTEM_PLATFORM"]),
|
||||
Tolerations: tolerations(options.Tolerations),
|
||||
|
|
Loading…
Reference in a new issue