🔧 Be more consistent when installing Helm charts

Always install Helm charts in their own namespace, and specify the
repo through a command-line flag instead of adding the repo.
This commit is contained in:
Jerome Petazzoni
2021-07-21 14:41:28 +02:00
parent 0ca798bc30
commit 92cdb4146b
3 changed files with 42 additions and 47 deletions

View File

@@ -728,15 +728,15 @@ _cmd_tmux() {
ssh $SSHOPTS -t -L /tmp/tmux-$UID/default:/tmp/tmux-1001/default docker@$IP tmux new-session -As 0
}
_cmd helmprom "Install Helm and Prometheus"
_cmd helmprom "Install Prometheus with Helm"
_cmd_helmprom() {
TAG=$1
need_tag
pssh "
if i_am_first_node; then
sudo -u docker -H helm repo add prometheus-community https://prometheus-community.github.io/helm-charts/
sudo -u docker -H helm install prometheus prometheus-community/prometheus \
--namespace kube-system \
sudo -u docker -H helm upgrade --install prometheus prometheus \
--repo https://prometheus-community.github.io/helm-charts/ \
--namespace prometheus --create-namespace \
--set server.service.type=NodePort \
--set server.service.nodePort=30090 \
--set server.persistentVolume.enabled=false \

View File

@@ -152,11 +152,9 @@ class: extra-details
- If it's not installed yet on the cluster, install Prometheus:
```bash
helm repo add prometheus-community
https://prometheus-community.github.io/helm-charts
helm upgrade prometheus prometheus-community/prometheus \
--install \
--namespace kube-system \
helm upgrade --install prometheus prometheus \
--repo https://prometheus-community.github.io/helm-charts \
--namespace prometheus --create-namespace \
--set server.service.type=NodePort \
--set server.service.nodePort=30090 \
--set server.persistentVolume.enabled=false \
@@ -475,10 +473,11 @@ no custom metrics API (custom.metrics.k8s.io) registered
- Install the Prometheus adapter:
```bash
helm upgrade prometheus-adapter prometheus-community/prometheus-adapter \
--install --namespace=kube-system \
--set prometheus.url=http://prometheus-server.kube-system.svc \
--set prometheus.port=80
helm upgrade --install prometheus-adapter prometheus-adapter \
--repo https://prometheus-community.github.io/helm-charts \
--namespace=prometheus-adapter --create-namespace \
--set prometheus.url=http://prometheus-server.prometheus.svc \
--set prometheus.port=80
```
]

View File

@@ -218,27 +218,7 @@ We need to:
---
## Step 2: add the `prometheus-community` repo
- This will add the repository containing the chart for Prometheus
- This command is idempotent
(it won't break anything if the repository was already added)
.exercise[
- Add the repository:
```bash
helm repo add prometheus-community \
https://prometheus-community.github.io/helm-charts
```
]
---
## Step 3: install Prometheus
## Step 2: install Prometheus
- The following command, just like the previous ones, is idempotent
@@ -248,9 +228,9 @@ We need to:
- Install Prometheus on our cluster:
```bash
helm upgrade prometheus prometheus-community/prometheus \
--install \
--namespace kube-system \
helm upgrade prometheus --install prometheus \
--repo https://prometheus-community.github.io/helm-charts \
--namespace prometheus --create-namespace \
--set server.service.type=NodePort \
--set server.service.nodePort=30090 \
--set server.persistentVolume.enabled=false \
@@ -267,24 +247,37 @@ class: extra-details
## Explaining all the Helm flags
- `helm upgrade prometheus` → upgrade the release named `prometheus` ...
- `helm upgrade prometheus` → upgrade the release named `prometheus`
<br/>
(a "release" is an instance of an app deployed with Helm)
- `prometheus-community/...` → of a chart located in the `prometheus-community` repo ...
- `--install` → if it doesn't exist, install it (instead of upgrading)
- `.../prometheus` → in that repo, get the chart named `prometheus` ...
- `prometheus` → use the chart named `prometheus`
- `--install` → if the app doesn't exist, create it ...
- `--repo ...` → the chart is located on the following repository
- `--namespace kube-system` → put it in that specific namespace ...
- `--namespace prometheus` → put it in that specific namespace
- ... and set the following *values* when rendering the chart's templates:
- `--create-namespace` → create the namespace if it doesn't exist
- `server.service.type=NodePort` → expose the Prometheus server with a NodePort
- `server.service.nodePort=30090` → set the specific NodePort number to use
- `server.persistentVolume.enabled=false` → do not use a PersistentVolumeClaim
- `alertmanager.enabled=false` → disable the alert manager entirely
- `--set ...` → here are some *values* to be used when rendering the chart's templates
---
class: extra-details
## Values for the Prometheus chart
Helm *values* are parameters to customize our installation.
- `server.service.type=NodePort` → expose the Prometheus server with a NodePort
- `server.service.nodePort=30090` → set the specific NodePort number to use
- `server.persistentVolume.enabled=false` → do not use a PersistentVolumeClaim
- `alertmanager.enabled=false` → disable the alert manager entirely
---
@@ -301,6 +294,9 @@ class: extra-details
- With your browser, connect to that port
- It should be 30090 if we just installed Prometheus with the Helm chart!
]
---