-
Notifications
You must be signed in to change notification settings - Fork 2.3k
helm: add support for PMM #3598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| FROM vitess/base AS base | ||
|
|
||
| FROM debian:stretch-slim | ||
|
|
||
| # Copy CA certs for https calls | ||
| COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get upgrade -qq && \ | ||
| apt-get install wget -qq --no-install-recommends && \ | ||
| wget https://www.percona.com/redir/downloads/pmm-client/1.6.1/binary/debian/stretch/x86_64/pmm-client_1.6.1-1.stretch_amd64.deb && \ | ||
| dpkg -i pmm-client_1.6.1-1.stretch_amd64.deb && \ | ||
| rm pmm-client_1.6.1-1.stretch_amd64.deb && \ | ||
| apt-get purge wget -qq && \ | ||
| apt-get autoremove -qq && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| ################################### | ||
| # pmm Service + Deployment | ||
| ################################### | ||
| {{- define "pmm" -}} | ||
| # set tuple values to more recognizable variables | ||
| {{- $pmm := index . 0 -}} | ||
| {{- $namespace := index . 1 -}} | ||
|
|
||
| ################################### | ||
| # pmm Service | ||
| ################################### | ||
| kind: Service | ||
| apiVersion: v1 | ||
| metadata: | ||
| name: pmm | ||
| labels: | ||
| component: pmm | ||
| app: vitess | ||
| spec: | ||
| ports: | ||
| - name: web | ||
| port: 80 | ||
|
|
||
| selector: | ||
| component: pmm | ||
| app: vitess | ||
| type: ClusterIP | ||
| --- | ||
| ################################### | ||
| # pmm StatefulSet | ||
| ################################### | ||
| apiVersion: apps/v1beta1 | ||
| kind: StatefulSet | ||
| metadata: | ||
| name: pmm | ||
| spec: | ||
| serviceName: pmm | ||
| replicas: 1 | ||
| updateStrategy: | ||
| type: RollingUpdate | ||
| selector: | ||
| matchLabels: | ||
| app: vitess | ||
| component: pmm | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: vitess | ||
| component: pmm | ||
| spec: | ||
| containers: | ||
| - name: pmm | ||
| image: "percona/pmm-server:{{ $pmm.pmmTag }}" | ||
|
|
||
| ports: | ||
| - name: web | ||
| containerPort: 80 | ||
|
|
||
| volumeMounts: | ||
| - name: pmmdata | ||
| mountPath: /pmmdata | ||
|
|
||
| resources: | ||
| {{ toYaml $pmm.server.resources | indent 12 }} | ||
|
|
||
| env: | ||
| - name: DISABLE_UPDATES | ||
| value: "true" | ||
|
|
||
| - name: DISABLE_TELEMETRY | ||
| value: {{ $pmm.server.env.disableTelemetry | quote }} | ||
|
|
||
| - name: METRICS_RESOLUTION | ||
| value: {{ $pmm.server.env.metricsResolution | quote }} | ||
|
|
||
| - name: METRICS_RETENTION | ||
| value: {{ $pmm.server.env.metricsRetention | quote }} | ||
|
|
||
| - name: QUERIES_RETENTION | ||
| value: {{ $pmm.server.env.queriesRetention | quote }} | ||
|
|
||
| - name: METRICS_MEMORY | ||
| value: {{ $pmm.server.env.metricsMemory | quote }} | ||
|
|
||
| command: ["bash"] | ||
| args: | ||
| - "-c" | ||
| - | | ||
| set -ex | ||
|
|
||
|
|
||
| if [ ! -f /pmmdata/vitess-init ]; then | ||
| # the PV hasn't been initialized, so copy over default | ||
| # pmm-server directories before symlinking | ||
| mkdir -p /pmmdata | ||
|
|
||
| mv /opt/prometheus/data /pmmdata/data | ||
| mv /opt/consul-data /pmmdata | ||
| mv /var/lib/mysql /pmmdata | ||
| mv /var/lib/grafana /pmmdata | ||
|
|
||
| # initialize the PV and then mark it complete | ||
| touch /pmmdata/vitess-init | ||
| else | ||
| # remove the default directories so we can symlink the | ||
| # existing PV directories | ||
| rm -Rf /opt/prometheus/data | ||
| rm -Rf /opt/consul-data | ||
| rm -Rf /var/lib/mysql | ||
| rm -Rf /var/lib/grafana | ||
| fi | ||
|
|
||
| # symlink pmm-server paths to point to our PV | ||
| ln -s /pmmdata/data /opt/prometheus/ | ||
| ln -s /pmmdata/consul-data /opt/ | ||
| ln -s /pmmdata/mysql /var/lib/ | ||
| ln -s /pmmdata/grafana /var/lib/ | ||
|
|
||
| /opt/entrypoint.sh | ||
|
|
||
| volumeClaimTemplates: | ||
| - metadata: | ||
| name: pmmdata | ||
| annotations: | ||
| {{ toYaml $pmm.server.dataVolumeClaimAnnotations | indent 10 }} | ||
| spec: | ||
| {{ toYaml $pmm.server.dataVolumeClaimSpec | indent 8 }} | ||
|
|
||
| {{- end -}} | ||
|
|
||
| ################################### | ||
| # sidecar container running pmm-client | ||
| ################################### | ||
| {{- define "cont-pmm-client" -}} | ||
| {{- $pmm := index . 0 -}} | ||
| {{- $namespace := index . 1 -}} | ||
|
|
||
| - name: "pmm-client" | ||
| image: "vitess/pmm-client:{{ $pmm.pmmTag }}" | ||
| imagePullPolicy: IfNotPresent | ||
| volumeMounts: | ||
| - name: vtdataroot | ||
| mountPath: "/vtdataroot" | ||
| ports: | ||
| - containerPort: 42001 | ||
| name: query-data | ||
| - containerPort: 42002 | ||
| name: mysql-metrics | ||
|
|
||
| securityContext: | ||
| # PMM requires root privileges | ||
| runAsUser: 0 | ||
|
|
||
| resources: | ||
| {{ toYaml $pmm.client.resources | indent 4 }} | ||
|
|
||
| command: ["bash"] | ||
| args: | ||
| - "-c" | ||
| - | | ||
| set -ex | ||
|
|
||
| mkdir -p /vtdataroot/pmm | ||
|
|
||
| # redirect logs to PV | ||
| ln -s /vtdataroot/pmm/pmm-mysql-metrics-42002.log /var/log/pmm-mysql-metrics-42002.log | ||
|
|
||
| # --force is used because the pod ip address may have changed | ||
| pmm-admin config --server pmm.{{ $namespace }} --force | ||
|
|
||
| # creates a systemd service | ||
| # TODO: remove "|| true" after https://jira.percona.com/projects/PMM/issues/PMM-1985 is resolved | ||
| pmm-admin add mysql:metrics --user root --socket /vtdataroot/tabletdata/mysql.sock --force || true | ||
|
|
||
| # keep the container alive but still responsive to stop requests | ||
| trap : TERM INT; sleep infinity & wait | ||
|
|
||
| - name: pmm-client-metrics-log | ||
| image: busybox | ||
| command: ["/bin/sh"] | ||
| args: ["-c", "tail -n+1 -F /vtdataroot/pmm/pmm-mysql-metrics-42002.log"] | ||
| volumeMounts: | ||
| - name: vtdataroot | ||
| mountPath: /vtdataroot | ||
|
|
||
| {{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put all these RUN commands into script file, and just COPY and RUN that. Currently since these are separate layers, we're still paying for the storage of all the removed files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can do that