Skip to content

Commit

Permalink
Merge pull request #58 from VictoriaMetrics/feature-update-quick-star…
Browse files Browse the repository at this point in the history
…t-docs

updated quick-start with VMPodScrape and VMRule examples
added relabeling docs
fixed few bugs
  • Loading branch information
f41gh7 authored Aug 4, 2020
2 parents cf4a27f + 34c9e00 commit d4510ad
Show file tree
Hide file tree
Showing 43 changed files with 1,194 additions and 434 deletions.
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ endif

all: build

gen-client:
client-gen --go-header-file hack/boilerplate.go.txt \
--input-base=""\
--input=$(REPO)/api/v1beta1 \
--clientset-name "versioned" \
--output-package=$(REPO)/pkg/client \
--output-base ""
cp -R $(REPO)/pkg/client ./pkg

install-golint:
which golint || GO111MODULE=off go get -u golang.org/x/lint/golint
Expand Down Expand Up @@ -178,7 +170,7 @@ vet:

# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./.../api"
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."

# Build the docker image
docker-build: test
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## Documentation

- quick start [doc](/docs/quick-start.MD)
- design and description of implementation [design](/docs/design.MD)
- high availability [doc](/docs/high-availability.MD)
- relabeling configuration [doc](/docs/relabeling.MD)
- managing crd objects versions [doc](/docs/managing-versions.MD)
- design and description of implementation [design](/docs/design.MD)
- operator objects description [doc](/docs/api.MD)


Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/additional.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ type EmbeddedPersistentVolumeClaim struct {
// More info: https://prometheus.io/docs/operating/configuration/#endpoints
// +k8s:openapi-gen=true
type BasicAuth struct {
// The secret in the service monitor namespace that contains the username
// The secret in the service scrape namespace that contains the username
// for authentication.
// +optional
Username v1.SecretKeySelector `json:"username,omitempty"`
// The secret in the service monitor namespace that contains the password
// The secret in the service scrape namespace that contains the password
// for authentication.
// +optional
Password v1.SecretKeySelector `json:"password,omitempty"`
Expand Down
42 changes: 17 additions & 25 deletions api/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ type VMAgentSpec struct {
// PodMetadata configures Labels and Annotations which are propagated to the vmagent pods.
// +optional
PodMetadata *EmbeddedObjectMetadata `json:"podMetadata,omitempty"`
// Image - victoria metrics agent base image
// if not specified - use default from operator config
// Image - docker image settings for VMAgent
// if no specified operator uses default config version
// +optional
Image *string `json:"image,omitempty"`
// Version for VMAgent.
// +optional
Version string `json:"version,omitempty"`
// ImagePullSecrets optional list of references to secrets in the same namespace
// to use for pulling prometheus and vmagent images from registries
Image Image `json:"image,omitempty"`
// ImagePullSecrets An optional list of references to secrets in the same namespace
// to use for pulling images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
// +optional
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Expand Down Expand Up @@ -121,7 +118,7 @@ type VMAgentSpec struct {
// +optional
APIServerConfig *APIServerConfig `json:"aPIServerConfig,omitempty"`
// OverrideHonorLabels if set to true overrides all user configured honor_labels.
// If HonorLabels is set in ServiceMonitor or PodMonitor to true, this overrides honor_labels to false.
// If HonorLabels is set in ServiceScrape or PodScrape to true, this overrides honor_labels to false.
// +optional
OverrideHonorLabels bool `json:"overrideHonorLabels,omitempty"`
// OverrideHonorTimestamps allows to globally enforce honoring timestamps in all scrape configs.
Expand All @@ -142,11 +139,6 @@ type VMAgentSpec struct {
// _not_ be added when value is set to empty string (`""`).
// +optional
VMAgentExternalLabelName *string `json:"vmAgentExternalLabelName,omitempty"`
// ReplicaExternalLabelName Name of vmagent external label used to denote replica name.
// Defaults to the value of `prometheus_replica`. External label will
// _not_ be added when value is set to empty string (`""`).
// +optional
ReplicaExternalLabelName *string `json:"replicaExternalLabelName,omitempty"`

// ExternalLabels The labels to add to any time series or alerts when communicating with
// external systems (federation, remote storage, etc).
Expand All @@ -162,24 +154,24 @@ type VMAgentSpec struct {
// This relabeling is applied to all the collected metrics before sending them to remote storage.
// +optional
RelabelConfig *v1.ConfigMapKeySelector `json:"relabelConfig,omitempty"`
// ServiceMonitorSelector defines ServiceMonitors to be selected for target discovery. if
// neither this nor podMonitorSelector are specified, configuration is
// ServiceScrapeSelector defines ServiceScrapes to be selected for target discovery. if
// neither serviceScrapeNamespaceSelector nor serviceScrapeSelector are specified, configuration is
// unmanaged.
// +optional
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
// ServiceMonitorNamespaceSelector Namespaces to be selected for ServiceMonitor discovery. If nil, only
ServiceScrapeSelector *metav1.LabelSelector `json:"serviceScrapeSelector,omitempty"`
// ServiceScrapeNamespaceSelector Namespaces to be selected for ServiceMonitor discovery. If nil, only
// check own namespace.
// +optional
ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"`
// PodMonitorSelector defines PodMonitors to be selected for target discovery.
// if neither this nor serviceMonitorSelector are specified,
ServiceScrapeNamespaceSelector *metav1.LabelSelector `json:"serviceScrapeNamespaceSelector,omitempty"`
// PodScrapeSelector defines PodScrapes to be selected for target discovery.
// if neither PodScrapeNamespaceSelector this nor PodScrapeSelector are specified,
// configuration is unmanaged.
// +optional
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
// PodMonitorNamespaceSelector defines Namespaces to be selected for PodMonitor discovery. If nil, only
PodScrapeSelector *metav1.LabelSelector `json:"podScrapeSelector,omitempty"`
// PodScrapeNamespaceSelector defines Namespaces to be selected for PodMonitor discovery. If nil, only
// check own namespace.
// +optional
PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"`
PodScrapeNamespaceSelector *metav1.LabelSelector `json:"podScrapeNamespaceSelector,omitempty"`
// AdditionalScrapeConfigs As scrape configs are appended, the user is responsible to make sure it
// is valid. Note that using this feature may expose the possibility to
// break upgrades of VMAgent. It is advised to review VMAgent release
Expand All @@ -188,7 +180,7 @@ type VMAgentSpec struct {
// +optional
AdditionalScrapeConfigs *v1.SecretKeySelector `json:"additionalScrapeConfigs,omitempty"`
// ArbitraryFSAccessThroughSMs configures whether configuration
// based on a service monitor can access arbitrary files on the file system
// based on a service scrape can access arbitrary files on the file system
// of the VMAgent container e.g. bearer token files.
// +optional
ArbitraryFSAccessThroughSMs ArbitraryFSAccessThroughSMsConfig `json:"arbitraryFSAccessThroughSMs,omitempty"`
Expand Down
11 changes: 6 additions & 5 deletions api/v1beta1/vmalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ import (
type VMAlertSpec struct {
// PodMetadata configures Labels and Annotations which are propagated to the VMAlert pods.
PodMetadata *EmbeddedObjectMetadata `json:"podMetadata,omitempty"`
// Image victoria metrics alert base image
// Image - docker image settings for VMAlert
// if no specified operator uses default config version
// +optional
Image *string `json:"image,omitempty"`
// Version the VMAlert should be on.
Version string `json:"version,omitempty"`
Image Image `json:"image,omitempty"`
// ImagePullSecrets An optional list of references to secrets in the same namespace
// to use for pulling prometheus and VMAlert images from registries
// to use for pulling images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
// +optional
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// Secrets is a list of Secrets in the same namespace as the VMAlert
// object, which shall be mounted into the VMAlert Pods.
// The Secrets are mounted into /etc/vmalert/secrets/<secret-name>.
Expand Down
23 changes: 5 additions & 18 deletions api/v1beta1/vmalertmanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,12 @@ type VMAlertmanagerSpec struct {
// PodMetadata configures Labels and Annotations which are propagated to the alertmanager pods.
// +optional
PodMetadata *EmbeddedObjectMetadata `json:"podMetadata,omitempty"`
// Image if specified has precedence over baseImage, tag and sha
// combinations.
// +optional
Image *string `json:"image,omitempty"`
// Version the cluster should be on.
// +optional
Version string `json:"version,omitempty"`
// Tag of VMAlertmanager container image to be deployed. Defaults to the value of `version`.
// Version is ignored if Tag is set.
// +optional
Tag string `json:"tag,omitempty"`
// SHA of VMAlertmanager container image to be deployed. Defaults to the value of `version`.
// Similar to a tag, but the SHA explicitly deploys an immutable container image.
// Version and Tag are ignored if SHA is set.
// +optional
SHA string `json:"sha,omitempty"`
// BaseImage that is used to deploy pods, without tag.

// Image - docker image settings for VMAlertmanager
// if no specified operator uses default config version
// +optional
BaseImage string `json:"baseImage,omitempty"`
Image Image `json:"image,omitempty"`

// ImagePullSecrets An optional list of references to secrets in the same namespace
// to use for pulling images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
Expand Down
10 changes: 5 additions & 5 deletions api/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,13 @@ type VMBackup struct {
// Defines if monthly backups disabled (default false)
// +optional
DisableMonthly *bool `json:"disableMonthly,omitempty"`
// Image - docker image settings for VMBackyper
// Image - docker image settings for VMBackuper
// +optional
Image Image `json:"image,omitempty"`
//Port for health check connetions
//Port for health check connections
Port string `json:"port,omitempty"`
// LogFormat for VMSelect to be configured with.
//default or json
// default or json
// +optional
// +kubebuilder:validation:Enum=default;json
LogFormat *string `json:"logFormat,omitempty"`
Expand Down Expand Up @@ -625,14 +625,14 @@ func (cr VMCluster) VMInsertPodAnnotations() map[string]string {
if cr.Spec.VMInsert == nil || cr.Spec.VMInsert.PodMetadata == nil {
return nil
}
return cr.Spec.VMSelect.PodMetadata.Annotations
return cr.Spec.VMInsert.PodMetadata.Annotations
}

func (cr VMCluster) VMStoragePodAnnotations() map[string]string {
if cr.Spec.VMStorage == nil || cr.Spec.VMStorage.PodMetadata == nil {
return nil
}
return cr.Spec.VMSelect.PodMetadata.Annotations
return cr.Spec.VMStorage.PodMetadata.Annotations
}

func (cr VMCluster) Annotations() map[string]string {
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/vmpodscrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ type PodMetricsEndpoint struct {
}

// ArbitraryFSAccessThroughSMsConfig enables users to configure, whether
// a service monitor selected by the vmagent instance is allowed to use
// a service scrape selected by the vmagent instance is allowed to use
// arbitrary files on the file system of the vmagent container. This is the case
// when e.g. a service scrape specifies a BearerTokenFile in an endpoint. A
// malicious user could create a service monitor selecting arbitrary secret files
// malicious user could create a service scrape selecting arbitrary secret files
// in the vmagent container. Those secrets would then be sent with a scrape
// request by vmagent to a malicious target. Denying the above would prevent the
// attack, users can instead use the BearerTokenSecret field.
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/vmservicescrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type VMServiceScrapeSpec struct {
// PodTargetLabels transfers labels on the Kubernetes Pod onto the target.
// +optional
PodTargetLabels []string `json:"podTargetLabels,omitempty"`
// A list of endpoints allowed as part of this ServiceMonitor.
// A list of endpoints allowed as part of this ServiceScrape.
Endpoints []Endpoint `json:"endpoints"`
// Selector to select Endpoints objects.
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Expand Down Expand Up @@ -107,7 +107,7 @@ type Endpoint struct {
// +optional
BearerTokenFile string `json:"bearerTokenFile,omitempty"`
// Secret to mount to read bearer token for scraping targets. The secret
// needs to be in the same namespace as the service monitor and accessible by
// needs to be in the same namespace as the service scrape and accessible by
// the victoria-metrics operator.
// +optional
BearerTokenSecret v1.SecretKeySelector `json:"bearerTokenSecret,omitempty"`
Expand Down
8 changes: 3 additions & 5 deletions api/v1beta1/vmsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ type VMSingleSpec struct {
// PodMetadata configures Labels and Annotations which are propagated to the VMSingle pods.
// +optional
PodMetadata *EmbeddedObjectMetadata `json:"podMetadata,omitempty"`
// Image victoria metrics single base image
// Image - docker image settings for VMSingle
// if no specified operator uses default config version
// +optional
Image *string `json:"image,omitempty"`
// Version of victoria metrics single
// +optional
Version string `json:"version,omitempty"`
Image Image `json:"image,omitempty"`
// ImagePullSecrets An optional list of references to secrets in the same namespace
// to use for pulling images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
Expand Down
Loading

0 comments on commit d4510ad

Please sign in to comment.