Skip to content

Commit

Permalink
update...
Browse files Browse the repository at this point in the history
  • Loading branch information
alphashaw committed Jan 13, 2025
1 parent aac5fb0 commit 31960eb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
7 changes: 3 additions & 4 deletions api/v1alpha1/pulsarcluster_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ type PulsarClusterSpec struct {
// JVMOptions defines the JVM options for pulsar broker; this is useful for performance tuning.
// If unspecified, a reasonable defaults will be set
// +optional
JVMOptions JVMOptions `json:"jvmOptions"`
Persistence *v1.PersistentVolumeClaimSpec `json:"persistence,omitempty"`
JVMOptions JVMOptions `json:"jvmOptions"`
InitJobResources v1.ResourceRequirements `json:"resources,omitempty"`
Persistence *v1.PersistentVolumeClaimSpec `json:"persistence,omitempty"`
// PodConfig defines common configuration for the broker pods
// +optional
PodConfig basetype.PodConfig `json:"podConfig,omitempty"`
Expand Down Expand Up @@ -327,10 +328,8 @@ func (in *PulsarClusterSpec) createLabels(clusterName string, broker bool) map[s
labels["broker"] = "true"
}
labels["app"] = "pulsar"
labels["version"] = in.PulsarVersion
labels[k8s.LabelAppName] = "pulsar"
labels[k8s.LabelAppInstance] = clusterName
labels[k8s.LabelAppVersion] = in.PulsarVersion
labels[k8s.LabelAppManagedBy] = internal.OperatorName
return labels
}
48 changes: 48 additions & 0 deletions config/crd/bases/pulsar.monime.sl_pulsarclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,54 @@ spec:
pulsarVersion:
description: PulsarVersion defines the version of broker to use
type: string
resources:
description: ResourceRequirements describes the compute resource requirements.
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
size:
format: int32
minimum: 0
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/pulsarcluster/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ func createClusterMetadataInitJob(c *v1alpha1.PulsarCluster) *v1.Job {
}

func createJobPodSpecContainers(c *v1alpha1.PulsarCluster) []coreV1.Container {
initJobResources := c.Spec.InitJobResources
if initJobResources.Limits == nil || initJobResources.Requests == nil {
initJobResources = c.Spec.PodConfig.Spec.Resources
}
return []coreV1.Container{
{
Name: "cluster-metadata-init",
Image: c.Image().ToString(),
ImagePullPolicy: c.Image().PullPolicy,
Resources: initJobResources,
Command: k8s.ContainerShellCommand(),
Args: createJobPodContainerArguments(c),
EnvFrom: []coreV1.EnvFromSource{
Expand Down

0 comments on commit 31960eb

Please sign in to comment.