Update goldilocks

This commit is contained in:
2024-02-06 23:46:03 +08:00
parent 42516f1f7d
commit cf45a3f547
148 changed files with 352 additions and 141 deletions
+21
View File
@@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.dashboard.ingress.enabled }}
{{- range $host := .Values.dashboard.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.dashboard.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.dashboard.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "goldilocks.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.dashboard.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "goldilocks.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "goldilocks.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.dashboard.service.port }}
{{- else if contains "ClusterIP" .Values.dashboard.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "goldilocks.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=dashboard" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
+54
View File
@@ -0,0 +1,54 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "goldilocks.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 "goldilocks.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 "goldilocks.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account for controller to use
*/}}
{{- define "controller.serviceAccountName" -}}
{{- if .Values.controller.serviceAccount.create -}}
{{ default (printf "%s-controller" (include "goldilocks.fullname" .)) .Values.controller.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.controller.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account for dashboard to use
*/}}
{{- define "dashboard.serviceAccountName" -}}
{{- if .Values.dashboard.serviceAccount.create -}}
{{ default (printf "%s-dashboard" (include "goldilocks.fullname" .)) .Values.dashboard.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.dashboard.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,62 @@
{{- if and .Values.controller.rbac.create .Values.controller.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "goldilocks.fullname" . }}-controller
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: controller
rules:
- apiGroups:
- 'apps'
resources:
- '*'
verbs:
- 'get'
- 'list'
- 'watch'
- apiGroups:
- 'batch'
resources:
- 'cronjobs'
- 'jobs'
verbs:
- 'get'
- 'list'
- 'watch'
- apiGroups:
- ''
resources:
- 'namespaces'
- 'pods'
verbs:
- 'get'
- 'list'
- 'watch'
- apiGroups:
- 'autoscaling.k8s.io'
resources:
- 'verticalpodautoscalers'
verbs:
- 'get'
- 'list'
- 'create'
- 'delete'
- 'update'
{{- if .Values.controller.rbac.enableArgoproj }}
- apiGroups:
- 'argoproj.io'
resources:
- rollouts
verbs:
- 'get'
- 'list'
- 'watch'
{{- end }}
{{- if .Values.controller.rbac.extraRules -}}
{{ toYaml .Values.controller.rbac.extraRules | nindent 2 }}
{{- end }}
{{- end }}
@@ -0,0 +1,43 @@
{{- if and .Values.controller.rbac.create .Values.controller.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "goldilocks.fullname" . }}-controller
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "goldilocks.fullname" . }}-controller
subjects:
- kind: ServiceAccount
name: {{ template "controller.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- range $.Values.controller.rbac.extraClusterRoleBindings }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "goldilocks.fullname" $ }}-controller-{{ . }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" $ }}
helm.sh/chart: {{ include "goldilocks.chart" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/component: controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ . }}
subjects:
- kind: ServiceAccount
name: {{ include "goldilocks.fullname" $ }}-controller
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
@@ -0,0 +1,92 @@
{{- if .Values.controller.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "goldilocks.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: controller
{{- if .Values.controller.deployment.additionalLabels }}
{{ toYaml .Values.controller.deployment.additionalLabels | nindent 4 }}
{{- end }}
{{- with .Values.controller.deployment.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
{{- if .Values.controller.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: controller
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: controller
{{- if .Values.controller.deployment.additionalLabels }}
{{ toYaml .Values.controller.deployment.additionalLabels | nindent 8 }}
{{- end }}
{{- with .Values.controller.deployment.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "controller.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /goldilocks
- controller
- -v{{ .Values.controller.logVerbosity }}
{{- range $name, $value := .Values.controller.flags }}
- --{{ $name }}={{ $value }}
{{- end }}
{{- if .Values.controller.securityContext }}
securityContext:
{{- toYaml .Values.controller.securityContext | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.controller.resources | nindent 12 }}
{{- if .Values.controller.deployment.extraVolumeMounts }}
volumeMounts:
{{ toYaml .Values.controller.deployment.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.controller.deployment.extraVolumes }}
volumes:
{{ toYaml .Values.controller.deployment.extraVolumes | indent 8}}
{{- end }}
{{- with .Values.controller.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,13 @@
{{- if and .Values.controller.serviceAccount.create .Values.controller.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "controller.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: controller
{{- end }}
@@ -0,0 +1,44 @@
{{- if and .Values.dashboard.rbac.create .Values.dashboard.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "goldilocks.fullname" . }}-dashboard
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
rules:
- apiGroups:
- 'autoscaling.k8s.io'
resources:
- 'verticalpodautoscalers'
verbs:
- 'get'
- 'list'
- apiGroups:
- 'apps'
resources:
- '*'
verbs:
- 'get'
- 'list'
- apiGroups:
- ''
resources:
- 'namespaces'
- 'pods'
verbs:
- 'get'
- 'list'
{{- if .Values.dashboard.rbac.enableArgoproj }}
- apiGroups:
- 'argoproj.io'
resources:
- rollouts
verbs:
- 'get'
- 'list'
{{- end }}
{{- end }}
@@ -0,0 +1,20 @@
{{- if and .Values.dashboard.rbac.create .Values.dashboard.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "goldilocks.fullname" . }}-dashboard
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "goldilocks.fullname" . }}-dashboard
subjects:
- kind: ServiceAccount
name: {{ template "dashboard.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
@@ -0,0 +1,109 @@
{{- if .Values.dashboard.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "goldilocks.fullname" . }}-dashboard
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
{{- if .Values.dashboard.deployment.additionalLabels }}
{{ toYaml .Values.dashboard.deployment.additionalLabels | nindent 4 }}
{{- end }}
{{- with .Values.dashboard.deployment.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.dashboard.replicaCount }}
{{- if .Values.dashboard.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.dashboard.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: dashboard
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: dashboard
{{- if .Values.dashboard.deployment.additionalLabels }}
{{ toYaml .Values.dashboard.deployment.additionalLabels | nindent 8 }}
{{- end }}
{{- with .Values.dashboard.deployment.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "dashboard.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.dashboard.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /goldilocks
- dashboard
- --exclude-containers={{ .Values.dashboard.excludeContainers }}
- -v{{ .Values.dashboard.logVerbosity }}
{{- range $name, $value := .Values.dashboard.flags }}
- --{{ $name }}={{ $value }}
{{- end }}
{{- with .Values.dashboard.basePath }}
- --base-path
- {{ . }}
{{- end }}
{{- if .Values.dashboard.securityContext }}
securityContext:
{{- toYaml .Values.dashboard.securityContext | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: {{.Values.dashboard.basePath | default "" }}/health
port: http
readinessProbe:
httpGet:
path: {{.Values.dashboard.basePath | default "" }}/health
port: http
resources:
{{- toYaml .Values.dashboard.resources | nindent 12 }}
{{- if .Values.dashboard.deployment.extraVolumeMounts }}
volumeMounts:
{{ toYaml .Values.dashboard.deployment.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.dashboard.deployment.extraVolumes }}
volumes:
{{ toYaml .Values.dashboard.deployment.extraVolumes | indent 8}}
{{- end }}
{{- with .Values.dashboard.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dashboard.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dashboard.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,60 @@
{{- if and .Values.dashboard.enabled .Values.dashboard.ingress.enabled }}
{{- $fullName := include "goldilocks.fullname" . -}}
{{- $apiV1 := false -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= v1.19-0" .Capabilities.KubeVersion.Version) -}}
apiVersion: networking.k8s.io/v1
{{- $apiV1 = true -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}-dashboard
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
{{- with .Values.dashboard.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (.Values.dashboard.ingress.ingressClassName) (semverCompare ">= v1.18-0" .Capabilities.KubeVersion.Version) }}
ingressClassName: {{ .Values.dashboard.ingress.ingressClassName }}
{{- end }}
{{- if .Values.dashboard.ingress.tls }}
tls:
{{- range .Values.dashboard.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.dashboard.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
{{- if $apiV1 }}
- path: {{ .path }}
pathType: {{ .type }}
backend:
service:
name: {{ $fullName }}-dashboard
port:
name: http
{{- else }}
- path: {{ .path }}
backend:
serviceName: {{ $fullName }}-dashboard
servicePort: http
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,28 @@
{{- if .Values.dashboard.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "goldilocks.fullname" . }}-dashboard
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
{{- with .Values.dashboard.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.dashboard.service.type }}
ports:
- port: {{ .Values.dashboard.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: dashboard
{{- end }}
@@ -0,0 +1,13 @@
{{- if and .Values.dashboard.serviceAccount.create .Values.dashboard.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "dashboard.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: dashboard
{{- end }}
@@ -0,0 +1,75 @@
{{- if .Values.uninstallVPA }}
apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
"helm.sh/hook": "pre-upgrade,post-delete"
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation,hook-failed"
"helm.sh/hook-weight": "-250"
name: {{ include "goldilocks.fullname" . }}-vpa-uninstall
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "goldilocks.fullname" . }}-vpa-uninstall
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: vpa-uninstall
annotations:
"helm.sh/hook": "pre-upgrade,post-delete"
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation,hook-failed"
"helm.sh/hook-weight": "-240"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: {{ include "goldilocks.fullname" . }}-vpa-uninstall
namespace: {{ .Release.Namespace }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "goldilocks.fullname" . }}-vpa-uninstall
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: vpa-uninstall
annotations:
"helm.sh/hook": "pre-upgrade,post-delete"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/hook-weight": "-230"
spec:
template:
metadata:
name: {{ include "goldilocks.fullname" . }}-vpa-uninstall
labels:
app.kubernetes.io/name: {{ include "goldilocks.name" . }}
helm.sh/chart: {{ include "goldilocks.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: vpa-uninstall
spec:
restartPolicy: Never
serviceAccountName: {{ include "goldilocks.fullname" . }}-vpa-uninstall
containers:
- name: vpa-uninstall
image: quay.io/reactiveops/ci-images:v9-alpine
command: ["bash"]
args:
- -c
- |
apk --update add git openssl
git clone "https://github.com/kubernetes/autoscaler.git"
cd autoscaler/vertical-pod-autoscaler
git checkout {{ .Values.vpaVersion }}
./hack/vpa-down.sh
{{- end }}