Skip to content

Commit

Permalink
Merge pull request #24 from maxime1907/enhance-chart
Browse files Browse the repository at this point in the history
feat: enhance chart features, add daemonset, add linting ci
  • Loading branch information
mstein11 authored May 12, 2022
2 parents afe5c05 + 72125cc commit 173815f
Show file tree
Hide file tree
Showing 16 changed files with 470 additions and 93 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/lint_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Lint and Test Charts

# Controls when the action will run. Triggers the workflow on pull request
# events but only for the main branch
on:
pull_request:
branches: [main]

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Validate schema
uses: wiremind/[email protected]
with:
path: charts
config: config_repos

- name: Cleanup subcharts after kubeval
run: rm -rf charts/*/charts

- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct --config ct.yaml list-changed)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Deploy Prometheus Operator crds
run: |
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.55.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.55.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.55.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.55.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
- name: Run chart-testing (install)
run: ct install --config ct.yaml
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
version: v3.5.0

- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ You can find more background information in this blog post: https://blog.viadee.

Note: The content of this repository is based on the work done by gitlab as described in their [blogpost](https://about.gitlab.com/blog/2020/11/18/docker-hub-rate-limit-monitoring/). The original source of the Python script can be found [here](https://gitlab.com/gitlab-com/marketing/corporate_marketing/developer-evangelism/code/docker-hub-limit-exporter).

## Upgrade from 0.2.x to 0.3.0

In 0.3.0 the config path for supplying the dockerhub credentials has been changed. If you monitor authenticated requests and you want to update to 0.3.0, then you have to change `config.dockerhubUsername` and `config.dockerhubPassword` to `config.dockerhub.username` and `config.dockerhub.password`.

## How to install the chart

The helm chart can be installed through a helm chart repository hosted on a github page in this repository. To install follow the next steps:
Expand All @@ -20,7 +24,7 @@ The helm chart can be installed through a helm chart repository hosted on a gith
If your kubernetes cluster does not authenticate with dockerhub you don't need to do anything here. However, if it does, you need to configure the crendetials with helm values. This is because the docker-hub-rate-limit-exporter does not use the dockerhub account assosiated with the docker context of your kubernetes-cluster. You can configure it to do so by following the steps below:

1. Create a helm value file as per the example in this repository (see: chart/values.yaml)
2. Fill in the variables `dockerhubUsername` and `dockerhubPassword`. It is recommended to use a dockerhub access token for the password.
2. Fill in the variables `config.dockerhub.username` and `config.dockerhub.password`. It is recommended to use a dockerhub access token for the password.
3. Run `helm upgrade <release name> viadee/docker-hub-rate-limit-exporter --install --namespace=<desired namespace> -f <name of value file>`

## How to tell prometheus to scrap the metrics
Expand Down
26 changes: 21 additions & 5 deletions charts/docker-hub-rate-limit-exporter-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
apiVersion: v2
name: docker-hub-rate-limit-exporter
description: Export your current docker hub rate limit status to prometheus.
icon: https://github.com/viadee/docker-hub-rate-limit-exporter/raw/main/chart/icon.png

icon: https://raw.githubusercontent.com/viadee/docker-hub-rate-limit-exporter/main/charts/docker-hub-rate-limit-exporter-chart/icon.png
keywords:
- docker
- hub
- rate
- limit
- exporter
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -11,14 +16,25 @@ icon: https://github.com/viadee/docker-hub-rate-limit-exporter/raw/main/chart/ic
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.11
version: 0.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.16.0
appVersion: version-1.6

home: https://github.com/viadee/docker-hub-rate-limit-exporter/
sources:
- https://github.com/viadee/docker-hub-rate-limit-exporter/
maintainers:
- email: [email protected]
name: sebastiansirch
- email: [email protected]
name: fkoehne
- email: [email protected]
name: mstein11
23 changes: 12 additions & 11 deletions charts/docker-hub-rate-limit-exporter-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ The command removes all the Kubernetes components associated with the chart and

## Configuration

| Parameter | Description | Default |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------- |
| `config.exporterPort` | Port the deployment exposes | `80` |
| `config.exporterVerbosity` | Loglevel of the deployment | `1` |
| `config.dockerhubUsername` | To authenticate with dockerhub | `nil` |
| `config.dockerhubPassword` | To authenticate with dockerhub (use access token) | `nil` |
| `serviceMonitor.enabled` | If true, creates a ServiceMonitor instance | `false` |
| `serviceMonitor.additionalLabels` | Configure additional labels for the servicemonitor | `{}` |
| `serviceMonitor.namespace` | The namespace into which the servicemonitor is deployed. If not set, will the same as the namespace of this chart | `nil` |
| `serviceMonitor.interval` | The interval with which prometheus will scrape | `30s` |
| `serviceMonitor.scrapeTimeout` | The timeout for the scrape request | `10s` |
| Parameter | Description | Default |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| `deployment.enabled` | If true, docker-hub-rate-limit-exporter will be deployed as a kubernetes Deployment | `1` |
| `daemonset.enabled` | If true, docker-hub-rate-limit-exporter will be deployed as a kubernetes Deamonset. Useful if kubernetes nodes have an own public IP | `1` |
| `config.verbosity` | Loglevel of the deployment | `1` |
| `config.dockerhub.username` | To authenticate with dockerhub | `nil` |
| `config.dockerhub.password` | To authenticate with dockerhub (use access token) | `nil` |
| `serviceMonitor.enabled` | If true, creates a ServiceMonitor instance | `false` |
| `serviceMonitor.additionalLabels` | Configure additional labels for the servicemonitor | `{}` |
| `serviceMonitor.namespace` | The namespace into which the servicemonitor is deployed. If not set, will the same as the namespace of this chart | `nil` |
| `serviceMonitor.interval` | The interval with which prometheus will scrape | `30s` |
| `serviceMonitor.scrapeTimeout` | The timeout for the scrape request | `10s` |

## Attribution

Expand Down
122 changes: 122 additions & 0 deletions charts/docker-hub-rate-limit-exporter-chart/ci/all-enabled-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Default values for docker-hub-rate-limit-exporter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

config:
# Log level of the exporter
verbosity: 1
dockerhub:
username: ""
password: ""

deployment:
enabled: true
replicaCount: 1
podAnnotations: {}

daemonset:
enabled: true
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
podAnnotations: {}


image:
repository: viadee/docker-hub-rate-limit-exporter
tag: ""
pullPolicy: IfNotPresent

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceMonitor:
enabled: true
additionalLabels: {}
namespace: ""

jobLabel: ""

scheme: http
bearerTokenFile:
tlsConfig: {}

## proxyUrl: URL of a proxy that should be used for scraping.
##
proxyUrl: ""

## Override serviceMonitor selector
##
selectorOverride: {}

relabelings:
- action: replace
sourceLabels:
- __meta_kubernetes_pod_node_name
targetLabel: instance
- action: replace
sourceLabels:
- __meta_kubernetes_pod_host_ip
targetLabel: host_ip
metricRelabelings: []
interval: ""
scrapeTimeout: 25s

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations:
sidecar.istio.io/inject: "false"

podSecurityContext:
fsGroup: 65534
runAsGroup: 65534
runAsNonRoot: true
runAsUser: 65534

securityContext:
capabilities:
add:
- SYS_TIME

service:
type: ClusterIP
port: 9100
targetPort: 9100
nodePort:
portName: metrics
annotations: {}

livenessProbeTimeoutSeconds: 5

readinessProbeTimeoutSeconds: 5

resources:
limits:
cpu: 200m
memory: 96Mi
requests:
cpu: 50m
memory: 64Mi

nodeSelector: {}

tolerations: []

priorityClassName: ""

affinity: {}

# Expose the service to the host network
hostNetwork: false

# Share the host process ID namespace
hostPID: true
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{{- $config := default dict .Values.config }}

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "docker-hub-rate-limit-exporter.fullname" . }}-configmap
labels:
{{- include "docker-hub-rate-limit-exporter.labels" . | nindent 4 }}
data:
exporter-port: {{ default "80" .Values.config.exporterPort | quote }}
exporter-verbosity: {{ default "1" .Values.config.exporterVerbosity | quote }}
dockerhub-username: {{ default "" .Values.config.dockerhubUsername | quote }}
exporter-port: {{ .Values.service.targetPort | quote }}
exporter-verbosity: {{ hasKey $config "verbosity" | ternary $config.verbosity 1 | quote }}
Loading

0 comments on commit 173815f

Please sign in to comment.