Skip to content

Commit

Permalink
Add metabase spec vars
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuCesbron committed Feb 13, 2024
1 parent 41561d3 commit feca1ad
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 11 deletions.
27 changes: 27 additions & 0 deletions api/v1/metabase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,32 @@ type MetabaseSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +kubebuilder:validation:Required
Metabase MetabasePodSpec `json:"metabase"`

// +kubebuilder:validation:Required
DB DBSpec `json:"db"`
}

type MetabasePodSpec struct {
// The image name to use for Metabase container.
// +kubebuilder:default="metabase/metabase:latest"
// +kubebuilder:validation:Optional
Image string `json:"image,omitempty"`

// ImagePullPolicy is used to determine when Kubernetes will attempt to
// pull (download) container images.
// +kubebuilder:validation:Enum={Always,Never,IfNotPresent}
// +kubebuilder:default="IfNotPresent"
// +kubebuilder:validation:Optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

// Resources of the metabase container.
// +kubebuilder:default={requests:{cpu: "1", memory: "2Gi"}, limits:{cpu: "1", memory: "2Gi"}}
// +kubebuilder:validation:Optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
}

type DBSpec struct {
// The image name to use for PostgreSQL containers.
// +kubebuilder:default="postgres:latest"
Expand All @@ -49,6 +71,11 @@ type DBSpec struct {
// +kubebuilder:validation:Optional
Replicas *int32 `json:"replicas,omitempty"`

// Resources of the PostgreSQL container.
// +kubebuilder:default={requests:{cpu: "100m", memory: "256Mi"}, limits:{cpu: "1", memory: "2Gi"}}
// +kubebuilder:validation:Optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// +kubebuilder:validation:Required
Volume VolumeSpec `json:"volume"`
}
Expand Down
18 changes: 18 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions charts/operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: metabase-operator
description: Helm chart to deploy [unagex-metabase-operator](https://github.com/unagex/metabase-operator)
type: application
version: 0.0.3
appVersion: 0.0.3
version: 0.0.4
appVersion: 0.0.4
home: https://github.com/unagex/metabase-operator
129 changes: 129 additions & 0 deletions charts/operator/templates/crds/unagex.com_metabases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,62 @@ spec:
format: int32
minimum: 1
type: integer
resources:
default:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: 100m
memory: 256Mi
description: Resources of the PostgreSQL container.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
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
volume:
properties:
size:
Expand All @@ -70,8 +126,81 @@ spec:
required:
- volume
type: object
metabase:
properties:
image:
default: metabase/metabase:latest
description: The image name to use for Metabase container.
type: string
imagePullPolicy:
default: IfNotPresent
description: ImagePullPolicy is used to determine when Kubernetes
will attempt to pull (download) container images.
enum:
- Always
- Never
- IfNotPresent
type: string
resources:
default:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
description: Resources of the metabase container.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
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
type: object
required:
- db
- metabase
type: object
status:
description: MetabaseStatus defines the observed state of Metabase
Expand Down
129 changes: 129 additions & 0 deletions config/crd/bases/unagex.com_metabases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,62 @@ spec:
format: int32
minimum: 1
type: integer
resources:
default:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: 100m
memory: 256Mi
description: Resources of the PostgreSQL container.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
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
volume:
properties:
size:
Expand All @@ -70,8 +126,81 @@ spec:
required:
- volume
type: object
metabase:
properties:
image:
default: metabase/metabase:latest
description: The image name to use for Metabase container.
type: string
imagePullPolicy:
default: IfNotPresent
description: ImagePullPolicy is used to determine when Kubernetes
will attempt to pull (download) container images.
enum:
- Always
- Never
- IfNotPresent
type: string
resources:
default:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "1"
memory: 2Gi
description: Resources of the metabase container.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
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
type: object
required:
- db
- metabase
type: object
status:
description: MetabaseStatus defines the observed state of Metabase
Expand Down
Loading

0 comments on commit feca1ad

Please sign in to comment.