[go: nahoru, domu]

Skip to content

Commit

Permalink
add helm chart configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentmrg committed Mar 29, 2021
1 parent 94ea8aa commit d432830
Show file tree
Hide file tree
Showing 15 changed files with 541 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ cert-manager:
@helm repo add jetstack https://charts.jetstack.io
@kubectl create namespace cert-manager &> /dev/null | true
@helm upgrade --install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.0.2 --set installCRDs=true

# Generate helm chart documentation
.PHONY: doc
doc:
@docker run --rm --volume "${PWD}/helm/default-scheduler-controller:/helm-docs" jnorwood/helm-docs:latest -s file
File renamed without changes.
5 changes: 5 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resources:
- manager.yaml
# Comment the following line if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
Expand Down
1 change: 0 additions & 1 deletion config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ resources:
# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml
23 changes: 23 additions & 0 deletions helm/default-scheduler-controller/.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/
24 changes: 24 additions & 0 deletions helm/default-scheduler-controller/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: default-scheduler-controller
description: A controller responsible of pods default scheduler overriding.

# 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
# to be deployed.
#
# 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

# 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.1.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.
# It is recommended to use it with quotes.
appVersion: 0.1.0
64 changes: 64 additions & 0 deletions helm/default-scheduler-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# default-scheduler-controller

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

A controller responsible of pods default scheduler overriding.

## Prerequisites

### Kubernetes
A [Kubernetes](https://kubernetes.io/) cluster of version v1.16 or later is required.

### CertManager
This operator needs [CertManager](https://cert-manager.io/docs/) v0.11 or later to be installed on the cluster.

## Usage

In a kubernetes cluster, by default the schedulerName attribute of a pod is "default-scheduler".
This tool handles a mutating webhook to override the defaults-scheduler attribute for new pods created.

## Installation

1. Add default-scheduler-controller helm repository

```sh
helm repo add default-scheduler-controller https://quortex.github.io/default-scheduler-controller
```

2. Create a namespace for default-scheduler-controller

```sh
kubectl create ns default-scheduler-controller-system
```

3. Deploy the appropriate release.

```sh
helm install default-scheduler-controller default-scheduler-controller/default-scheduler-controller -n default-scheduler-controller-system
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| manager.image.repository | string | `"quortexio/default-scheduler-controller"` | default-scheduler-controller manager image repository. |
| manager.image.tag | string | `"latest"` | default-scheduler-controller manager image tag. |
| manager.image.pullPolicy | string | `"IfNotPresent"` | default-scheduler-controller manager image pull policy. |
| manager.resources | object | `{}` | default-scheduler-controller manager container required resources. |
| manager.schedulerName | string | `"default-scheduler"` | The scheduler to set as default scheduler for all pods. |
| kubeRBACProxy.enabled | bool | `true` | |
| kubeRBACProxy.image.repository | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | kube-rbac-proxy image repository. |
| kubeRBACProxy.image.tag | string | `"v0.5.0"` | kube-rbac-proxy image tag. |
| kubeRBACProxy.image.pullPolicy | string | `"IfNotPresent"` | kube-rbac-proxy image pull policy. |
| kubeRBACProxy.resources | object | `{}` | kube-rbac-proxy container required resources. |
| replicaCount | int | `1` | Number of desired pods. |
| imagePullSecrets | list | `[]` | A list of secrets used to pull containers images. |
| nameOverride | string | `""` | Helm's name computing override. |
| fullnameOverride | string | `""` | Helm's fullname computing override. |
| podAnnotations | object | `{}` | Annotations to be added to pods. |
| deploymentAnnotations | object | `{}` | Annotations to be added to deployment. |
| terminationGracePeriod | int | `30` | How long to wait for pods to stop gracefully. |
| nodeSelector | object | `{}` | Node labels for default-scheduler-controller pod assignment. |
| tolerations | list | `[]` | Node tolerations for default-scheduler-controller scheduling to nodes with taints. |
| affinity | object | `{}` | Affinity for default-scheduler-controller pod assignment. |

49 changes: 49 additions & 0 deletions helm/default-scheduler-controller/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

## Prerequisites

### Kubernetes
A [Kubernetes](https://kubernetes.io/) cluster of version v1.16 or later is required.

### CertManager
This operator needs [CertManager](https://cert-manager.io/docs/) v0.11 or later to be installed on the cluster.

## Usage

In a kubernetes cluster, by default the schedulerName attribute of a pod is "default-scheduler".
This tool handles a mutating webhook to override the defaults-scheduler attribute for new pods created.

## Installation

1. Add default-scheduler-controller helm repository

```sh
helm repo add default-scheduler-controller https://quortex.github.io/default-scheduler-controller
```

2. Create a namespace for default-scheduler-controller

```sh
kubectl create ns default-scheduler-controller-system
```

3. Deploy the appropriate release.

```sh
helm install default-scheduler-controller default-scheduler-controller/default-scheduler-controller -n default-scheduler-controller-system
```

{{ template "chart.valuesSection" . }}

{{ template "chart.maintainersSection" . }}
Empty file.
62 changes: 62 additions & 0 deletions helm/default-scheduler-controller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "default-scheduler-controller.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 "default-scheduler-controller.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 "default-scheduler-controller.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "default-scheduler-controller.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "default-scheduler-controller.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
90 changes: 90 additions & 0 deletions helm/default-scheduler-controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{- $fullName := include "default-scheduler-controller.fullname" . -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}
labels:
{{- include "default-scheduler-controller.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "default-scheduler-controller.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "default-scheduler-controller.selectorLabels" . | nindent 8 }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
{{- with .Values.manager }}
- name: manager
image: "{{ .image.repository }}:{{ .image.tag }}"
command:
- /manager
args:
- --metrics-addr={{ ternary "127.0.0.1:8080" "0.0.0.0:8080" $.Values.kubeRBACProxy.enabled }}
- --enable-leader-election
- --scheduler-name={{ .schedulerName }}
imagePullPolicy: {{ .image.pullPolicy }}
ports:
- containerPort: 9443
name: webhook-server
protocol: TCP
{{- if not $.Values.kubeRBACProxy.enabled }}
- containerPort: 8080
name: http
{{- end }}
resources:
{{- toYaml .resources | nindent 12 }}
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
{{- end }}
{{- with .Values.kubeRBACProxy }}
{{- if .enabled }}
- name: kube-rbac-proxy
image: "{{ .image.repository }}:{{ .image.tag }}"
args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
imagePullPolicy: {{ .image.pullPolicy }}
ports:
- containerPort: 8443
name: https
resources:
{{- toYaml .resources | nindent 12 }}
{{- end }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
Loading

0 comments on commit d432830

Please sign in to comment.