1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 11:48:53 +00:00

prometheus and alertmanager: added imagePullSecrets support to statefulsets

This enhancement enables users to maintain Prometheus and Alertmanager
images in private/authenticated image registries

Fixes 
This commit is contained in:
Nir Dothan 2017-04-27 16:42:44 +03:00
parent 88f90dc68f
commit 0b91a57680
5 changed files with 23 additions and 0 deletions
Documentation
cmd/apidocgen
pkg
alertmanager
client/monitoring/v1alpha1
prometheus

View file

@ -50,6 +50,7 @@ Specification of the desired behavior of the Alertmanager cluster. More info: ht
| ----- | ----------- | ------ | -------- |
| version | Version the cluster should be on. | string | false |
| baseImage | Base image that is used to deploy pods. | string | false |
| imagePullSecrets | An optional list of references to secrets in the same namespace to use for pulling prometheus and alertmanager images from registries see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod | [][v1.LocalObjectReference](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_localobjectreference) | false |
| replicas | Size is the expected size of the alertmanager cluster. The controller will eventually make the size of the running cluster equal to the expected size. | *int32 | false |
| storage | Storage is the definition of how storage will be used by the Alertmanager instances. | *[StorageSpec](#storagespec) | false |
| externalUrl | ExternalURL is the URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically. | string | false |
@ -121,6 +122,7 @@ Specification of the desired behavior of the Prometheus cluster. More info: http
| version | Version of Prometheus to be deployed. | string | false |
| paused | When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects. | bool | false |
| baseImage | Base image to use for a Prometheus deployment. | string | false |
| imagePullSecrets | An optional list of references to secrets in the same namespace to use for pulling prometheus and alertmanager images from registries see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod | [][v1.LocalObjectReference](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_localobjectreference) | false |
| replicas | Number of instances to deploy for a Prometheus deployment. | *int32 | false |
| retention | Time duration Prometheus shall retain data for. | string | false |
| externalUrl | The external URL the Prometheus instances will be available under. This is necessary to generate correct URLs. This is necessary if Prometheus is not served from root of a DNS name. | string | false |

View file

@ -40,6 +40,7 @@ var (
"unversioned.ListMeta": "https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_listmeta",
"unversioned.LabelSelector": "https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_labelselector",
"v1.ResourceRequirements": "https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_resourcerequirements",
"v1.LocalObjectReference": "https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_localobjectreference",
}
selfLinks = map[string]string{}

View file

@ -60,6 +60,12 @@ func makeStatefulSet(am *v1alpha1.Alertmanager, old *v1beta1.StatefulSet, config
},
Spec: makeStatefulSetSpec(am, config),
}
if am.Spec.ImagePullSecrets != nil && len(am.Spec.ImagePullSecrets) > 0 {
statefulset.Spec.Template.Spec.ImagePullSecrets = make([]v1.LocalObjectReference, len(am.Spec.ImagePullSecrets))
copy(statefulset.Spec.Template.Spec.ImagePullSecrets, am.Spec.ImagePullSecrets)
}
if vc := am.Spec.Storage; vc == nil {
statefulset.Spec.Template.Spec.Volumes = append(statefulset.Spec.Template.Spec.Volumes, v1.Volume{
Name: volumeName(am.Name),

View file

@ -58,6 +58,10 @@ type PrometheusSpec struct {
Paused bool `json:"paused,omitempty"`
// Base image to use for a Prometheus deployment.
BaseImage string `json:"baseImage,omitempty"`
// An optional list of references to secrets in the same namespace
// to use for pulling prometheus and alertmanager images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// Number of instances to deploy for a Prometheus deployment.
Replicas *int32 `json:"replicas,omitempty"`
// Time duration Prometheus shall retain data for.
@ -239,6 +243,10 @@ type AlertmanagerSpec struct {
Version string `json:"version,omitempty"`
// Base image that is used to deploy pods.
BaseImage string `json:"baseImage,omitempty"`
// An optional list of references to secrets in the same namespace
// to use for pulling prometheus and alertmanager images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// Size is the expected size of the alertmanager cluster. The controller will
// eventually make the size of the running cluster equal to the expected
// size.

View file

@ -86,6 +86,12 @@ func makeStatefulSet(p v1alpha1.Prometheus, old *v1beta1.StatefulSet, config *Co
},
Spec: *spec,
}
if p.Spec.ImagePullSecrets != nil && len(p.Spec.ImagePullSecrets) > 0 {
statefulset.Spec.Template.Spec.ImagePullSecrets = make([]v1.LocalObjectReference, len(p.Spec.ImagePullSecrets))
copy(statefulset.Spec.Template.Spec.ImagePullSecrets, p.Spec.ImagePullSecrets)
}
if vc := p.Spec.Storage; vc == nil {
statefulset.Spec.Template.Spec.Volumes = append(statefulset.Spec.Template.Spec.Volumes, v1.Volume{
Name: volumeName(p.Name),