Skip to content

Commit

Permalink
Add helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Hipwell <steve.hipwell@proagrica.com>
  • Loading branch information
stevehipwell committed Feb 16, 2021
1 parent ab84346 commit c379e31
Show file tree
Hide file tree
Showing 21 changed files with 637 additions and 6 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lint and Test Charts

on:
pull_request:
paths:
- "charts/**"

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

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1

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

- name: Create Kind cluster
uses: helm/kind-action@v1.0.0
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release Charts

on:
release:
types:
- published

jobs:
release:
if: startsWith(github.ref, "refs/tags/v")
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.5.2

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.1.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "metrics-server-helm-chart-{{ .Version }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/_output
metrics-server
!charts/metrics-server
.cover

# Vim-related files
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Latest Metrics Server release can be installed by running:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
```

Or via the [Helm chart](charts/metrics-server/README.md).

Installation instructions for previous releases can be found in [Metrics Server releases].

WARNING: You should no longer use manifests from `master` branch (previously available in `deploy/kubernetes` directory).
Expand Down Expand Up @@ -96,12 +98,6 @@ You can get a full list of Metrics Server configuration flags by running:
docker run --rm k8s.gcr.io/metrics-server/metrics-server:v0.3.7 --help
```

#### Helm Chart

This [Helm chart](https://github.com/helm/charts/tree/master/stable/metrics-server) can deploy the metric-server service in your cluster.

Note: This Helm chart isn't supported by Metrics Server maintainers.

## Design

Metrics Server is a component in the core metrics pipeline described in [Kubernetes monitoring architecture].
Expand Down
23 changes: 23 additions & 0 deletions charts/metrics-server/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
20 changes: 20 additions & 0 deletions charts/metrics-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: metrics-server
description: Metrics Server is a scalable, efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines.
type: application
version: 3.0.0
appVersion: 0.4.2
keywords:
- kubernetes
- metrics-server
- metrics
home: https://github.com/kubernetes-sigs/metrics-server
icon: https://avatars.githubusercontent.com/u/36015203?s=400&v=4
sources:
- https://github.com/kubernetes-sigs/metrics-server
maintainers:
- name: stevehipwell
email: steve.hipwell@gmail.com
annotations:
artifacthub.io/changes: |
- Initial release
57 changes: 57 additions & 0 deletions charts/metrics-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Kubernetes Metrics Server

[Metrics Server](https://github.com/kubernetes-sigs/metrics-server/) is a scalable, efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines.

## Installing the Chart

Before you can install the chart you will need to add the `metrics-server` repo to [Helm](https://helm.sh/).

```shell
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
```

After you've installed the repo you can install the chart.

```shell
helm upgrade --install metrics-server/metrics-server
```

## Configuration

The following table lists the configurable parameters of the _Metrics Server_ chart and their default values.

| Parameter | Description | Default |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `image.repository` | Image repository. | `k8s.gcr.io/metrics-server/metrics-server` |
| `image.tag` | Image tag. | `v{{ .Chart.AppVersion }}` |
| `image.pullPolPcy` | Image pull policy. | `IfNotPresent` |
| `imagePullSecrets` | Image pull secrets. | `[]` |
| `nameOverride` | Override the `name` of the chart. | `nil` |
| `fullnameOverride` | Override the `fullname` of the chart. | `nil` |
| `serviceAccount.create` | If `true`, create a new `serviceaccount`. | `true` |
| `serviceAccount.annotations` | Annotations to add to the service account. | `{}` |
| `serviceAccount.name` | Service account to be used. If not set and `serviceAccount.create` is `true`, a name is generated using the _fullname_ template. | `nil` |
| `rbac.create` | If `true`, create the RBAC resources. | `true` |
| `rbac.pspEnabled` | If `true`, create a `PodSecurityPolicy` resource. | `false` |
| `apiService.create` | If `true`, create the `v1beta1.metrics.k8s.io` API service. You typically want this enabled! If you disable API service creation you have to manage it outside of this chart for e.g horizontal pod autoscaling to work with this release. | `false` |
| `podAnnotations` | Annotations to add to the pod. | `{}` |
| `podLabels` | Labels to add to the pod. | `{}` |
| `podSecurityContext` | Security context for the pod. | `{}` |
| `securityContext` | Security context for the _metrics-server_ container. | _See values.yaml_ |
| `priorityClassName` | Priority class name to use. | `system-cluster-critical` |
| `hostNetwork.enabled` | If `true`, start _metric-server_ in hostNetwork mode. You would require this enabled if you use alternate overlay networking for pods and API server unable to communicate with metrics-server. As an example, this is required if you use Weave network on EKS. | `false` |
| `replicas` | Number of replicas to run. | `1` |
| `args` | Additional arguments to pass to the _metrics-server_ command. | `[]` |
| `livenessProbe` | Liveness probe. | See _values.yaml_ |
| `readinessProbe` | Readiness probe. | See _values.yaml_ |
| `service.type` | Service type. | `ClusterIP` |
| `service.port` | Service port. | `443` |
| `service.annotations` | Annotations to add to the service. | `{}` |
| `service.labels` | Labels to add to the service. | `{}` |
| `resources` | Resource requests and limits. | `{}` |
| `nodeSelector` | Node labels for pod assignment. | `{}` |
| `tolerations` | Toleration labels for pod assignment. | `[]` |
| `affinity` | Affinity settings for pod assignment. | `{}` |
| `podDisruptionBudget.enabled` | If `true`, create `PodDisruptionBudget` resource. | `{}` |
| `podDisruptionBudget.minAvailable` | Set the `PodDisruptionBugdet` minimum available pods. | `nil` |
| `podDisruptionBudget.maxUnavailable` | Set the `PodDisruptionBugdet` maximum unavailable pods. | `nil` |
11 changes: 11 additions & 0 deletions charts/metrics-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The metric server has been deployed.
{{ if .Values.apiService.create }}
In a few minutes you should be able to list metrics using the following
command:

kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
{{ else }}
NOTE: You have disabled the API service creation for this release. The metrics
API will not work with this release unless you configure the metrics API
service outside of this Helm chart.
{{- end -}}
62 changes: 62 additions & 0 deletions charts/metrics-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "metrics-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "metrics-server.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "metrics-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "metrics-server.labels" -}}
helm.sh/chart: {{ include "metrics-server.chart" . }}
{{ include "metrics-server.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "metrics-server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "metrics-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "metrics-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "metrics-server.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/metrics-server/templates/apiservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.apiService.create -}}
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.metrics.k8s.io
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
spec:
group: metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: {{ include "metrics-server.fullname" . }}
namespace: {{ .Release.Namespace }}
version: v1beta1
versionPriority: 100
{{- end -}}
21 changes: 21 additions & 0 deletions charts/metrics-server/templates/clusterrole-aggregated-reader.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ printf "system:%s-aggregated-reader" (include "metrics-server.name" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
rules:
- apiGroups:
- metrics.k8s.io
resources:
- pods
- nodes
verbs:
- get
- list
- watch
{{- end -}}
32 changes: 32 additions & 0 deletions charts/metrics-server/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ printf "system:%s" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- nodes/stats
- namespaces
- configmaps
verbs:
- get
- list
- watch
{{- if .Values.rbac.pspEnabled }}
- apiGroups:
- extensions
- policy
resources:
- podsecuritypolicies
resourceNames:
- {{ printf "privileged-%s" (include "metrics-server.fullname" .) }}
verbs:
- use
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ printf "%s:system:auth-delegator" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: {{ include "metrics-server.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/metrics-server/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ printf "system:%s" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:{{ template "metrics-server.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "metrics-server.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
Loading

0 comments on commit c379e31

Please sign in to comment.