Skip to content

Commit

Permalink
Merge pull request #93 from saswatamcode/resources
Browse files Browse the repository at this point in the history
Add ability to specify ResourceRequirements per container
  • Loading branch information
saswatamcode authored Sep 7, 2024
2 parents e34fa88 + 91e624c commit d4c5386
Show file tree
Hide file tree
Showing 22 changed files with 652 additions and 121 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply --server-side -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand All @@ -181,7 +181,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/default | $(KUBECTL) apply --server-side -f -

.PHONY: undeploy
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
Expand Down
9 changes: 6 additions & 3 deletions api/v1alpha1/thanosreceive_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (

// RouterSpec represents the configuration for the router
type RouterSpec struct {
// CommonThanosFields are the options available to all Thanos components.
// +kubebuilder:validation:Optional
CommonThanosFields `json:",inline"`
// Labels are additional labels to add to the router components.
// Labels set here will overwrite the labels inherited from the ThanosReceive object if they have the same key.
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -49,6 +52,9 @@ type RouterSpec struct {

// IngesterSpec represents the configuration for the ingestor
type IngesterSpec struct {
// CommonThanosFields are the options available to all Thanos components.
// +kubebuilder:validation:Optional
CommonThanosFields `json:",inline"`
// DefaultObjectStorageConfig is the secret that contains the object storage configuration for the ingest components.
// Can be overridden by the ObjectStorageConfig in the IngestorHashringSpec per hashring.
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -113,9 +119,6 @@ type IngestorHashringSpec struct {
// ThanosReceiveSpec defines the desired state of ThanosReceive
// +kubebuilder:validation:XValidation:rule="self.ingestor.hashrings.all(h, h.replicas >= self.router.replicationFactor )", message=" Ingester replicas must be greater than or equal to the Router replicas"
type ThanosReceiveSpec struct {
// CommonThanosFields are the options available to all Thanos components.
// +kubebuilder:validation:Optional
CommonThanosFields `json:",inline"`
// Router is the configuration for the router.
// +kubebuilder:validation:Required
Router RouterSpec `json:"router,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type CommonThanosFields struct {
// See http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
// +kubebuilder:validation:Optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// ResourceRequirements for the Thanos component container.
// +kubebuilder:validation:Optional
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
// When a resource is paused, no actions except for deletion
// will be performed on the underlying objects.
// +kubebuilder:validation:Optional
Expand Down
8 changes: 7 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions config/crd/bases/monitoring.thanos.io_thanoscompacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,65 @@ spec:
When a resource is paused, no actions except for deletion
will be performed on the underlying objects.
type: boolean
resourceRequirements:
description: ResourceRequirements for the Thanos component container.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
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. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
retentionConfig:
description: RetentionConfig is the retention configuration for the
compact component.
Expand Down
118 changes: 118 additions & 0 deletions config/crd/bases/monitoring.thanos.io_thanosqueries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7325,6 +7325,65 @@ spec:
format: int32
minimum: 1
type: integer
resourceRequirements:
description: ResourceRequirements for the Thanos component container.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
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. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
version:
description: |-
Version of Thanos to be deployed.
Expand All @@ -7338,6 +7397,65 @@ spec:
format: int32
minimum: 1
type: integer
resourceRequirements:
description: ResourceRequirements for the Thanos component container.
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
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. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
version:
description: |-
Version of Thanos to be deployed.
Expand Down
Loading

0 comments on commit d4c5386

Please sign in to comment.