Skip to content
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

Changes for pmm-server.sh #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Global configuration.
# Use conf.sh.default as a template.
conf.sh
# Use example-values.yaml as a template.
values.yaml
# Host-level configuration
hosts/*
!hosts/.KEEP
# Info sharing between pmm-server and pmm-client?
info/*
# Logs
log
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,61 @@ are not desirable for some reason, or not necessary.

Copy the configuration template:

```
```bash
cp conf.sh.default.sh conf.sh
```

`conf.sh` contains all the configuration. Each option is documented in the file itself.
Also copy the example 'values' file:

```bash
cp example-values.yaml values.yaml
```

`conf.sh` and `values.yaml` contain all the configuration. Each option is
documented in the files themselves.

NB! Make sure the values are the same for `PMM_SERVER_PASSWORD` in `conf.sh` and
`pmm_password` in `values.yaml`.

These file are ignored by git.

### Notes about the values.yaml file

The file is ignored by git.
The `example-values.yaml` file has the `service` `type` as `ClusterIP`, so it
can use the separate `LoadBalancer` (see below).

Note also that the `storageClassName` used is a magical one which in the
Diamond Kubernetes cluster will give us node-local storage.

## Usage

Currently scripts usage is documented in the scripts themselves.
To see their built-in help:

```
```bash
HELP=1 ./pmm-server.sh
HELP=1 ./pmm-client.sh
```

`ACTION=INSTALL pmm-server.sh` outputs, amongst other things, the IP of PMM Server.
But you may need this information at any later time. To obtain it, run:

```
```bash
./get-ip.sh
```

It only outputs the IP, so it can be piped to another script.

## Load balancer

Currently, the project needs a separate LoadBalancer to work. This has a fixed
IP address which was assigned especially for PMM.

Install this with:

```bash
kubectl apply -f ./pmm-loadbalancer.yaml
```

## Copyright and License

Expand Down
2 changes: 2 additions & 0 deletions conf.sh.default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ PMM_SERVER_HOST=
PMM_SERVER_USER='admin'
# Password for PMM Server user
PMM_SERVER_PASSWORD='...'
# File containing chart configuration values for PMM Server
PMM_SERVER_VALUES='values.yaml'

# Set exactly to 1 to enable "mysql" service in PMM Client
PMM_SERVICE_MYSQL=1
Expand Down
129 changes: 129 additions & 0 deletions example-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
## @section Percona Monitoring and Management (PMM) parameters
## Default values for PMM.
## This is a YAML-formatted file.
## Declare variables to be passed into your templates.

## PMM image version
## ref: https://hub.docker.com/r/percona/pmm-server/tags
## @param image.repository PMM image repository
## @param image.pullPolicy PMM image pull policy
## @param image.tag PMM image tag (immutable tags are recommended)
## @param image.imagePullSecrets Global Docker registry secret names as an array
##
image:
repository: percona/pmm-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: "2.31.0"
# imagePullSecrets: []

## PMM environment variables
## ref: https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html#environment-variables
##
pmmEnv:
## @param pmmEnv.DISABLE_UPDATES Disables a periodic check for new PMM versions as well as ability to apply upgrades using the UI (need to be disabled in k8s environment as updates rolled with helm/container update)
##
DISABLE_UPDATES: "1"
# ENABLE_DBAAS: "1"
# optional variables to integrate Grafana with internal iDP, see also secret part
# GF_AUTH_GENERIC_OAUTH_ENABLED: 'true'
# GF_AUTH_GENERIC_OAUTH_SCOPES: ''
# GF_AUTH_GENERIC_OAUTH_AUTH_URL: ''
# GF_AUTH_GENERIC_OAUTH_TOKEN_URL: ''
# GF_AUTH_GENERIC_OAUTH_API_URL: ''
# GF_AUTH_GENERIC_OAUTH_ALLOWED_DOMAINS: ''

## @param pmmResources optional [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) requested for [PMM container](https://docs.percona.com/percona-monitoring-and-management/setting-up/server/index.html#set-up-pmm-server)
pmmResources:
requests:
memory: "32Gi"
cpu: "8"
limits:
memory: "64Gi"
cpu: "24"
## pmmResources: {}

## @section PMM secrets
##
secret:
## @param secret.name Defines the name of the k8s secret that holds passwords and other secrets
##
name: pmm-secret
## @param secret.create If true then secret will be generated by Helm chart. Otherwise it is expected to be created by user.
##
create: true
## @param secret.pmm_password Initial PMM password - it changes only on the first deployment, ignored if PMM was already provisioned and just restarted. If PMM admin password is not set, it will be generated.
## E.g.
## pmm_password: admin
##
## To get password execute `kubectl get secret pmm-secret -o jsonpath='{.data.PMM_ADMIN_PASSWORD}' | base64 --decode`
##
pmm_password: "password123"
##
# GF_AUTH_GENERIC_OAUTH_CLIENT_ID optional client ID to integrate Grafana with internal iDP, requires other env defined as well under pmmEnv
# GF_AUTH_GENERIC_OAUTH_CLIENT_ID:
# GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET optional secret to integrate Grafana with internal iDP, requires other env defined as well under pmmEnv
# GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET:

## @section PMM network configuration
## Service configuration
##
service:
## @param service.name Service name that is dns name monitoring services would send data to. `monitoring-service` used by default by pmm-client in Percona operators.
##
name: monitoring-service
## @param service.type Kubernetes Service type
##
type: ClusterIP

## Ports 443 and/or 80
##
ports:
## @param service.ports[0].port https port number
- port: 443
## @param service.ports[0].targetPort target port to map for statefulset and ingress
targetPort: https
## @param service.ports[0].protocol protocol for https
protocol: TCP
## @param service.ports[0].name port name
name: https
## @param service.ports[1].port http port number
- port: 80
## @param service.ports[1].targetPort target port to map for statefulset and ingress
targetPort: http
## @param service.ports[1].protocol protocol for http
protocol: TCP
## @param service.ports[1].name port name
name: http

## @section PMM storage configuration
## Claiming storage for PMM using Persistent Volume Claims (PVC)
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
##
storage:
## @param storage.name name of PVC
name: pmm-storage
## @param storage.storageClassName optional PMM data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
storageClassName: "db-nvme-storage"
##
## @param storage.size size of storage [depends](https://docs.percona.com/percona-monitoring-and-management/setting-up/server/index.html#set-up-pmm-server) on number of monitored services and data retention
##
size: 50Gi

## Pods Service Account
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
## @param serviceAccount.create Specifies whether a ServiceAccount should be created
## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. Only used if `create` is `true`.
## @param serviceAccount.name Name of the service account to use. If not set and create is true, a name is generated using the fullname template.
##
serviceAccount:
create: false
annotations: {}
name: "default"

27 changes: 27 additions & 0 deletions pmm-loadbalancer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: https
protocol: TCP
port: 443
targetPort: https
- name: http
protocol: TCP
port: 80
targetPort: http
- name: p7777
protocol: TCP
port: 7777
targetPort: 7777
selector:
app.kubernetes.io/component: pmm-server
app.kubernetes.io/instance: monitoring
app.kubernetes.io/name: pmm
app.kubernetes.io/part-of: percona-platform
type: LoadBalancer
loadBalancerIP: 172.23.169.239
externalTrafficPolicy: Cluster

16 changes: 14 additions & 2 deletions pmm-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Options understood:
ACTION Allowed values: SHOW | INSTALL | UNINSTALL | REINSTALL.
Case-insensitive.
Default: SHOW.
VERSION The chart version to use.
Default: latest
WHAT With ACTION = SHOW:
Allowed values: ALL | SYSTEM | SERVICES | VOLUMES | EVENTS
Default: ALL
Expand Down Expand Up @@ -265,7 +267,18 @@ then
fi
if [ $WHAT == 'ALL' ] || [ $WHAT == 'RELEASE' ];
then
run "helm install monitoring percona/pmm --set secret.pmm_password=$PMM_SERVER_PASSWORD --set serviceAccount.create=false --set serviceAccount.name=default"
if [ -r $PMM_SERVER_VALUES ] && [ ! -z $VERSION ];
then
run "helm install -f $PMM_SERVER_VALUES --version=$VERSION monitoring percona/pmm"
elif [ -r $PMM_SERVER_VALUES ];
then
run "helm install -f $PMM_SERVER_VALUES monitoring percona/pmm"
elif [ ! -z $VERSION ];
then
run "helm install --version=$VERSION monitoring percona/pmm"
else
run "helm install monitoring percona/pmm"
fi
fi

helm get values monitoring
Expand Down Expand Up @@ -293,6 +306,5 @@ success 'Success'


# TODO:
# - Allow to install a specific version
# - Allow to use a non-standard server port