-
Notifications
You must be signed in to change notification settings - Fork 10
feat(kubernetes): Add PipelinePodsTemplate CRD to define worker-specific Pod defaults for Kubernetes Runtime #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9daffd1
feat(k8s): Define PipelinePodsTemplate CRD
cognifloyd 19a183a
chore: Add crd generation targets to Makefile
cognifloyd 718d9bd
chore: Generate client for PipelinePodsTemplate CRD
cognifloyd ed28cf6
chore: Generate PipelinePodsTemplate CRD manifest
cognifloyd 5dcb8a3
feat(k8s): Add PipelinePodsTemplate loading opts
cognifloyd 7d7f1e9
feat(k8s): Get PipelinePodsTemplate from k8s API
cognifloyd 020421a
feat(k8s): Get defaults from PipelinePodTemplate
cognifloyd 7c261a2
chore: Add tests for runtime WithPodsTemplate opt
cognifloyd f5837d7
chore: Add tests for runtime WithPodsTemplate opt (failure path)
cognifloyd 040cbae
chore: Extend k8s SetupBuild test to use WithPodsTemplate
cognifloyd f8b4d5f
chore: Extend k8s SetupBuild test PipelinePodsTemplate missing in k8s
cognifloyd 1552e6e
chore: Extend k8s SetupBuild test with mocked PipelinePodsTemplate in…
cognifloyd 6703202
fix(kubernetes): use sigs.k8s.io/yaml instead of buildkite/yaml
cognifloyd 77ed714
feat(kubernetes): ensure local PipelinePodsTemplate YAML is valid
cognifloyd 5558f17
Merge branch 'master' into k8s-pods-templates
cognifloyd e7ca84a
chore: test ignoring k8s labels from PipelinePodsTemplate
cognifloyd 3ac92fb
chore: test CRD with DNS or node selection
cognifloyd 504c15f
refactor(k8s): simplify setting container.SecurityContext
cognifloyd 2574d97
chore(kubernetes): ensure PipelinePodsTemplate contents get into Pod …
cognifloyd eabfd5b
chore(kubernetes): test SetupContainer with privileged container
cognifloyd 2e6d35b
chore: satisfy lint
cognifloyd 060d1f8
chore: Add instructional comments with links to docs
cognifloyd 8bdca0b
Merge branch 'master' into k8s-pods-templates
cognifloyd 097973a
Adjust comment location
cognifloyd 156980a
chore: update opts FilePath to use _ over -
cognifloyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat(k8s): Define PipelinePodsTemplate CRD
The CRD is defined under runtime/kurbernetes/apis Other pieces will be generated under runtime/kubernetes/generated
- Loading branch information
commit 9daffd1e9a3e7f376b7abbaa0d76890710aae640
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by the LICENSE file in this repository. | ||
|
|
||
| // Package apis defines the worker-config CRD and related utilities. | ||
| // | ||
| // Usage: | ||
| // | ||
| // import "github.com/go-vela/worker/runtime/kubernetes/apis" | ||
| package apis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by the LICENSE file in this repository. | ||
|
|
||
| package vela | ||
|
|
||
| // GroupName is the group name used in this package. | ||
| const ( | ||
| GroupName = "go-vela.github.io" | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by the LICENSE file in this repository. | ||
|
|
||
| // Package v1alpha1 defines version 1alpha1 of the worker-config CRD. | ||
| // | ||
| // Usage: | ||
| // | ||
| // import "github.com/go-vela/worker/runtime/kubernetes/apis/v1alpha1" | ||
| package v1alpha1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by the LICENSE file in this repository. | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
|
|
||
| "github.com/go-vela/worker/runtime/kubernetes/apis/vela" | ||
| ) | ||
|
|
||
| // SchemeGroupVersion is group version used to register these objects. | ||
| var SchemeGroupVersion = schema.GroupVersion{Group: vela.GroupName, Version: "v1alpha1"} | ||
|
|
||
| // Kind takes an unqualified kind and returns a Group qualified GroupKind. | ||
| func Kind(kind string) schema.GroupKind { | ||
| return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
| } | ||
|
|
||
| // Resource takes an unqualified resource and returns a Group qualified GroupResource. | ||
| func Resource(resource string) schema.GroupResource { | ||
| return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
| } | ||
|
|
||
| var ( | ||
| // SchemeBuilder initializes a scheme builder. | ||
| SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
| // AddToScheme is a global function that registers this API group & version to a scheme. | ||
| AddToScheme = SchemeBuilder.AddToScheme | ||
| ) | ||
|
|
||
| // addKnownTypes adds the list of known types to Scheme. | ||
| func addKnownTypes(scheme *runtime.Scheme) error { | ||
| scheme.AddKnownTypes(SchemeGroupVersion, | ||
| &PipelinePodsTemplate{}, | ||
| &PipelinePodsTemplateList{}, | ||
| ) | ||
| metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
| // | ||
| // Use of this source code is governed by the LICENSE file in this repository. | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| v1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // PipelinePodsTemplate defines the config for a given worker. | ||
| type PipelinePodsTemplate struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| // Standard object's metadata. | ||
| // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| // Spec defines the PipelinePodsTemplate configuration for Vela Workers. | ||
| Spec PipelinePodsTemplateSpec `json:"spec,omitempty"` | ||
| } | ||
|
|
||
| // PipelinePodsTemplateSpec configures creation of Pipeline Pods by Vela Workers. | ||
| type PipelinePodsTemplateSpec struct { | ||
| // Template defines defaults for Pipeline Pod creation in Vela Workers. | ||
| Template PipelinePodTemplate `json:"template"` | ||
| } | ||
|
|
||
| // PipelinePodTemplate describes the data defaults to use when creating each pipeline pod. | ||
| type PipelinePodTemplate struct { | ||
| // Meta contains a subset of the standard object metadata (see: metav1.ObjectMeta). | ||
| Meta PipelinePodTemplateMeta `json:"metadata,omitempty"` | ||
|
|
||
| // Spec contains a subset of the pod configuration options (see: v1.PodSpec). | ||
| Spec PipelinePodTemplateSpec `json:"spec,omitempty"` | ||
| } | ||
|
|
||
| // PipelinePodTemplateMeta is a subset of metav1.ObjectMeta with meta defaults for pipeline pods. | ||
| type PipelinePodTemplateMeta struct { | ||
| // Labels is a key value map of strings to organize and categorize pods. | ||
| // More info: http://kubernetes.io/docs/user-guide/labels | ||
| Labels map[string]string `json:"labels,omitempty"` | ||
|
|
||
| // Annotations is a key value map of strings to store additional info on pods. | ||
| // More info: http://kubernetes.io/docs/user-guide/annotations | ||
| Annotations map[string]string `json:"annotations,omitempty"` | ||
| } | ||
|
|
||
| // PipelinePodTemplateSpec is (loosely) a subset of v1.PodSpec with spec defaults for pipeline pods. | ||
| type PipelinePodTemplateSpec struct { | ||
| // NodeSelector is a selector which must be true for the pipeline pod to fit on a node. | ||
| // Selector which must match a node's labels for the pod to be scheduled on that node. | ||
| // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | ||
| // +mapType=atomic | ||
| NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
| // Affinity specifies the pipeline pod's scheduling constraints, if any. | ||
| Affinity *v1.Affinity `json:"affinity,omitempty"` | ||
| // Affinity specifies the pipeline pod's tolerations, if any. | ||
| Tolerations []v1.Toleration `json:"tolerations,omitempty"` | ||
|
|
||
| // DNSPolicy sets DNS policy for the pipeline pod. | ||
| // Defaults to "ClusterFirst". | ||
| // Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. | ||
| DNSPolicy v1.DNSPolicy `json:"dnsPolicy,omitempty"` | ||
| // DNSConfig specifies the DNS parameters of a pod. | ||
| // Parameters specified here will be merged to the generated DNS | ||
| // configuration based on DNSPolicy. | ||
| DNSConfig *v1.PodDNSConfig `json:"dnsConfig,omitempty"` | ||
|
|
||
| // Container defines a limited set of defaults to apply to each PipelinePodsTemplate container. | ||
| // This is analogous to one entry in v1.PodSpec.Containers. | ||
| Container *PipelineContainer `json:"container,omitempty"` | ||
|
|
||
| // SecurityContext holds pod-level security attributes and common container settings. | ||
| // Optional: Defaults to empty. See type description for default values of each field. | ||
| SecurityContext *PipelinePodSecurityContext `json:"securityContext,omitempty"` | ||
| } | ||
|
|
||
| // PipelineContainer has defaults for containers in a PipelinePodsTemplate. | ||
| type PipelineContainer struct { | ||
| // SecurityContext defines the security options the container should be run with. | ||
| // If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. | ||
| // More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ | ||
| SecurityContext *PipelineContainerSecurityContext `json:"securityContext,omitempty"` | ||
| } | ||
|
|
||
| // PipelinePodSecurityContext holds pod-level security attributes and common container settings. | ||
| type PipelinePodSecurityContext struct { | ||
| // RunAsNonRoot indicates that the container must run as a non-root user. | ||
| // If true, the Kubelet will validate the image at runtime to ensure that it | ||
| // does not run as UID 0 (root) and fail to start the container if it does. | ||
| // If unset or false, no such validation will be performed. | ||
| RunAsNonRoot *bool `json:"runAsNonRoot,omitempty"` | ||
| // Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported | ||
| // sysctls (by the container runtime) might fail to launch. | ||
| // Note that this field cannot be set when spec.os.name is windows. | ||
| Sysctls []v1.Sysctl `json:"sysctls,omitempty"` | ||
| } | ||
|
|
||
| // PipelineContainerSecurityContext holds container-level security configuration. | ||
| type PipelineContainerSecurityContext struct { | ||
| // Capabilities contains the capabilities to add/drop when running containers. | ||
| // Defaults to the default set of capabilities granted by the container runtime. | ||
| // Note that this field cannot be set when spec.os.name is windows. | ||
| Capabilities *v1.Capabilities `json:"capabilities,omitempty"` | ||
| } | ||
|
|
||
| // PipelinePodsTemplateList is a list of Deployments. | ||
| type PipelinePodsTemplateList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| // Standard list metadata. | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
|
|
||
| // Items is the list of Deployments. | ||
| Items []PipelinePodsTemplate `json:"items"` | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.