diff --git a/operator/configuration/00-download-operator.sh b/operator/configuration/00-download-operator.sh index 5124aa5..123d231 100755 --- a/operator/configuration/00-download-operator.sh +++ b/operator/configuration/00-download-operator.sh @@ -3,6 +3,8 @@ set -e set -x + + export VM_OPERATOR_VERSION=$(basename $(curl -fs -o /dev/null -w %{redirect_url} \ https://github.com/VictoriaMetrics/operator/releases/latest)) echo "VM_OPERATOR_VERSION=$VM_OPERATOR_VERSION" diff --git a/operator/configuration/02-install-vm.sh b/operator/configuration/02-install-vm.sh new file mode 100755 index 0000000..85458ff --- /dev/null +++ b/operator/configuration/02-install-vm.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e +set -x + +../quick-start/10-create-vmsingle-manifest.sh +../quick-start/11-install-vmsingle.sh +../quick-start/20-create-vmagent-manifest.sh +../quick-start/21-install-vmagent.sh +../quick-start/30-create-demo-app-manifest.sh +../quick-start/32-create-demo-app-service-scrape.sh \ No newline at end of file diff --git a/operator/configuration/30-scrape-operator-metrics.sh b/operator/configuration/30-scrape-operator-metrics.sh new file mode 100755 index 0000000..3237b2e --- /dev/null +++ b/operator/configuration/30-scrape-operator-metrics.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e +set -x + +cat <<'EOF' > operator-scrape.yaml +apiVersion: operator.victoriametrics.com/v1beta1 +kind: VMServiceScrape +metadata: + name: operator-service-scrape + # You might need to change the namespace below + namespace: vm +spec: + selector: + matchLabels: + # You might need to change the labels below + app.kubernetes.io/instance: default + app.kubernetes.io/name: victoria-metrics-operator + endpoints: + - port: http +EOF + +kubectl apply -f operator-scrape.yaml; +kubectl wait -n vm --for=jsonpath='{.status.updateStatus}'=operational vmservicescrape/operator-service-scrape; diff --git a/operator/configuration/31-port-forward-vmagent.sh b/operator/configuration/31-port-forward-vmagent.sh new file mode 100755 index 0000000..4a47ceb --- /dev/null +++ b/operator/configuration/31-port-forward-vmagent.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e +set -x + +VMAGENT_POD_NAME=$(kubectl get pod -n vm -l "app.kubernetes.io/name=vmagent" -o jsonpath="{.items[0].metadata.name}") +kubectl port-forward -n vm $VMAGENT_POD_NAME 8429:8429 diff --git a/operator/configuration/demo-app-scrape.yaml b/operator/configuration/demo-app-scrape.yaml new file mode 100644 index 0000000..6e5928c --- /dev/null +++ b/operator/configuration/demo-app-scrape.yaml @@ -0,0 +1,11 @@ +apiVersion: operator.victoriametrics.com/v1beta1 +kind: VMServiceScrape +metadata: + name: demo-app-service-scrape +spec: + selector: + matchLabels: + app.kubernetes.io/name: demo-app + endpoints: + - port: http + path: /metrics diff --git a/operator/configuration/demo-app.yaml b/operator/configuration/demo-app.yaml new file mode 100644 index 0000000..baf184c --- /dev/null +++ b/operator/configuration/demo-app.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: demo-app + namespace: default + labels: + app.kubernetes.io/name: demo-app +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: demo-app + template: + metadata: + labels: + app.kubernetes.io/name: demo-app + spec: + containers: + - name: main + image: docker.io/victoriametrics/demo-app:1.2 +--- +apiVersion: v1 +kind: Service +metadata: + name: demo-app + namespace: default + labels: + app.kubernetes.io/name: demo-app +spec: + selector: + app.kubernetes.io/name: demo-app + ports: + - port: 8080 + name: http diff --git a/operator/configuration/operator-scrape.yaml b/operator/configuration/operator-scrape.yaml new file mode 100644 index 0000000..a498b6d --- /dev/null +++ b/operator/configuration/operator-scrape.yaml @@ -0,0 +1,14 @@ +apiVersion: operator.victoriametrics.com/v1beta1 +kind: VMServiceScrape +metadata: + name: operator-service-scrape + # You might need to change the namespace below + namespace: vm +spec: + selector: + matchLabels: + # You might need to change the labels below + app.kubernetes.io/instance: default + app.kubernetes.io/name: victoria-metrics-operator + endpoints: + - port: http diff --git a/operator/configuration/vmagent-demo.yaml b/operator/configuration/vmagent-demo.yaml new file mode 100644 index 0000000..7dac4d5 --- /dev/null +++ b/operator/configuration/vmagent-demo.yaml @@ -0,0 +1,9 @@ +apiVersion: operator.victoriametrics.com/v1beta1 +kind: VMAgent +metadata: + name: demo + namespace: vm +spec: + selectAllByDefault: true + remoteWrite: + - url: "http://vmsingle-demo.vm.svc:8429/api/v1/write" diff --git a/operator/configuration/vmsingle-demo.yaml b/operator/configuration/vmsingle-demo.yaml new file mode 100644 index 0000000..55d772c --- /dev/null +++ b/operator/configuration/vmsingle-demo.yaml @@ -0,0 +1,8 @@ +apiVersion: operator.victoriametrics.com/v1beta1 +kind: VMSingle +metadata: + name: demo + namespace: vm +spec: + # make it optional, remove from this file + retentionPeriod: "1"