Skip to content

Commit

Permalink
Merge pull request #4863 from seanlaii/add_image_pull_in_karmada_oper…
Browse files Browse the repository at this point in the history
…ator

Add image-pull-policy field for karmada-operator
  • Loading branch information
karmada-bot authored Apr 25, 2024
2 parents 006aff9 + d78ea38 commit 1e427bb
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 40 deletions.
41 changes: 41 additions & 0 deletions charts/karmada-operator/crds/operator.karmada.io_karmadas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ spec:
are not queryable and should be preserved when modifying
objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to
IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry
to pull images from. if not set, the ImageRepository
Expand Down Expand Up @@ -571,6 +576,10 @@ spec:
description: 'FeatureGates enabled by the user. More info:
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -703,6 +712,10 @@ spec:
https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -832,6 +845,10 @@ spec:
- CustomizedClusterResourceModeling: https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -937,6 +954,10 @@ spec:
For supported flags, please see https://karmada.io/docs/reference/components/karmada-descheduler
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1042,6 +1063,10 @@ spec:
configuration. \n For supported flags, please see https://karmada.io/docs/reference/components/karmada-metrics-adapter
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1154,6 +1179,10 @@ spec:
https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1259,6 +1288,10 @@ spec:
please see https://karmada.io/docs/reference/components/karmada-search
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1364,6 +1397,10 @@ spec:
please see https://karmada.io/docs/reference/components/karmada-webhook
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1512,6 +1549,10 @@ spec:
description: 'FeatureGates enabled by the user. More info:
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down
41 changes: 41 additions & 0 deletions operator/config/crds/operator.karmada.io_karmadas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ spec:
are not queryable and should be preserved when modifying
objects. More info: http://kubernetes.io/docs/user-guide/annotations'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to
IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry
to pull images from. if not set, the ImageRepository
Expand Down Expand Up @@ -571,6 +576,10 @@ spec:
description: 'FeatureGates enabled by the user. More info:
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -703,6 +712,10 @@ spec:
https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -832,6 +845,10 @@ spec:
- CustomizedClusterResourceModeling: https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -937,6 +954,10 @@ spec:
For supported flags, please see https://karmada.io/docs/reference/components/karmada-descheduler
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1042,6 +1063,10 @@ spec:
configuration. \n For supported flags, please see https://karmada.io/docs/reference/components/karmada-metrics-adapter
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1154,6 +1179,10 @@ spec:
https://karmada.io/docs/userguide/scheduling/cluster-resources#start-to-use-cluster-resource-models
More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1259,6 +1288,10 @@ spec:
please see https://karmada.io/docs/reference/components/karmada-search
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1364,6 +1397,10 @@ spec:
please see https://karmada.io/docs/reference/components/karmada-webhook
for details."
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down Expand Up @@ -1512,6 +1549,10 @@ spec:
description: 'FeatureGates enabled by the user. More info:
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/'
type: object
imagePullPolicy:
description: ImagePullPolicy defines the policy for pulling
the container image. If not specified, it defaults to IfNotPresent.
type: string
imageRepository:
description: ImageRepository sets the container registry to
pull images from. if not set, the ImageRepository defined
Expand Down
32 changes: 30 additions & 2 deletions operator/pkg/apis/operator/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func setDefaultsEtcd(obj *KarmadaComponents) {
if len(obj.Etcd.Local.Image.ImageTag) == 0 {
obj.Etcd.Local.Image.ImageTag = constants.EtcdDefaultVersion
}

if len(obj.Etcd.Local.ImagePullPolicy) == 0 {
obj.Etcd.Local.ImagePullPolicy = corev1.PullIfNotPresent
}
if obj.Etcd.Local.VolumeData == nil {
obj.Etcd.Local.VolumeData = &VolumeData{}
}
Expand All @@ -148,6 +150,9 @@ func setDefaultsKarmadaAPIServer(obj *KarmadaComponents) {
if len(apiserver.Image.ImageTag) == 0 {
apiserver.Image.ImageTag = constants.KubeDefaultVersion
}
if len(apiserver.ImagePullPolicy) == 0 {
apiserver.ImagePullPolicy = corev1.PullIfNotPresent
}
if apiserver.Replicas == nil {
apiserver.Replicas = pointer.Int32(1)
}
Expand All @@ -171,6 +176,9 @@ func setDefaultsKarmadaAggregatedAPIServer(obj *KarmadaComponents) {
if len(aggregated.Image.ImageTag) == 0 {
aggregated.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(aggregated.ImagePullPolicy) == 0 {
aggregated.ImagePullPolicy = corev1.PullIfNotPresent
}
if aggregated.Replicas == nil {
aggregated.Replicas = pointer.Int32(1)
}
Expand All @@ -188,6 +196,9 @@ func setDefaultsKubeControllerManager(obj *KarmadaComponents) {
if len(kubeControllerManager.Image.ImageTag) == 0 {
kubeControllerManager.Image.ImageTag = constants.KubeDefaultVersion
}
if len(kubeControllerManager.ImagePullPolicy) == 0 {
kubeControllerManager.ImagePullPolicy = corev1.PullIfNotPresent
}
if kubeControllerManager.Replicas == nil {
kubeControllerManager.Replicas = pointer.Int32(1)
}
Expand All @@ -205,6 +216,9 @@ func setDefaultsKarmadaControllerManager(obj *KarmadaComponents) {
if len(karmadaControllerManager.Image.ImageTag) == 0 {
karmadaControllerManager.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(karmadaControllerManager.ImagePullPolicy) == 0 {
karmadaControllerManager.ImagePullPolicy = corev1.PullIfNotPresent
}
if karmadaControllerManager.Replicas == nil {
karmadaControllerManager.Replicas = pointer.Int32(1)
}
Expand All @@ -222,6 +236,9 @@ func setDefaultsKarmadaScheduler(obj *KarmadaComponents) {
if len(scheduler.Image.ImageTag) == 0 {
scheduler.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(scheduler.ImagePullPolicy) == 0 {
scheduler.ImagePullPolicy = corev1.PullIfNotPresent
}
if scheduler.Replicas == nil {
scheduler.Replicas = pointer.Int32(1)
}
Expand All @@ -239,6 +256,9 @@ func setDefaultsKarmadaWebhook(obj *KarmadaComponents) {
if len(webhook.Image.ImageTag) == 0 {
webhook.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(webhook.ImagePullPolicy) == 0 {
webhook.ImagePullPolicy = corev1.PullIfNotPresent
}
if webhook.Replicas == nil {
webhook.Replicas = pointer.Int32(1)
}
Expand All @@ -256,6 +276,9 @@ func setDefaultsKarmadaSearch(obj *KarmadaComponents) {
if len(search.Image.ImageTag) == 0 {
search.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(search.ImagePullPolicy) == 0 {
search.ImagePullPolicy = corev1.PullIfNotPresent
}
if search.Replicas == nil {
search.Replicas = pointer.Int32(1)
}
Expand All @@ -273,6 +296,9 @@ func setDefaultsKarmadaDescheduler(obj *KarmadaComponents) {
if len(descheduler.Image.ImageTag) == 0 {
descheduler.Image.ImageTag = DefaultKarmadaImageVersion
}
if len(descheduler.ImagePullPolicy) == 0 {
descheduler.ImagePullPolicy = corev1.PullIfNotPresent
}
if descheduler.Replicas == nil {
descheduler.Replicas = pointer.Int32(1)
}
Expand All @@ -290,7 +316,9 @@ func setDefaultsKarmadaMetricsAdapter(obj *KarmadaComponents) {
if len(metricsAdapter.Image.ImageTag) == 0 {
metricsAdapter.Image.ImageTag = DefaultKarmadaImageVersion
}

if len(metricsAdapter.ImagePullPolicy) == 0 {
metricsAdapter.ImagePullPolicy = corev1.PullIfNotPresent
}
if metricsAdapter.Replicas == nil {
metricsAdapter.Replicas = pointer.Int32(2)
}
Expand Down
5 changes: 5 additions & 0 deletions operator/pkg/apis/operator/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ type CommonSettings struct {
// Image allows to customize the image used for the component.
Image `json:",inline"`

// ImagePullPolicy defines the policy for pulling the container image.
// If not specified, it defaults to IfNotPresent.
// +optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
// +optional
Expand Down
Loading

0 comments on commit 1e427bb

Please sign in to comment.