Added chart versions:
cerbos/cerbos: - 0.39.0 cockroach-labs/cockroachdb: - 14.0.4 codefresh/cf-runtime: - 6.4.2 crate/crate-operator: - 2.42.0 f5/nginx-ingress: - 1.4.0 intel/intel-device-plugins-operator: - 0.31.0 intel/intel-device-plugins-qat: - 0.31.0 intel/intel-device-plugins-sgx: - 0.31.0 jenkins/jenkins: - 5.7.2 new-relic/nri-bundle: - 5.0.93 speedscale/speedscale-operator: - 2.2.488pull/1067/head
parent
8f3dfcabb5
commit
1bba14c669
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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/
|
|
@ -0,0 +1,27 @@
|
|||
annotations:
|
||||
catalog.cattle.io/certified: partner
|
||||
catalog.cattle.io/display-name: Cerbos
|
||||
catalog.cattle.io/kube-version: '>=1.23.0-0'
|
||||
catalog.cattle.io/release-name: cerbos
|
||||
apiVersion: v2
|
||||
appVersion: 0.39.0
|
||||
description: A Helm chart to deploy Cerbos. Cerbos is an open core, language agnostic,
|
||||
scalable solution that makes user permissions and authorization simple to implement
|
||||
and manage by writing context-aware access control policies for your application
|
||||
resources.
|
||||
home: https://cerbos.dev
|
||||
icon: file://assets/icons/cerbos.png
|
||||
keywords:
|
||||
- abac
|
||||
- authorization
|
||||
- developer tools
|
||||
- policies
|
||||
- rbac
|
||||
- security
|
||||
kubeVersion: '>=1.23.0-0'
|
||||
maintainers:
|
||||
- email: help+helm@cerbos.dev
|
||||
name: Cerbos authors
|
||||
name: cerbos
|
||||
type: application
|
||||
version: 0.39.0
|
|
@ -0,0 +1,9 @@
|
|||
Cerbos Helm Chart
|
||||
=================
|
||||
|
||||
Cerbos is the open core, language-agnostic, scalable authorization solution that makes user permissions and authorization simple to implement and manage by writing context-aware access control policies for your application resources.
|
||||
|
||||
* [Cerbos website](https://cerbos.dev)
|
||||
* [Cerbos documentation](https://docs.cerbos.dev)
|
||||
* [Cerbos GitHub repository](https://github.com/cerbos/cerbos)
|
||||
* [Cerbos Slack community](http://go.cerbos.io/slack)
|
|
@ -0,0 +1,5 @@
|
|||
## Cerbos
|
||||
|
||||
Implement roles and permissions in your application in minutes with Cerbos. Cerbos is a plug and play collaborative authorization service for developer, product and security teams.
|
||||
|
||||
A guide for how to deploy Cerbos can be found on the [Cerbos Documentation](https://docs.cerbos.dev/cerbos/latest/installation/helm) site.
|
|
@ -0,0 +1,17 @@
|
|||
You have successfully deployed Cerbos.
|
||||
|
||||
You can get started with the API by accessing the Cerbos OpenAPI definitions as follows:
|
||||
{{- $scheme := (include "cerbos.httpScheme" .) -}}
|
||||
{{- if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "cerbos.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo {{ $scheme }}://$NODE_IP:$NODE_PORT/schema/swagger.json
|
||||
{{- else if contains "LoadBalancer" .Values.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 "cerbos.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "cerbos.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo {{ $scheme }}://$SERVICE_IP:{{ .Values.service.port }}/schema/swagger.json
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
echo "Download OpenAPI definition by accesing {{ $scheme }}://127.0.0.1:{{ .Values.service.httpPort }}/schema/swagger.json"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "cerbos.fullname" . }} {{ .Values.service.httpPort }}
|
||||
{{- end }}
|
|
@ -0,0 +1,193 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "cerbos.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 "cerbos.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 "cerbos.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "cerbos.labels" -}}
|
||||
helm.sh/chart: {{ include "cerbos.chart" . }}
|
||||
{{ include "cerbos.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- with .Values.commonLabels }}
|
||||
{{ toYaml . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "cerbos.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "cerbos.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Name of the secret used to read the TLS certificates from
|
||||
*/}}
|
||||
{{- define "cerbos.tlsSecretName" -}}
|
||||
{{ coalesce .Values.cerbos.tlsSecretName .Values.certManager.certSpec.secretName "None" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Determine the scheme based on whether the TLS secret is defined or not
|
||||
*/}}
|
||||
{{- define "cerbos.httpScheme" -}}
|
||||
{{- $tlsDisabled := (eq (include "cerbos.tlsSecretName" .) "None") -}}
|
||||
{{- if $tlsDisabled -}}
|
||||
http
|
||||
{{- else -}}
|
||||
https
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Prometheus annotations
|
||||
*/}}
|
||||
{{- define "cerbos.promAnnotations" -}}
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.cerbos.httpPort }}"
|
||||
prometheus.io/path: "/_cerbos/metrics"
|
||||
prometheus.io/scheme: {{ include "cerbos.httpScheme" . }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Generate pod annotations based on config
|
||||
*/}}
|
||||
{{- define "cerbos.podAnnotations" -}}
|
||||
{{- $annotations := mustMergeOverwrite .Values.podAnnotations (dict "checksum/config" (include "cerbos.config" . | sha256sum)) -}}
|
||||
{{- if .Values.cerbos.prometheusPodAnnotationsEnabled -}}
|
||||
{{- $promAnnotations := (include "cerbos.promAnnotations" .)| fromYaml -}}
|
||||
{{- $annotations = mustMergeOverwrite $annotations $promAnnotations -}}
|
||||
{{- end -}}
|
||||
annotations:
|
||||
{{- $annotations | toYaml | nindent 2 }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "cerbos.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "cerbos.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Default configuration if none is provided
|
||||
*/}}
|
||||
{{- define "cerbos.defaultConfig" -}}
|
||||
storage:
|
||||
driver: "disk"
|
||||
disk:
|
||||
directory: /work
|
||||
watchForChanges: false
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Configuration derived from values provided by the user
|
||||
*/}}
|
||||
{{- define "cerbos.derivedConfig" -}}
|
||||
{{- $tlsDisabled := (eq (include "cerbos.tlsSecretName" .) "None") -}}
|
||||
{{- $defaultHTTPListenAddr := (toString .Values.cerbos.httpPort | printf ":%s") -}}
|
||||
{{- $defaultGRPCListenAddr := (toString .Values.cerbos.grpcPort | printf ":%s") -}}
|
||||
server:
|
||||
httpListenAddr: "{{ dig "config" "server" "httpListenAddr" $defaultHTTPListenAddr .Values.cerbos }}"
|
||||
grpcListenAddr: "{{ dig "config" "server" "grpcListenAddr" $defaultGRPCListenAddr .Values.cerbos }}"
|
||||
{{- if not $tlsDisabled }}
|
||||
tls:
|
||||
cert: /certs/tls.crt
|
||||
key: /certs/tls.key
|
||||
caCert: /certs/ca.crt
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Merge the configurations to obtain the final configuration file
|
||||
*/}}
|
||||
{{- define "cerbos.config" -}}
|
||||
{{- $defaultConf := (include "cerbos.defaultConfig" .) | fromYaml -}}
|
||||
{{- $derivedConf := (include "cerbos.derivedConfig" .) | fromYaml -}}
|
||||
{{ mustMergeOverwrite $defaultConf .Values.cerbos.config $derivedConf | toYaml }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Detect if hub driver is used with default config
|
||||
*/}}
|
||||
{{- define "cerbos.defaultHubDriverEnabled" -}}
|
||||
{{- $isBundleDriver := (eq (dig "config" "storage" "driver" "<not_defined>" .Values.cerbos) "bundle") -}}
|
||||
{{- $isHubDriver := (eq (dig "config" "storage" "driver" "<not_defined>" .Values.cerbos) "hub") -}}
|
||||
{{- $isBundleStorage := (or $isBundleDriver $isHubDriver) -}}
|
||||
{{- $isDefaultTmp := (eq (dig "config" "storage" "bundle" "remote" "tempDir" "<not_defined>" .Values.cerbos) "<not_defined>") -}}
|
||||
{{- $isDefaultCache := (eq (dig "config" "storage" "bundle" "remote" "cacheDir" "<not_defined>" .Values.cerbos) "<not_defined>") -}}
|
||||
{{- if (and $isBundleStorage $isDefaultTmp $isDefaultCache) -}}yes{{- else -}}no{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
The image reference to use in pods
|
||||
*/}}
|
||||
{{- define "cerbos.image" -}}
|
||||
"{{ .Values.image.repository }}
|
||||
{{- with .Values.image.digest -}}
|
||||
@{{ . }}
|
||||
{{- else -}}
|
||||
:{{ .Values.image.tag | default .Chart.AppVersion }}
|
||||
{{- end -}}
|
||||
"
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Topology spread constraints with label selector injected
|
||||
*/}}
|
||||
{{- define "cerbos.topologySpreadConstraints" -}}
|
||||
{{- if .Values.topologySpreadConstraints }}
|
||||
{{- $defaultLabels := (fromYaml (include "cerbos.selectorLabels" $)) }}
|
||||
{{- $defaultLabelSelector := (dict "labelSelector" (dict "matchLabels" $defaultLabels)) }}
|
||||
{{- $constraints := list }}
|
||||
{{- range $c := .Values.topologySpreadConstraints }}
|
||||
{{- if (hasKey $c "labelSelector") }}
|
||||
{{- $constraints = (append $constraints $c) }}
|
||||
{{- else }}
|
||||
{{- $constraints = (append $constraints (mergeOverwrite $c $defaultLabelSelector)) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
topologySpreadConstraints:
|
||||
{{ toYaml $constraints | indent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,10 @@
|
|||
{{- if .Values.certManager.certSpec -}}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
spec:
|
||||
{{- toYaml .Values.certManager.certSpec | nindent 2 }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,9 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
data:
|
||||
".cerbos.yaml": |-
|
||||
{{- include "cerbos.config" . | nindent 8 }}
|
|
@ -0,0 +1,149 @@
|
|||
{{- $tlsDisabled := (eq (include "cerbos.tlsSecretName" .) "None") -}}
|
||||
{{- $defaultHubDriverEnabled := (eq (include "cerbos.defaultHubDriverEnabled" .) "yes") -}}
|
||||
apiVersion: apps/v1
|
||||
{{- if eq .Values.type "deployment" }}
|
||||
kind: Deployment
|
||||
{{- else if eq .Values.type "daemonset" }}
|
||||
kind: DaemonSet
|
||||
{{- else }}
|
||||
{{- fail "valid values for .Values.type are deployment or daemonset" }}
|
||||
{{- end}}
|
||||
metadata:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
{{- with .Values.deployment.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if not .Values.autoscaling.enabled }}
|
||||
{{- if eq .Values.type "deployment" }}
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "cerbos.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "cerbos.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.commonLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- include "cerbos.podAnnotations" . | nindent 6 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "cerbos.serviceAccountName" . }}
|
||||
{{- with .Values.podSecurityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.initContainers }}
|
||||
initContainers:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{- .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
{{- with .Values.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
image: {{ include "cerbos.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
args:
|
||||
- "server"
|
||||
- "--config=/config/.cerbos.yaml"
|
||||
- "--log-level={{ .Values.cerbos.logLevel }}"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.cerbos.httpPort }}
|
||||
- name: grpc
|
||||
containerPort: {{ .Values.cerbos.grpcPort }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /_cerbos/health
|
||||
port: http
|
||||
scheme: {{ include "cerbos.httpScheme" . | upper }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /_cerbos/health
|
||||
port: http
|
||||
scheme: {{ include "cerbos.httpScheme" . | upper }}
|
||||
{{- with .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.env }}
|
||||
env:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.envFrom }}
|
||||
envFrom:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /config
|
||||
readOnly: true
|
||||
{{- if $defaultHubDriverEnabled }}
|
||||
- name: bundletmp
|
||||
mountPath: /tmp
|
||||
- name: bundlecache
|
||||
mountPath: /.cache
|
||||
{{- else }}
|
||||
- name: work
|
||||
mountPath: /work
|
||||
{{- end }}
|
||||
{{- if not $tlsDisabled }}
|
||||
- name: certs
|
||||
mountPath: /certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- with .Values.volumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
{{- if $defaultHubDriverEnabled }}
|
||||
- name: bundletmp
|
||||
emptyDir: {}
|
||||
- name: bundlecache
|
||||
emptyDir: {}
|
||||
{{- else }}
|
||||
- name: work
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if not $tlsDisabled }}
|
||||
- name: certs
|
||||
secret:
|
||||
secretName: {{ include "cerbos.tlsSecretName" . }}
|
||||
{{- end }}
|
||||
{{- with .Values.volumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- include "cerbos.topologySpreadConstraints" . | nindent 6}}
|
|
@ -0,0 +1,32 @@
|
|||
{{- if and .Values.autoscaling.enabled (eq .Values.type "deployment") }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,40 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "cerbos.fullname" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
{{- with .Values.service.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
{{- with .Values.service.clusterIP }}
|
||||
clusterIP: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.service.internalTrafficPolicy }}
|
||||
internalTrafficPolicy: {{ .Values.service.internalTrafficPolicy }}
|
||||
{{- else if eq .Values.type "daemonset" }}
|
||||
internalTrafficPolicy: Local
|
||||
{{- end }}
|
||||
ports:
|
||||
- port: {{ .Values.service.httpPort }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
{{ if eq .Values.service.type "NodePort" -}}
|
||||
nodePort: {{ .Values.service.httpNodePort }}
|
||||
{{- end }}
|
||||
- port: {{ .Values.service.grpcPort }}
|
||||
targetPort: grpc
|
||||
protocol: TCP
|
||||
name: grpc
|
||||
{{ if eq .Values.service.type "NodePort" -}}
|
||||
nodePort: {{ .Values.service.grpcNodePort }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "cerbos.selectorLabels" . | nindent 4 }}
|
|
@ -0,0 +1,12 @@
|
|||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "cerbos.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "cerbos.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,40 @@
|
|||
# Illustrates how to deploy Cerbos with an SQLite3 backend and audit logs.
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
# Configure the SQLite3 storage driver
|
||||
storage:
|
||||
driver: "sqlite3"
|
||||
sqlite3:
|
||||
dsn: "file:/data/cerbos.sqlite?mode=rwc&_fk=true"
|
||||
# Configure audit logging
|
||||
audit:
|
||||
enabled: true
|
||||
accessLogsEnabled: true
|
||||
decisionLogsEnabled: true
|
||||
backend: local
|
||||
local:
|
||||
storagePath: /audit/cerbos
|
||||
|
||||
# Create volumes to hold the SQLite3 database and the audit log.
|
||||
# Note that this example uses emptyDir volumes that lose data when the pod or node is killed.
|
||||
# Use persistent volumes in production to preserve the data between pod restarts.
|
||||
|
||||
volumes:
|
||||
- name: cerbos-policies
|
||||
emptyDir: {}
|
||||
- name: cerbos-auditlog
|
||||
emptyDir: {}
|
||||
|
||||
volumeMounts:
|
||||
- name: cerbos-policies
|
||||
mountPath: /data
|
||||
- name: cerbos-auditlog
|
||||
mountPath: /audit
|
||||
|
||||
# Optional: Autoscale the Cerbos deployment using CPU and memory utilization.
|
||||
autoscaling:
|
||||
enabled: true
|
||||
targetCPUUtilizationPercentage: 80
|
||||
targetMemoryUtilizationPercentage: 80
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# Illustrates how to connect a PDP to Cerbos Hub
|
||||
# Prerequisites:
|
||||
# - Sign up to Cerbos Hub and follow the instructions to create client credentials.
|
||||
# - Create a Kubernetes secret named `cerbos-hub-credentials`:
|
||||
# kubectl create secret generic cerbos-hub-credentials \
|
||||
# --from-literal=CERBOS_HUB_CLIENT_ID=<YOUR_CLIENT_ID> \
|
||||
# --from-literal=CERBOS_HUB_CLIENT_SECRET=<YOUR_CLIENT_SECRET> \
|
||||
# --from-literal=CERBOS_HUB_WORKSPACE_SECRET=<YOUR_WORKSPACE_SECRET>
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
# Configure the Hub storage driver
|
||||
storage:
|
||||
driver: "hub"
|
||||
hub:
|
||||
remote:
|
||||
bundleLabel: "YOUR_LABEL" # Alternatively, add `CERBOS_HUB_BUNDLE=<YOUR_LABEL>` to the secret you created above.
|
||||
|
||||
# Configure the Hub audit backend
|
||||
audit:
|
||||
enabled: true
|
||||
backend: "hub"
|
||||
hub:
|
||||
storagePath: /audit_logs
|
||||
|
||||
# Create environment variables from the secret.
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: cerbos-hub-credentials
|
||||
|
||||
# Mount volume for locally buffering the audit logs. A persistent volume is recommended for production use cases.
|
||||
volumes:
|
||||
- name: cerbos-audit-logs
|
||||
emptyDir: {}
|
||||
|
||||
volumeMounts:
|
||||
- name: cerbos-audit-logs
|
||||
mountPath: /audit_logs
|
|
@ -0,0 +1,40 @@
|
|||
# Illustrates how to deploy Cerbos with a TLS certificate issued by cert-manager.
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
# Configure the SQLite3 storage driver
|
||||
storage:
|
||||
driver: "sqlite3"
|
||||
sqlite3:
|
||||
dsn: "file:/data/cerbos.sqlite?mode=rwc&_fk=true"
|
||||
|
||||
certManager:
|
||||
certSpec:
|
||||
secretName: cerbos-certs
|
||||
secretTemplate:
|
||||
labels:
|
||||
app.kubernetes.io/component: certificate
|
||||
app.kubernetes.io/part-of: cerbos
|
||||
duration: 48h
|
||||
renewBefore: 36h
|
||||
subject:
|
||||
organizations:
|
||||
- cerbos
|
||||
isCA: false
|
||||
dnsNames: ["cerbos.security.svc.cluster.local"]
|
||||
issuerRef:
|
||||
name: ca-cluster-issuer
|
||||
kind: ClusterIssuer
|
||||
|
||||
|
||||
# Create volumes to hold the SQLite3 database.
|
||||
# Note that this example uses emptyDir volumes that lose data when the pod or node is killed.
|
||||
# Use persistent volumes in production to preserve the data between pod restarts.
|
||||
volumes:
|
||||
- name: cerbos-policies
|
||||
emptyDir: {}
|
||||
|
||||
volumeMounts:
|
||||
- name: cerbos-policies
|
||||
mountPath: /data
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Illustrates how to connect Cerbos to a policy repository hosted on GitHub.
|
||||
# Prerequisites:
|
||||
# - Create a personal access token (PAT) in GitHub with `repo` permissions (https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
# - Create a Kubernetes secret named `cerbos-github-token`:
|
||||
# PAT=YOUR_GITHUB_PAT kubectl create secret generic cerbos-github-token --from-literal=GITHUB_TOKEN=$PAT
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
# Configure the git storage driver
|
||||
storage:
|
||||
driver: "git"
|
||||
git:
|
||||
protocol: https
|
||||
# Replace with the URL of your GitHub repo.
|
||||
url: https://github.com/cerbos/sample-policies.git
|
||||
# Replace with the branch name of your repo.
|
||||
branch: main
|
||||
# Remove or leave empty if the policies are not stored in a subdirectory.
|
||||
subDir: hr
|
||||
# Path to checkout. By default, /work is a Kubernetes emptyDir volume that is only available for the lifetime of the pod.
|
||||
# If you want the work directory to persist between pod restarts, specify the mount path of a persistent volume here.
|
||||
checkoutDir: /work
|
||||
# How often the remote repo should be checked for updates.
|
||||
updatePollInterval: 60s
|
||||
# Credentials used to login to the remote GitHub repo. We are using an environment variable mounted from the secret we created earlier.
|
||||
https:
|
||||
username: ${GITHUB_TOKEN}
|
||||
password: ""
|
||||
|
||||
# Create an environment variable from the GitHub PAT stored in a secret.
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: cerbos-github-token
|
|
@ -0,0 +1,43 @@
|
|||
# Illustrates how to deploy Cerbos with traces exported via OTLP.
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
# Configure the SQLite3 storage driver
|
||||
storage:
|
||||
driver: "sqlite3"
|
||||
sqlite3:
|
||||
dsn: "file:/data/cerbos.sqlite?mode=rwc&_fk=true"
|
||||
|
||||
# Environment variables to configure OTLP exporter.
|
||||
env:
|
||||
- name: OTEL_SERVICE_NAME
|
||||
value: cerbos.myns.svc
|
||||
- name: OTEL_TRACE_SAMPLER
|
||||
value: parentbased_always_on
|
||||
- name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
|
||||
value: https://otlp.monitoring.svc.cluster.local
|
||||
|
||||
# Optional common labels for resources.
|
||||
commonLabels:
|
||||
app.kubernetes.io/part-of: my-awesome-app
|
||||
|
||||
# Optional annotations for the service.
|
||||
service:
|
||||
annotations:
|
||||
a8r.io/owner: my-awesome-team
|
||||
a8r.io/uptime: dashboard.example.com/cerbos
|
||||
|
||||
# Optional annotations for the Cerbos pod.
|
||||
podAnnotations:
|
||||
a8r.io/owner: my-awesome-team
|
||||
|
||||
# Create volumes to hold the SQLite3 database.
|
||||
# Note that this example uses emptyDir volumes that lose data when the pod or node is killed.
|
||||
# Use persistent volumes in production to preserve the data between pod restarts.
|
||||
volumes:
|
||||
- name: cerbos-policies
|
||||
emptyDir: {}
|
||||
|
||||
volumeMounts:
|
||||
- name: cerbos-policies
|
||||
mountPath: /data
|
|
@ -0,0 +1,19 @@
|
|||
# Illustrates how to mount a volume containing policies to the Cerbos pod.
|
||||
|
||||
volumes:
|
||||
- name: cerbos-policies
|
||||
hostPath:
|
||||
path: /data/cerbos-policies
|
||||
|
||||
volumeMounts:
|
||||
- name: cerbos-policies
|
||||
mountPath: /policies
|
||||
readOnly: true
|
||||
|
||||
cerbos:
|
||||
config:
|
||||
storage:
|
||||
driver: "disk"
|
||||
disk:
|
||||
directory: /policies
|
||||
watchForChanges: true
|
|
@ -0,0 +1,572 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"affinity": {
|
||||
"additionalProperties": true,
|
||||
"description": "Pod affinity rules. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.",
|
||||
"required": [],
|
||||
"title": "affinity",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"autoscaling": {
|
||||
"additionalProperties": true,
|
||||
"description": "Autoscaling configuration.",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
"required": [],
|
||||
"type": "boolean"
|
||||
},
|
||||
"maxReplicas": {
|
||||
"default": 100,
|
||||
"required": [],
|
||||
"type": "integer"
|
||||
},
|
||||
"minReplicas": {
|
||||
"default": 1,
|
||||
"required": [],
|
||||
"type": "integer"
|
||||
},
|
||||
"targetCPUUtilizationPercentage": {
|
||||
"default": 80,
|
||||
"required": [],
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"targetMemoryUtilizationPercentage": {
|
||||
"required": [],
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "autoscaling",
|
||||
"type": "object"
|
||||
},
|
||||
"cerbos": {
|
||||
"additionalProperties": false,
|
||||
"description": "Cerbos deployment settings.",
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": true,
|
||||
"description": "Cerbos config file contents.\nSome server settings like server.httpListenAddr, server.grpcListenAddr, server.tls will be overwritten by the chart based on values provided above.",
|
||||
"required": [],
|
||||
"title": "config",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"grpcPort": {
|
||||
"default": 3593,
|
||||
"description": "Port to expose the gRPC service on.",
|
||||
"required": [],
|
||||
"title": "grpcPort",
|
||||
"type": "integer"
|
||||
},
|
||||
"httpPort": {
|
||||
"default": 3592,
|
||||
"description": "Port to expose the http service on.",
|
||||
"required": [],
|
||||
"title": "httpPort",
|
||||
"type": "integer"
|
||||
},
|
||||
"logLevel": {
|
||||
"default": "INFO",
|
||||
"description": "Cerbos log level. Valid values are DEBUG, INFO, WARN and ERROR",
|
||||
"required": [],
|
||||
"title": "logLevel",
|
||||
"type": "string"
|
||||
},
|
||||
"prometheusPodAnnotationsEnabled": {
|
||||
"default": true,
|
||||
"description": "Add Prometheus service discovery annotations to the pod.",
|
||||
"required": [],
|
||||
"title": "prometheusPodAnnotationsEnabled",
|
||||
"type": "boolean"
|
||||
},
|
||||
"tlsSecretName": {
|
||||
"default": "",
|
||||
"description": "Secret containing the TLS certificate.\nLeave empty to disable TLS.\nThe secret must contain the following keys:\n - tls.crt: Required. Certificate file contents.\n - tls.key: Required. Private key for the certificate.\n - ca.crt: Optional. CA certificate to add to the trust pool.",
|
||||
"required": [],
|
||||
"title": "tlsSecretName",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"httpPort",
|
||||
"grpcPort",
|
||||
"logLevel",
|
||||
"prometheusPodAnnotationsEnabled"
|
||||
],
|
||||
"title": "cerbos"
|
||||
},
|
||||
"certManager": {
|
||||
"additionalProperties": false,
|
||||
"description": "Spec of the cert-manager certificate to create for the Cerbos deployment.\nIf certSpec is not empty, a cert-manager.io/v1/Certificate resource will be created with its spec populated with values from certSpec.\nThe certSpec value must be a valid Certificate spec. This Helm chart does not provide any defaults or inject any values into it.\nIf cerbos.tlsSecretName is defined, it takes precedence over the generated certificate.",
|
||||
"properties": {
|
||||
"certSpec": {
|
||||
"required": [],
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "certManager",
|
||||
"type": "object"
|
||||
},
|
||||
"commonLabels": {
|
||||
"additionalProperties": true,
|
||||
"description": "Common labels to add to the resources. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.",
|
||||
"required": [],
|
||||
"title": "commonLabels",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deployment": {
|
||||
"additionalProperties": false,
|
||||
"description": "Annotations to add to the deployment. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"title": "annotations",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "deployment"
|
||||
},
|
||||
"env": {
|
||||
"description": "Environment variables to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#environment-variables.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"required": [],
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"required": [],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "env",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"envFrom": {
|
||||
"description": "Source environment variables from config maps or secrets. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#environment-variables.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "envFrom",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"fullnameOverride": {
|
||||
"default": "",
|
||||
"required": [],
|
||||
"title": "fullnameOverride",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"global": {
|
||||
"description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.",
|
||||
"required": [],
|
||||
"title": "global",
|
||||
"type": "object"
|
||||
},
|
||||
"image": {
|
||||
"additionalProperties": false,
|
||||
"description": "Container image details. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image.",
|
||||
"properties": {
|
||||
"digest": {
|
||||
"default": "",
|
||||
"description": "Image digest to use. Takes precedence over tag if specified.",
|
||||
"required": [],
|
||||
"title": "digest",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"pullPolicy": {
|
||||
"default": [
|
||||
"IfNotPresent"
|
||||
],
|
||||
"description": "Image pull policy.",
|
||||
"enum": [
|
||||
"IfNotPresent",
|
||||
"Always"
|
||||
],
|
||||
"required": [],
|
||||
"title": "pullPolicy"
|
||||
},
|
||||
"repository": {
|
||||
"default": "ghcr.io.cerbos/cerbos",
|
||||
"description": "Container image name without the tag.",
|
||||
"required": [],
|
||||
"title": "repository"
|
||||
},
|
||||
"tag": {
|
||||
"default": "",
|
||||
"description": "Image tag to use. Defaults to the chart appVersion.",
|
||||
"required": [],
|
||||
"title": "tag",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "image"
|
||||
},
|
||||
"imagePullSecrets": {
|
||||
"description": "Image pull secrets to use if pulling the image from a private container registry. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#containers.",
|
||||
"items": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"required": [],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "imagePullSecrets",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"initContainers": {
|
||||
"description": "Init containers to inject into the deployment. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#containers.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "initContainers",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"nameOverride": {
|
||||
"default": "",
|
||||
"required": [],
|
||||
"title": "nameOverride",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"nodeSelector": {
|
||||
"additionalProperties": true,
|
||||
"description": "Node selector for the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.",
|
||||
"required": [],
|
||||
"title": "nodeSelector",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"podAnnotations": {
|
||||
"additionalProperties": true,
|
||||
"description": "Annotations to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.",
|
||||
"required": [],
|
||||
"title": "podAnnotations",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"podLabels": {
|
||||
"additionalProperties": true,
|
||||
"description": "Labels to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.",
|
||||
"required": [],
|
||||
"title": "podLabels",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"podSecurityContext": {
|
||||
"additionalProperties": true,
|
||||
"description": "Security context for the whole pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1.",
|
||||
"required": [],
|
||||
"title": "podSecurityContext",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"priorityClassName": {
|
||||
"default": "",
|
||||
"description": "PriorityClassName to set on deployed pods",
|
||||
"required": [],
|
||||
"title": "priorityClassName",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"replicaCount": {
|
||||
"default": 1,
|
||||
"description": "Number of Cerbos pods to run",
|
||||
"required": [],
|
||||
"title": "replicaCount",
|
||||
"type": "integer"
|
||||
},
|
||||
"resources": {
|
||||
"additionalProperties": true,
|
||||
"description": "Resource limits for the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#resources.",
|
||||
"properties": {
|
||||
"limits": {
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"requests": {
|
||||
"required": [],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "resources",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"securityContext": {
|
||||
"additionalProperties": true,
|
||||
"description": "Security context for the Cerbos container. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1.",
|
||||
"required": [],
|
||||
"title": "securityContext",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"service": {
|
||||
"additionalProperties": false,
|
||||
"description": "Cerbos service settings.",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"additionalProperties": true,
|
||||
"description": "Service annotations",
|
||||
"required": [],
|
||||
"title": "annotations",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"clusterIP": {
|
||||
"default": "null",
|
||||
"description": "Service Cluster IP",
|
||||
"required": [],
|
||||
"title": "clusterIP",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"grpcNodePort": {
|
||||
"default": 13593,
|
||||
"description": "gRPC node port (if service type is NodePort)",
|
||||
"required": [],
|
||||
"title": "grpcNodePort"
|
||||
},
|
||||
"grpcPort": {
|
||||
"default": 3593,
|
||||
"description": "Service gRPC port",
|
||||
"required": [],
|
||||
"title": "grpcPort"
|
||||
},
|
||||
"httpNodePort": {
|
||||
"default": 13592,
|
||||
"description": "HTTP node port (if service type is NodePort)",
|
||||
"required": [],
|
||||
"title": "httpNodePort"
|
||||
},
|
||||
"httpPort": {
|
||||
"default": 3592,
|
||||
"description": "Service HTTP port",
|
||||
"required": [],
|
||||
"title": "httpPort"
|
||||
},
|
||||
"internalTrafficPolicy": {
|
||||
"default": "",
|
||||
"description": "Set the internalTrafficPolicy. If this is unset and .Values.type is set to daemonset, this will default to \"Local\"",
|
||||
"required": [],
|
||||
"title": "internalTrafficPolicy",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"loadBalancerIP": {
|
||||
"default": "null",
|
||||
"description": "LoadBalancer static IP",
|
||||
"required": [],
|
||||
"title": "loadBalancerIP",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"default": "ClusterIP",
|
||||
"description": "Service type",
|
||||
"enum": [
|
||||
"ClusterIP",
|
||||
"NodePort",
|
||||
"LoadBalancer"
|
||||
],
|
||||
"required": [],
|
||||
"title": "type"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "service"
|
||||
},
|
||||
"serviceAccount": {
|
||||
"additionalProperties": false,
|
||||
"description": "Service account settings",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"additionalProperties": true,
|
||||
"description": "Annotations to add to the service account. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.",
|
||||
"required": [],
|
||||
"title": "annotations",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"create": {
|
||||
"default": true,
|
||||
"description": "Specifies whether a service account should be created.",
|
||||
"required": [],
|
||||
"title": "create"
|
||||
},
|
||||
"name": {
|
||||
"default": "",
|
||||
"description": "The name of the service account to use.\nIf not set and create is true, a name is generated using the fullname template",
|
||||
"required": [],
|
||||
"title": "name",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"title": "serviceAccount"
|
||||
},
|
||||
"tolerations": {
|
||||
"description": "Pod tolerations. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "tolerations",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"topologySpreadConstraints": {
|
||||
"description": "Topology Spread Constraints rules. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "topologySpreadConstraints",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"default": "deployment",
|
||||
"description": "Kubernetes workload type to use. Valid values are `deployment` or `daemonset`.",
|
||||
"enum": [
|
||||
"deployment",
|
||||
"daemonset"
|
||||
],
|
||||
"required": [],
|
||||
"title": "type"
|
||||
},
|
||||
"volumeMounts": {
|
||||
"description": "Volume mounts to add to the Cerbos container. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#volumes-1.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "volumeMounts",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"volumes": {
|
||||
"description": "Volumes to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#volumes.",
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"required": [],
|
||||
"type": "object"
|
||||
},
|
||||
"required": [],
|
||||
"title": "volumes",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"type": "object"
|
||||
}
|
|
@ -0,0 +1,369 @@
|
|||
# Default values for cerbos.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
nameOverride: ""
|
||||
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
fullnameOverride: ""
|
||||
|
||||
# @schema
|
||||
# type: [integer]
|
||||
# default: 1
|
||||
# @schema
|
||||
# Number of Cerbos pods to run
|
||||
replicaCount: 1
|
||||
|
||||
# @schema
|
||||
# required: false
|
||||
# @schema
|
||||
# Container image details. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#image.
|
||||
image:
|
||||
# @schema
|
||||
# default: "ghcr.io.cerbos/cerbos"
|
||||
# @schema
|
||||
# Container image name without the tag.
|
||||
repository: ghcr.io/cerbos/cerbos
|
||||
# @schema
|
||||
# enum: [IfNotPresent, Always]
|
||||
# default: ["IfNotPresent"]
|
||||
# @schema
|
||||
# Image pull policy.
|
||||
pullPolicy: IfNotPresent
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
# Image digest to use. Takes precedence over tag if specified.
|
||||
digest: ""
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
# Image tag to use. Defaults to the chart appVersion.
|
||||
tag: ""
|
||||
|
||||
# @schema
|
||||
# type: [array,null]
|
||||
# items:
|
||||
# type: object
|
||||
# properties:
|
||||
# name:
|
||||
# type: string
|
||||
# @schema
|
||||
# Image pull secrets to use if pulling the image from a private container registry. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#containers.
|
||||
imagePullSecrets: []
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Init containers to inject into the deployment. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#containers.
|
||||
initContainers: []
|
||||
|
||||
# @schema
|
||||
# required: false
|
||||
# @schema
|
||||
# Service account settings
|
||||
serviceAccount:
|
||||
# @schema
|
||||
# default: true
|
||||
# @schema
|
||||
# Specifies whether a service account should be created.
|
||||
create: true
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Annotations to add to the service account. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.
|
||||
annotations: {}
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
# The name of the service account to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name: ""
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Annotations to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.
|
||||
podAnnotations: {}
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Labels to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.
|
||||
podLabels: {}
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Common labels to add to the resources. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.
|
||||
commonLabels: {}
|
||||
|
||||
# @schema
|
||||
# required: false
|
||||
# @schema
|
||||
# Annotations to add to the deployment. See https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta.
|
||||
deployment:
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
annotations: {}
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Security context for the whole pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1.
|
||||
podSecurityContext: {}
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Security context for the Cerbos container. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1.
|
||||
securityContext: {}
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# properties:
|
||||
# limits:
|
||||
# type: object
|
||||
# requests:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Resource limits for the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#resources.
|
||||
resources:
|
||||
{}
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
# @schema
|
||||
# type: object
|
||||
# properties:
|
||||
# enabled:
|
||||
# type: boolean
|
||||
# default: false
|
||||
# minReplicas:
|
||||
# type: integer
|
||||
# default: 1
|
||||
# maxReplicas:
|
||||
# type: integer
|
||||
# default: 100
|
||||
# targetCPUUtilizationPercentage:
|
||||
# type: [integer, null]
|
||||
# default: 80
|
||||
# targetMemoryUtilizationPercentage:
|
||||
# type: [integer, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Autoscaling configuration.
|
||||
autoscaling:
|
||||
enabled: false
|
||||
minReplicas: 1
|
||||
maxReplicas: 100
|
||||
targetCPUUtilizationPercentage: 80
|
||||
# targetMemoryUtilizationPercentage: 80
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Node selector for the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.
|
||||
nodeSelector: {}
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Pod tolerations. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.
|
||||
tolerations: []
|
||||
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Pod affinity rules. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.
|
||||
affinity: {}
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Topology Spread Constraints rules. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling.
|
||||
topologySpreadConstraints:
|
||||
[] # @schema type:[array,null]
|
||||
# - topologyKey: topology.kubernetes.io/zone
|
||||
# maxSkew: 1
|
||||
# whenUnsatisfiable: ScheduleAnyway
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Volumes to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#volumes.
|
||||
volumes: []
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Volume mounts to add to the Cerbos container. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#volumes-1.
|
||||
volumeMounts: []
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# properties:
|
||||
# name:
|
||||
# type: string
|
||||
# value:
|
||||
# type: string
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Environment variables to add to the pod. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#environment-variables.
|
||||
env: [] # @schema type[array,null]
|
||||
|
||||
# @schema
|
||||
# type: [array, null]
|
||||
# items:
|
||||
# type: object
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Source environment variables from config maps or secrets. See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#environment-variables.
|
||||
envFrom: []
|
||||
|
||||
# @schema
|
||||
# type: object
|
||||
# properties:
|
||||
# certSpec:
|
||||
# type: [object, null]
|
||||
# @schema
|
||||
# Spec of the cert-manager certificate to create for the Cerbos deployment.
|
||||
# If certSpec is not empty, a cert-manager.io/v1/Certificate resource will be created with its spec populated with values from certSpec.
|
||||
# The certSpec value must be a valid Certificate spec. This Helm chart does not provide any defaults or inject any values into it.
|
||||
# If cerbos.tlsSecretName is defined, it takes precedence over the generated certificate.
|
||||
certManager:
|
||||
certSpec: {}
|
||||
|
||||
# @schema
|
||||
# enum: [deployment,daemonset]
|
||||
# default: deployment
|
||||
# @schema
|
||||
# Kubernetes workload type to use. Valid values are `deployment` or `daemonset`.
|
||||
type: deployment
|
||||
|
||||
# @schema
|
||||
# type: [string,null]
|
||||
# @schema
|
||||
# PriorityClassName to set on deployed pods
|
||||
priorityClassName: ""
|
||||
|
||||
# @schema
|
||||
# required: false
|
||||
# @schema
|
||||
# Cerbos service settings.
|
||||
service:
|
||||
# @schema
|
||||
# enum: [ClusterIP, NodePort, LoadBalancer]
|
||||
# default: ClusterIP
|
||||
# @schema
|
||||
# Service type
|
||||
type: ClusterIP
|
||||
# @schema
|
||||
# default: 3592
|
||||
# @schema
|
||||
# Service HTTP port
|
||||
httpPort: 3592
|
||||
# @schema
|
||||
# default: 3593
|
||||
# @schema
|
||||
# Service gRPC port
|
||||
grpcPort: 3593
|
||||
# @schema
|
||||
# default: 13592
|
||||
# @schema
|
||||
# HTTP node port (if service type is NodePort)
|
||||
httpNodePort: 13592
|
||||
# @schema
|
||||
# default: 13593
|
||||
# @schema
|
||||
# gRPC node port (if service type is NodePort)
|
||||
grpcNodePort: 13593
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Service annotations
|
||||
annotations: {}
|
||||
# @schema
|
||||
# type: [string, null]
|
||||
# @schema
|
||||
# Service Cluster IP
|
||||
clusterIP: null
|
||||
# @schema
|
||||
# type: [string, null]
|
||||
# @schema
|
||||
# LoadBalancer static IP
|
||||
loadBalancerIP: null
|
||||
# @schema
|
||||
# type: [string, null]
|
||||
# @schema
|
||||
# Set the internalTrafficPolicy. If this is unset and .Values.type is set to daemonset, this will default to "Local"
|
||||
internalTrafficPolicy: ""
|
||||
|
||||
# @schema
|
||||
# required: false
|
||||
# @schema
|
||||
# Cerbos deployment settings.
|
||||
cerbos:
|
||||
# Port to expose the http service on.
|
||||
httpPort: 3592
|
||||
# Port to expose the gRPC service on.
|
||||
grpcPort: 3593
|
||||
# @schema
|
||||
# type: [string, null]
|
||||
# @schema
|
||||
# Secret containing the TLS certificate.
|
||||
# Leave empty to disable TLS.
|
||||
# The secret must contain the following keys:
|
||||
# - tls.crt: Required. Certificate file contents.
|
||||
# - tls.key: Required. Private key for the certificate.
|
||||
# - ca.crt: Optional. CA certificate to add to the trust pool.
|
||||
tlsSecretName: ""
|
||||
# Cerbos log level. Valid values are DEBUG, INFO, WARN and ERROR
|
||||
logLevel: INFO
|
||||
# Add Prometheus service discovery annotations to the pod.
|
||||
prometheusPodAnnotationsEnabled: true
|
||||
# @schema
|
||||
# type: [object, null]
|
||||
# additionalProperties: true
|
||||
# @schema
|
||||
# Cerbos config file contents.
|
||||
# Some server settings like server.httpListenAddr, server.grpcListenAddr, server.tls will be overwritten by the chart based on values provided above.
|
||||
config: {}
|
|
@ -0,0 +1,14 @@
|
|||
# Contributing
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
For every change, please increment the `version` contained in
|
||||
[Chart.yaml](https://github.com/cockroachdb/helm-charts/blob/master/cockroachdb/Chart.yaml).
|
||||
The `version` roughly follows the [SEMVER](https://semver.org/) versioning
|
||||
pattern. For changes which do not affect backwards compatibility, the PATCH or
|
||||
MINOR version must be incremented, e.g. `4.1.3` -> `4.1.4`. For changes which
|
||||
affect the backwards compatibility of the chart, the major version must be
|
||||
incremented, e.g. `4.1.3` -> `5.0.0`. Examples of changes which affect backwards
|
||||
compatibility include any major version releases of CockroachDB, as well as any
|
||||
breaking changes to the CockroachDB chart templates.
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
annotations:
|
||||
catalog.cattle.io/certified: partner
|
||||
catalog.cattle.io/display-name: CockroachDB
|
||||
catalog.cattle.io/kube-version: '>=1.8-0'
|
||||
catalog.cattle.io/release-name: cockroachdb
|
||||
apiVersion: v1
|
||||
appVersion: 24.2.3
|
||||
description: CockroachDB is a scalable, survivable, strongly-consistent SQL database.
|
||||
home: https://www.cockroachlabs.com
|
||||
icon: file://assets/icons/cockroachdb.png
|
||||
kubeVersion: '>=1.8-0'
|
||||
maintainers:
|
||||
- email: helm-charts@cockroachlabs.com
|
||||
name: cockroachlabs
|
||||
name: cockroachdb
|
||||
sources:
|
||||
- https://github.com/cockroachdb/cockroach
|
||||
version: 14.0.4
|
|
@ -0,0 +1,589 @@
|
|||
<!--- Generated file, DO NOT EDIT. Source: build/templates/README.md --->
|
||||
# CockroachDB Helm Chart
|
||||
|
||||
[CockroachDB](https://github.com/cockroachdb/cockroach) - the open source, cloud-native distributed SQL database.
|
||||
|
||||
## Documentation
|
||||
|
||||
Below is a brief overview of operating the CockroachDB Helm Chart and some specific implementation details. For additional information on deploying CockroachDB, please see:
|
||||
> <https://www.cockroachlabs.com/docs/stable/orchestrate-cockroachdb-with-kubernetes.html>
|
||||
|
||||
Note that the documentation requires Helm 3.0 or higher.
|
||||
|
||||
## Prerequisites Details
|
||||
|
||||
* Kubernetes 1.8
|
||||
* PV support on the underlying infrastructure (only if using `storage.persistentVolume`). [Docker for windows hostpath provisioner is not supported](https://github.com/cockroachdb/docs/issues/3184).
|
||||
* If you want to secure your cluster to use TLS certificates for all network communication, [Helm must be installed with RBAC privileges](https://helm.sh/docs/topics/rbac/) or else you will get an "attempt to grant extra privileges" error.
|
||||
|
||||
## StatefulSet Details
|
||||
|
||||
* <http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/>
|
||||
|
||||
## StatefulSet Caveats
|
||||
|
||||
* <http://kubernetes.io/docs/concepts/abstractions/controllers/statefulsets/#limitations>
|
||||
|
||||
## Chart Details
|
||||
|
||||
This chart will do the following:
|
||||
|
||||
* Set up a dynamically scalable CockroachDB cluster using a Kubernetes StatefulSet.
|
||||
|
||||
## Add the CockroachDB Repository
|
||||
|
||||
```shell
|
||||
helm repo add cockroachdb https://charts.cockroachdb.com/
|
||||
```
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
To install the chart with the release name `my-release`:
|
||||
|
||||
```shell
|
||||
helm install my-release cockroachdb/cockroachdb
|
||||
```
|
||||
|
||||
Note that for a production cluster, you will likely want to override the following parameters in [`values.yaml`](values.yaml) with your own values.
|
||||
|
||||
- `statefulset.resources.requests.memory` and `statefulset.resources.limits.memory` allocate memory resources to CockroachDB pods in your cluster.
|
||||
- `conf.cache` and `conf.max-sql-memory` are memory limits that we recommend setting to 1/4 of the above resource allocation. When running CockroachDB, you must set these limits explicitly to avoid running out of memory.
|
||||
- `storage.persistentVolume.size` defaults to `100Gi` of disk space per pod, which you may increase or decrease for your use case.
|
||||
- `storage.persistentVolume.storageClass` uses the default storage class for your environment. We strongly recommend that you specify a storage class which uses an SSD.
|
||||
- `tls.enabled` must be set to `yes`/`true` to deploy in secure mode.
|
||||
|
||||
For more information on overriding the `values.yaml` parameters, please see:
|
||||
> <https://www.cockroachlabs.com/docs/stable/orchestrate-cockroachdb-with-kubernetes.html#step-2-start-cockroachdb>
|
||||
|
||||
Confirm that all pods are `Running` successfully and init has been completed:
|
||||
|
||||
```shell
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
my-release-cockroachdb-0 1/1 Running 0 1m
|
||||
my-release-cockroachdb-1 1/1 Running 0 1m
|
||||
my-release-cockroachdb-2 1/1 Running 0 1m
|
||||
my-release-cockroachdb-init-k6jcr 0/1 Completed 0 1m
|
||||
```
|
||||
|
||||
Confirm that persistent volumes are created and claimed for each pod:
|
||||
|
||||
```shell
|
||||
kubectl get pv
|
||||
```
|
||||
|
||||
```
|
||||
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
|
||||
pvc-64878ebf-f3f0-11e8-ab5b-42010a8e0035 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-0 standard 51s
|
||||
pvc-64945b4f-f3f0-11e8-ab5b-42010a8e0035 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-1 standard 51s
|
||||
pvc-649d920d-f3f0-11e8-ab5b-42010a8e0035 100Gi RWO Delete Bound default/datadir-my-release-cockroachdb-2 standard 51s
|
||||
```
|
||||
|
||||
### Running in secure mode
|
||||
|
||||
In order to set up a secure cockroachdb cluster set `tls.enabled` to `yes`/`true`
|
||||
|
||||
There are 3 ways to configure a secure cluster, with this chart. This all relates to how the certificates are issued:
|
||||
|
||||
* Self-signer (default)
|
||||
* Cert-manager
|
||||
* Manual
|
||||
|
||||
#### Self-signer
|
||||
|
||||
This is the default behaviour, and requires no configuration beyond setting certificate durations if user wants to set custom duration.
|
||||
|
||||
If you are running in this mode, self-signed certificates are created by self-signed utility for the nodes and root client and are stored in a secret.
|
||||
You can look for the certificates created:
|
||||
```shell
|
||||
kubectl get secrets
|
||||
```
|
||||
|
||||
```shell
|
||||
crdb-cockroachdb-ca-secret Opaque 2 23s
|
||||
crdb-cockroachdb-client-secret kubernetes.io/tls 3 22s
|
||||
crdb-cockroachdb-node-secret kubernetes.io/tls 3 23s
|
||||
```
|
||||
|
||||
|
||||
#### Manual
|
||||
|
||||
If you wish to supply the certificates to the nodes yourself set `tls.certs.provided` to `yes`/`true`. You may want to use this if you want to use a different certificate authority from the one being used by Kubernetes or if your Kubernetes cluster doesn't fully support certificate-signing requests. To use this, first set up your certificates and load them into your Kubernetes cluster as Secrets using the commands below:
|
||||
|
||||
```shell
|
||||
$ mkdir certs
|
||||
$ mkdir my-safe-directory
|
||||
$ cockroach cert create-ca --certs-dir=certs --ca-key=my-safe-directory/ca.key
|
||||
$ cockroach cert create-client root --certs-dir=certs --ca-key=my-safe-directory/ca.key
|
||||
$ kubectl create secret generic cockroachdb-root --from-file=certs
|
||||
secret/cockroachdb-root created
|
||||
$ cockroach cert create-node --certs-dir=certs --ca-key=my-safe-directory/ca.key localhost 127.0.0.1 my-release-cockroachdb-public my-release-cockroachdb-public.my-namespace my-release-cockroachdb-public.my-namespace.svc.cluster.local *.my-release-cockroachdb *.my-release-cockroachdb.my-namespace *.my-release-cockroachdb.my-namespace.svc.cluster.local
|
||||
$ kubectl create secret generic cockroachdb-node --from-file=certs
|
||||
secret/cockroachdb-node created
|
||||
```
|
||||
|
||||
> Note: The subject alternative names are based on a release called `my-release` in the `my-namespace` namespace. Make sure they match the services created with the release during `helm install`
|
||||
|
||||
If your certificates are stored in tls secrets such as secrets generated by cert-manager, the secret will contain files named:
|
||||
|
||||
* `ca.crt`
|
||||
* `tls.crt`
|
||||
* `tls.key`
|
||||
|
||||
Cockroachdb, however, expects the files to be named like this:
|
||||
|
||||
* `ca.crt`
|
||||
* `node.crt`
|
||||
* `node.key`
|
||||
* `client.root.crt`
|
||||
* `client.root.key`
|
||||
|
||||
By enabling `tls.certs.tlsSecret` the tls secrets are projected on to the correct filenames, when they are mounted to the cockroachdb pods.
|
||||
|
||||
#### Cert-manager
|
||||
|
||||
If you wish to supply certificates with [cert-manager][3], set
|
||||
|
||||
* `tls.certs.certManager` to `yes`/`true`
|
||||
* `tls.certs.certManagerIssuer` to an IssuerRef (as they appear in certificate resources) pointing to a clusterIssuer or issuer, you have set up in the cluster
|
||||
|
||||
Example issuer:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: cockroachdb-ca
|
||||
namespace: cockroachdb
|
||||
data:
|
||||
tls.crt: [BASE64 Encoded ca.crt]
|
||||
tls.key: [BASE64 Encoded ca.key]
|
||||
type: kubernetes.io/tls
|
||||
---
|
||||
apiVersion: cert-manager.io/v1alpha3
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: cockroachdb-cert-issuer
|
||||
namespace: cockroachdb
|
||||
spec:
|
||||
ca:
|
||||
secretName: cockroachdb-ca
|
||||
```
|
||||
|
||||
## Upgrading the cluster
|
||||
|
||||
### Chart version 3.0.0 and after
|
||||
|
||||
Launch a temporary interactive pod and start the built-in SQL client:
|
||||
|
||||
```shell
|
||||
kubectl run cockroachdb --rm -it \
|
||||
--image=cockroachdb/cockroach \
|
||||
--restart=Never \
|
||||
-- sql --insecure --host=my-release-cockroachdb-public
|
||||
```
|
||||
|
||||
> If you are running in secure mode, you will have to provide a client certificate to the cluster in order to authenticate, so the above command will not work. See [here](https://github.com/cockroachdb/cockroach/blob/master/cloud/kubernetes/client-secure.yaml) for an example of how to set up an interactive SQL shell against a secure cluster or [here](https://github.com/cockroachdb/cockroach/blob/master/cloud/kubernetes/example-app-secure.yaml) for an example application connecting to a secure cluster.
|
||||
|
||||
Set `cluster.preserve_downgrade_option`, where `$current_version` is the CockroachDB version currently running (e.g., `19.2`):
|
||||
|
||||
```sql
|
||||
> SET CLUSTER SETTING cluster.preserve_downgrade_option = '$current_version';
|
||||
```
|
||||
|
||||
Exit the shell and delete the temporary pod:
|
||||
|
||||
```sql
|
||||
> \q
|
||||
```
|
||||
|
||||
Kick off the upgrade process by changing the new Docker image, where `$new_version` is the CockroachDB version to which you are upgrading:
|
||||
|
||||
```shell
|
||||
helm upgrade my-release cockroachdb/cockroachdb \
|
||||
--set image.tag=$new_version \
|
||||
--reuse-values
|
||||
```
|
||||
|
||||
Kubernetes will carry out a safe [rolling upgrade](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets) of your CockroachDB nodes one-by-one. Monitor the cluster's pods until all have been successfully restarted:
|
||||
|
||||
```shell
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
my-release-cockroachdb-0 1/1 Running 0 2m
|
||||
my-release-cockroachdb-1 1/1 Running 0 3m
|
||||
my-release-cockroachdb-2 1/1 Running 0 3m
|
||||
my-release-cockroachdb-3 0/1 ContainerCreating 0 25s
|
||||
my-release-cockroachdb-init-nwjkh 0/1 ContainerCreating 0 6s
|
||||
```
|
||||
|
||||
```shell
|
||||
kubectl get pods \
|
||||
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].image}{"\n"}'
|
||||
```
|
||||
|
||||
```
|
||||
my-release-cockroachdb-0 cockroachdb/cockroach:v24.2.3
|
||||
my-release-cockroachdb-1 cockroachdb/cockroach:v24.2.3
|
||||
my-release-cockroachdb-2 cockroachdb/cockroach:v24.2.3
|
||||
my-release-cockroachdb-3 cockroachdb/cockroach:v24.2.3
|
||||
```
|
||||
|
||||
Resume normal operations. Once you are comfortable that the stability and performance of the cluster is what you'd expect post-upgrade, finalize the upgrade:
|
||||
|
||||
```shell
|
||||
kubectl run cockroachdb --rm -it \
|
||||
--image=cockroachdb/cockroach \
|
||||
--restart=Never \
|
||||
-- sql --insecure --host=my-release-cockroachdb-public
|
||||
```
|
||||
|
||||
```sql
|
||||
> RESET CLUSTER SETTING cluster.preserve_downgrade_option;
|
||||
> \q
|
||||
```
|
||||
|
||||
### Chart versions prior to 3.0.0
|
||||
|
||||
Due to a change in the label format in version 3.0.0 of this chart, upgrading requires that you delete the StatefulSet. Luckily there is a way to do it without actually deleting all the resources managed by the StatefulSet. Use the workaround below to upgrade from charts versions previous to 3.0.0:
|
||||
|
||||
Get the new labels from the specs rendered by Helm:
|
||||
|
||||
```shell
|
||||
helm template -f deploy.vals.yml cockroachdb/cockroachdb -x templates/statefulset.yaml \
|
||||
| yq r - spec.template.metadata.labels
|
||||
```
|
||||
|
||||
```
|
||||
app.kubernetes.io/name: cockroachdb
|
||||
app.kubernetes.io/instance: my-release
|
||||
app.kubernetes.io/component: cockroachdb
|
||||
```
|
||||
|
||||
Place the new labels on all pods of the StatefulSet (change `my-release-cockroachdb-0` to the name of each pod):
|
||||
|
||||
```shell
|
||||
kubectl label pods my-release-cockroachdb-0 \
|
||||
app.kubernetes.io/name=cockroachdb \
|
||||
app.kubernetes.io/instance=my-release \
|
||||
app.kubernetes.io/component=cockroachdb
|
||||
```
|
||||
|
||||
Delete the StatefulSet without deleting pods:
|
||||
|
||||
```shell
|
||||
kubectl delete statefulset my-release-cockroachdb --cascade=false
|
||||
```
|
||||
|
||||
Verify that no pod is deleted and then upgrade as normal. A new StatefulSet will be created, taking over the management of the existing pods and upgrading them if needed.
|
||||
|
||||
### See also
|
||||
|
||||
For more information about upgrading a cluster to the latest major release of CockroachDB, see [Upgrade to CockroachDB](https://www.cockroachlabs.com/docs/stable/upgrade-cockroach-version.html).
|
||||
|
||||
Note that there are sometimes backward-incompatible changes to SQL features between major CockroachDB releases. For details, see the [Upgrade Policy](https://www.cockroachlabs.com/docs/cockroachcloud/upgrade-policy).
|
||||
|
||||
## Configuration
|
||||
|
||||
The following table lists the configurable parameters of the CockroachDB chart and their default values.
|
||||
For details see the [`values.yaml`](values.yaml) file.
|
||||
|
||||
| Parameter | Description | Default |
|
||||
| --------- | ----------- | ------- |
|
||||
| `clusterDomain` | Cluster's default DNS domain | `cluster.local` |
|
||||
| `conf.attrs` | CockroachDB node attributes | `[]` |
|
||||
| `conf.cache` | Size of CockroachDB's in-memory cache | `25%` |
|
||||
| `conf.cluster-name` | Name of CockroachDB cluster | `""` |
|
||||
| `conf.disable-cluster-name-verification` | Disable CockroachDB cluster name verification | `no` |
|
||||
| `conf.join` | List of already-existing CockroachDB instances | `[]` |
|
||||
| `conf.max-disk-temp-storage` | Max storage capacity for temp data | `0` |
|
||||
| `conf.max-offset` | Max allowed clock offset for CockroachDB cluster | `500ms` |
|
||||
| `conf.max-sql-memory` | Max memory to use processing SQL querie | `25%` |
|
||||
| `conf.locality` | Locality attribute for this deployment | `""` |
|
||||
| `conf.single-node` | Disable CockroachDB clustering (standalone mode) | `no` |
|
||||
| `conf.sql-audit-dir` | Directory for SQL audit log | `""` |
|
||||
| `conf.port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.grpc.internal.port` instead | `""` |
|
||||
| `conf.http-port` | WARNING this parameter is deprecated and will be removed in future version. Use `service.ports.http.port` instead | `""` |
|
||||
| `conf.path` | CockroachDB data directory mount path | `cockroach-data` |
|
||||
| `conf.store.enabled` | Enable store configuration for CockroachDB | `false` |
|
||||
| `conf.store.type` | CockroachDB storage type | `""` |
|
||||
| `conf.store.size` | CockroachDB storage size | `""` |
|
||||
| `conf.store.attrs` | CockroachDB storage attributes | `""` |
|
||||
| `image.repository` | Container image name | `cockroachdb/cockroach` |
|
||||
| `image.tag` | Container image tag | `v24.2.3` |
|
||||
| `image.pullPolicy` | Container pull policy | `IfNotPresent` |
|
||||
| `image.credentials` | `registry`, `user` and `pass` credentials to pull private image | `{}` |
|
||||
| `statefulset.replicas` | StatefulSet replicas number | `3` |
|
||||
| `statefulset.updateStrategy` | Update strategy for StatefulSet Pods | `{"type": "RollingUpdate"}` |
|
||||
| `statefulset.podManagementPolicy` | `OrderedReady`/`Parallel` Pods creation/deletion order | `Parallel` |
|
||||
| `statefulset.budget.maxUnavailable` | k8s PodDisruptionBudget parameter | `1` |
|
||||
| `statefulset.args` | Extra command-line arguments | `[]` |
|
||||
| `statefulset.env` | Extra env vars | `[]` |
|
||||
| `statefulset.secretMounts` | Additional Secrets to mount at cluster members | `[]` |
|
||||
| `statefulset.labels` | Additional labels of StatefulSet and its Pods | `{"app.kubernetes.io/component": "cockroachdb"}` |
|
||||
| `statefulset.annotations` | Additional annotations of StatefulSet Pods | `{}` |
|
||||
| `statefulset.nodeAffinity` | [Node affinity rules][2] of StatefulSet Pods | `{}` |
|
||||
| `statefulset.podAffinity` | [Inter-Pod affinity rules][1] of StatefulSet Pods | `{}` |
|
||||
| `statefulset.podAntiAffinity` | [Anti-affinity rules][1] of StatefulSet Pods | auto |
|
||||
| `statefulset.podAntiAffinity.topologyKey` | The topologyKey for auto [anti-affinity rules][1] | `kubernetes.io/hostname` |
|
||||
| `statefulset.podAntiAffinity.type` | Type of auto [anti-affinity rules][1] | `soft` |
|
||||
| `statefulset.podAntiAffinity.weight` | Weight for `soft` auto [anti-affinity rules][1] | `100` |
|
||||
| `statefulset.nodeSelector` | Node labels for StatefulSet Pods assignment | `{}` |
|
||||
| `statefulset.priorityClassName` | [PriorityClassName][4] for StatefulSet Pods | `""` |
|
||||
| `statefulset.tolerations` | Node taints to tolerate by StatefulSet Pods | `[]` |
|
||||
| `statefulset.topologySpreadConstraints` | [Topology Spread Constraints rules][5] of StatefulSet Pods | auto |
|
||||
| `statefulset.topologySpreadConstraints.maxSkew` | Degree to which Pods may be unevenly distributed | `1` |
|
||||
| `statefulset.topologySpreadConstraints.topologyKey` | The key of node labels | `topology.kubernetes.io/zone` |
|
||||
| `statefulset.topologySpreadConstraints.whenUnsatisfiable` | `ScheduleAnyway`/`DoNotSchedule` for unsatisfiable constraints | `ScheduleAnyway` |
|
||||
| `statefulset.resources` | Resource requests and limits for StatefulSet Pods | `{}` |
|
||||
| `statefulset.customLivenessProbe` | Custom Liveness probe | `{}` |
|
||||
| `statefulset.customReadinessProbe` | Custom Rediness probe | `{}` |
|
||||
| `statefulset.customStartupProbe` | Custom Startup probe | `{}` |
|
||||
| `statefulset.terminationGracePeriodSeconds` | Termination grace period for CRDB statefulset pods | `300` |
|
||||
| `service.ports.grpc.external.port` | CockroachDB primary serving port in Services | `26257` |
|
||||
| `service.ports.grpc.external.name` | CockroachDB primary serving port name in Services | `grpc` |
|
||||
| `service.ports.grpc.internal.port` | CockroachDB inter-communication port in Pods and Services | `26257` |
|
||||
| `service.ports.grpc.internal.name` | CockroachDB inter-communication port name in Services | `grpc-internal` |
|
||||
| `service.ports.http.port` | CockroachDB HTTP port in Pods and Services | `8080` |
|
||||
| `service.ports.http.name` | CockroachDB HTTP port name in Services | `http` |
|
||||
| `service.public.type` | Public Service type | `ClusterIP` |
|
||||
| `service.public.labels` | Additional labels of public Service | `{"app.kubernetes.io/component": "cockroachdb"}` |
|
||||
| `service.public.annotations` | Additional annotations of public Service | `{}` |
|
||||
| `service.discovery.labels` | Additional labels of discovery Service | `{"app.kubernetes.io/component": "cockroachdb"}` |
|
||||
| `service.discovery.annotations` | Additional annotations of discovery Service | `{}` |
|
||||
| `ingress.enabled` | Enable ingress resource for CockroachDB | `false` |
|
||||
| `ingress.labels` | Additional labels of Ingress | `{}` |
|
||||
| `ingress.annotations` | Additional annotations of Ingress | `{}` |
|
||||
| `ingress.paths` | Paths for the default host | `[/]` |
|
||||
| `ingress.hosts` | CockroachDB Ingress hostnames | `[]` |
|
||||
| `ingress.tls[0].hosts` | CockroachDB Ingress tls hostnames | `nil` |
|
||||
| `ingress.tls[0].secretName` | CockroachDB Ingress tls secret name | `nil` |
|
||||
| `prometheus.enabled` | Enable automatic monitoring of all instances when Prometheus is running | `true` |
|
||||
| `serviceMonitor.enabled` | Create [ServiceMonitor](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/design.md#servicemonitor) Resource for scraping metrics using [PrometheusOperator](https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/getting-started.md#prometheus-operator) | `false` |
|
||||
| `serviceMonitor.labels` | Additional labels of ServiceMonitor | `{}` |
|
||||
| `serviceMonitor.annotations` | Additional annotations of ServiceMonitor | `{}` |
|
||||
| `serviceMonitor.interval` | ServiceMonitor scrape metrics interval | `10s` |
|
||||
| `serviceMonitor.scrapeTimeout` | ServiceMonitor scrape timeout | `nil` |
|
||||
| `serviceMonitor.tlsConfig` | Additional TLS configuration of ServiceMonitor | `{}` |
|
||||
| `serviceMonitor.namespaced` | Limit ServiceMonitor to current namespace | `false` |
|
||||
| `storage.hostPath` | Absolute path on host to store data | `""` |
|
||||
| `storage.persistentVolume.enabled` | Whether to use PersistentVolume to store data | `yes` |
|
||||
| `storage.persistentVolume.size` | PersistentVolume size | `100Gi` |
|
||||
| `storage.persistentVolume.storageClass` | PersistentVolume class | `""` |
|
||||
| `storage.persistentVolume.labels` | Additional labels of PersistentVolumeClaim | `{}` |
|
||||
| `storage.persistentVolume.annotations` | Additional annotations of PersistentVolumeClaim | `{}` |
|
||||
| `init.labels` | Additional labels of init Job and its Pod | `{"app.kubernetes.io/component": "init"}` |
|
||||
| `init.jobAnnotations` | Additional annotations of the init Job itself | `{}` |
|
||||
| `init.annotations` | Additional annotations of the Pod of init Job | `{}` |
|
||||
| `init.affinity` | [Affinity rules][2] of init Job Pod | `{}` |
|
||||
| `init.nodeSelector` | Node labels for init Job Pod assignment | `{}` |
|
||||
| `init.tolerations` | Node taints to tolerate by init Job Pod | `[]` |
|
||||
| `init.resources` | Resource requests and limits for the `cluster-init` container | `{}` |
|
||||
| `init.terminationGracePeriodSeconds` | Termination grace period for CRDB init job | `300` |
|
||||
| `tls.enabled` | Whether to run securely using TLS certificates | `no` |
|
||||
| `tls.serviceAccount.create` | Whether to create a new RBAC service account | `yes` |
|
||||
| `tls.serviceAccount.name` | Name of RBAC service account to use | `""` |
|
||||
| `tls.copyCerts.image` | Image used in copy certs init container | `busybox` |
|
||||
| `tls.copyCerts.resources` | Resource requests and limits for the `copy-certs` container | `{}` |
|
||||
| `tls.certs.provided` | Bring your own certs scenario, i.e certificates are provided | `no` |
|
||||
| `tls.certs.clientRootSecret` | If certs are provided, secret name for client root cert | `cockroachdb-root` |
|
||||
| `tls.certs.nodeSecret` | If certs are provided, secret name for node cert | `cockroachdb-node` |
|
||||
| `tls.certs.tlsSecret` | Own certs are stored in TLS secret | `no` |
|
||||
| `tls.certs.selfSigner.enabled` | Whether cockroachdb should generate its own self-signed certs | `true` |
|
||||
| `tls.certs.selfSigner.caProvided` | Bring your own CA scenario. This CA will be used to generate node and client cert | `false` |
|
||||
| `tls.certs.selfSigner.caSecret` | If CA is provided, secret name for CA cert | `""` |
|
||||
| `tls.certs.selfSigner.minimumCertDuration` | Minimum cert duration for all the certs, all certs duration will be validated against this duration | `624h` |
|
||||
| `tls.certs.selfSigner.caCertDuration` | Duration of CA cert in hour | `43824h` |
|
||||
| `tls.certs.selfSigner.caCertExpiryWindow` | Expiry window of CA cert means a window before actual expiry in which CA cert should be rotated | `648h` |
|
||||
| `tls.certs.selfSigner.clientCertDuration` | Duration of client cert in hour | `672h |
|
||||
| `tls.certs.selfSigner.clientCertExpiryWindow` | Expiry window of client cert means a window before actual expiry in which client cert should be rotated | `48h` |
|
||||
| `tls.certs.selfSigner.nodeCertDuration` | Duration of node cert in hour | `8760h` |
|
||||
| `tls.certs.selfSigner.nodeCertExpiryWindow` | Expiry window of node cert means a window before actual expiry in which node certs should be rotated | `168h` |
|
||||
| `tls.certs.selfSigner.rotateCerts` | Whether to rotate the certs generate by cockroachdb | `true` |
|
||||
| `tls.certs.selfSigner.readinessWait` | Wait time for each cockroachdb replica to become ready once it comes in running state. Only considered when rotateCerts is set to true | `30s` |
|
||||
| `tls.certs.selfSigner.podUpdateTimeout` | Wait time for each cockroachdb replica to get to running state. Only considered when rotateCerts is set to true | `2m` |
|
||||
| `tls.certs.certManager` | Provision certificates with cert-manager | `false` |
|
||||
| `tls.certs.certManagerIssuer.group` | IssuerRef group to use when generating certificates | `cert-manager.io` |
|
||||
| `tls.certs.certManagerIssuer.kind` | IssuerRef kind to use when generating certificates | `Issuer` |
|
||||
| `tls.certs.certManagerIssuer.name` | IssuerRef name to use when generating certificates | `cockroachdb` |
|
||||
| `tls.certs.certManagerIssuer.caCertDuration` | Duration of CA cert in hour | `43824h` |
|
||||
| `tls.certs.certManagerIssuer.caCertExpiryWindow` | Expiry window of CA cert means a window before actual expiry in which CA cert should be rotated | `648h` |
|
||||
| `tls.certs.certManagerIssuer.clientCertDuration` | Duration of client cert in hours | `672h` |
|
||||
| `tls.certs.certManagerIssuer.clientCertExpiryWindow` | Expiry window of client cert means a window before actual expiry in which client cert should be rotated | `48h` |
|
||||
| `tls.certs.certManagerIssuer.nodeCertDuration` | Duration of node cert in hours | `8760h` |
|
||||
| `tls.certs.certManagerIssuer.nodeCertExpiryWindow` | Expiry window of node certificates means a window before actual expiry in which node certs should be rotated. | `168h` |
|
||||
| `tls.selfSigner.image.repository` | Image to use for self signing TLS certificates | `cockroachlabs-helm-charts/cockroach-self-signer-cert`|
|
||||
| `tls.selfSigner.image.tag` | Image tag to use for self signing TLS certificates | `0.1` |
|
||||
| `tls.selfSigner.image.pullPolicy` | Self signing TLS certificates container pull policy | `IfNotPresent` |
|
||||
| `tls.selfSigner.image.credentials` | `registry`, `user` and `pass` credentials to pull private image | `{}` |
|
||||
| `networkPolicy.enabled` | Enable NetworkPolicy for CockroachDB's Pods | `no` |
|
||||
| `networkPolicy.ingress.grpc` | Whitelist resources to access gRPC port of CockroachDB's Pods | `[]` |
|
||||
| `networkPolicy.ingress.http` | Whitelist resources to access gRPC port of CockroachDB's Pods | `[]` |
|
||||
|
||||
|
||||
Override the default parameters using the `--set key=value[,key=value]` argument to `helm install`.
|
||||
|
||||
Alternatively, a YAML file that specifies custom values for the parameters can be provided while installing the chart. For example:
|
||||
|
||||
```shell
|
||||
helm install my-release -f my-values.yaml cockroachdb/cockroachdb
|
||||
```
|
||||
|
||||
> **Tip**: You can use the default [values.yaml](values.yaml)
|
||||
|
||||
## Deep dive
|
||||
|
||||
### Connecting to the CockroachDB cluster
|
||||
|
||||
Once you've created the cluster, you can start talking to it by connecting to its `-public` Service. CockroachDB is PostgreSQL wire protocol compatible, so there's a [wide variety of supported clients](https://www.cockroachlabs.com/docs/install-client-drivers.html). As an example, we'll open up a SQL shell using CockroachDB's built-in shell and play around with it a bit, like this (likely needing to replace `my-release-cockroachdb-public` with the name of the `-public` Service that was created with your installed chart):
|
||||
|
||||
```shell
|
||||
kubectl run cockroach-client --rm -it \
|
||||
--image=cockroachdb/cockroach \
|
||||
--restart=Never \
|
||||
-- sql --insecure --host my-release-cockroachdb-public
|
||||
```
|
||||
|
||||
```
|
||||
Waiting for pod default/cockroach-client to be running, status is Pending,
|
||||
pod ready: false
|
||||
If you don't see a command prompt, try pressing enter.
|
||||
root@my-release-cockroachdb-public:26257> SHOW DATABASES;
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| information_schema |
|
||||
| pg_catalog |
|
||||
| system |
|
||||
+--------------------+
|
||||
(3 rows)
|
||||
root@my-release-cockroachdb-public:26257> CREATE DATABASE bank;
|
||||
CREATE DATABASE
|
||||
root@my-release-cockroachdb-public:26257> CREATE TABLE bank.accounts (id INT
|
||||
PRIMARY KEY, balance DECIMAL);
|
||||
CREATE TABLE
|
||||
root@my-release-cockroachdb-public:26257> INSERT INTO bank.accounts VALUES
|
||||
(1234, 10000.50);
|
||||
INSERT 1
|
||||
root@my-release-cockroachdb-public:26257> SELECT * FROM bank.accounts;
|
||||
+------+---------+
|
||||
| id | balance |
|
||||
+------+---------+
|
||||
| 1234 | 10000.5 |
|
||||
+------+---------+
|
||||
(1 row)
|
||||
root@my-release-cockroachdb-public:26257> \q
|
||||
Waiting for pod default/cockroach-client to terminate, status is Running
|
||||
pod "cockroach-client" deleted
|
||||
```
|
||||
|
||||
> If you are running in secure mode, you will have to provide a client certificate to the cluster in order to authenticate, so the above command will not work. See [here](https://github.com/cockroachdb/cockroach/blob/master/cloud/kubernetes/client-secure.yaml) for an example of how to set up an interactive SQL shell against a secure cluster or [here](https://github.com/cockroachdb/cockroach/blob/master/cloud/kubernetes/example-app-secure.yaml) for an example application connecting to a secure cluster.
|
||||
|
||||
### Cluster health
|
||||
|
||||
Because our pod spec includes regular health checks of the CockroachDB processes, simply running `kubectl get pods` and looking at the `STATUS` column is sufficient to determine the health of each instance in the cluster.
|
||||
|
||||
If you want more detailed information about the cluster, the best place to look is the Admin UI.
|
||||
|
||||
### Accessing the Admin UI
|
||||
|
||||
If you want to see information about how the cluster is doing, you can try pulling up the CockroachDB Admin UI by port-forwarding from your local machine to one of the pods (replacing `my-release-cockroachdb-0` with the name of one of your pods:
|
||||
|
||||
```shell
|
||||
kubectl port-forward my-release-cockroachdb-0 8080
|
||||
```
|
||||
|
||||
You should then be able to access the Admin UI by visiting <http://localhost:8080/> in your web browser.
|
||||
|
||||
### Failover
|
||||
|
||||
If any CockroachDB member fails, it is restarted or recreated automatically by the Kubernetes infrastructure, and will re-join the cluster automatically when it comes back up. You can test this scenario by killing any of the CockroachDB pods:
|
||||
|
||||
```shell
|
||||
kubectl delete pod my-release-cockroachdb-1
|
||||
```
|
||||
|
||||
```shell
|
||||
kubectl get pods -l "app.kubernetes.io/instance=my-release,app.kubernetes.io/component=cockroachdb"
|
||||
```
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
my-release-cockroachdb-0 1/1 Running 0 5m
|
||||
my-release-cockroachdb-2 1/1 Running 0 5m
|
||||
```
|
||||
|
||||
After a while:
|
||||
|
||||
```shell
|
||||
kubectl get pods -l "app.kubernetes.io/instance=my-release,app.kubernetes.io/component=cockroachdb"
|
||||
```
|
||||
|
||||
```
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
my-release-cockroachdb-0 1/1 Running 0 5m
|
||||
my-release-cockroachdb-1 1/1 Running 0 20s
|
||||
my-release-cockroachdb-2 1/1 Running 0 5m
|
||||
```
|
||||
|
||||
You can check the state of re-joining from the new pod's logs:
|
||||
|
||||
```shell
|
||||
kubectl logs my-release-cockroachdb-1
|
||||
```
|
||||
|
||||
```
|
||||
[...]
|
||||
I161028 19:32:09.754026 1 server/node.go:586 [n1] node connected via gossip and
|
||||
verified as part of cluster {"35ecbc27-3f67-4e7d-9b8f-27c31aae17d6"}
|
||||
[...]
|
||||
cockroachdb-0.my-release-cockroachdb.default.svc.cluster.local:26257
|
||||
build: beta-20161027-55-gd2d3c7f @ 2016/10/28 19:27:25 (go1.7.3)
|
||||
admin: http://0.0.0.0:8080
|
||||
sql:
|
||||
postgresql://root@my-release-cockroachdb-1.my-release-cockroachdb.default.svc.cluster.local:26257?sslmode=disable
|
||||
logs: cockroach-data/logs
|
||||
store[0]: path=cockroach-data
|
||||
status: restarted pre-existing node
|
||||
clusterID: {35ecbc27-3f67-4e7d-9b8f-27c31aae17d6}
|
||||
nodeID: 2
|
||||
[...]
|
||||
```
|
||||
|
||||
### NetworkPolicy
|
||||
|
||||
To enable NetworkPolicy for CockroachDB, install [a networking plugin that implements the Kubernetes NetworkPolicy spec](https://kubernetes.io/docs/tasks/administer-cluster/declare-network-policy#before-you-begin), and set `networkPolicy.enabled` to `yes`/`true`.
|
||||
|
||||
For Kubernetes v1.5 & v1.6, you must also turn on NetworkPolicy by setting the `DefaultDeny` Namespace annotation. Note: this will enforce policy for _all_ pods in the Namespace:
|
||||
|
||||
```shell
|
||||
kubectl annotate namespace default "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"
|
||||
```
|
||||
|
||||
For more precise policy, set `networkPolicy.ingress.grpc` and `networkPolicy.ingress.http` rules. This will only allow pods that match the provided rules to connect to CockroachDB.
|
||||
|
||||
### Scaling
|
||||
|
||||
Scaling should be managed via the `helm upgrade` command. After resizing your cluster on your cloud environment (e.g., GKE or EKS), run the following command to add a pod. This assumes you scaled from 3 to 4 nodes:
|
||||
|
||||
```shell
|
||||
helm upgrade \
|
||||
my-release \
|
||||
cockroachdb/cockroachdb \
|
||||
--set statefulset.replicas=4 \
|
||||
--reuse-values
|
||||
```
|
||||
|
||||
Note, that if you are running in secure mode (`tls.enabled` is `yes`/`true`) and increase the size of your cluster, you will also have to approve the CSR (certificate-signing request) of each new node (using `kubectl get csr` and `kubectl certificate approve`).
|
||||
|
||||
[1]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity
|
||||
[2]: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity
|
||||
[3]: https://cert-manager.io/
|
||||
[4]: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
|
||||
[5]: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
|
|
@ -0,0 +1,9 @@
|
|||
# CockroachDB Chart
|
||||
|
||||
CockroachDB is a Distributed SQL database that runs natively in Kubernetes. It gives you resilient, horizontal scale across multiple clouds with always-on availability and data partitioned by location.
|
||||
|
||||
CockroachDB scales horizontally without reconfiguration or need for a massive architectural overhaul. Simply add a new node to the cluster and CockroachDB takes care of the underlying complexity.
|
||||
|
||||
- Scale by simply adding new nodes to a CockroachDB cluster
|
||||
- Automate balancing and distribution of ranges, not shards
|
||||
- Optimize server utilization evenly across all nodes
|
|
@ -0,0 +1,50 @@
|
|||
CockroachDB can be accessed via port {{ .Values.service.ports.grpc.external.port }} at the
|
||||
following DNS name from within your cluster:
|
||||
|
||||
{{ template "cockroachdb.fullname" . }}-public.{{ .Release.Namespace }}.svc.cluster.local
|
||||
|
||||
Because CockroachDB supports the PostgreSQL wire protocol, you can connect to
|
||||
the cluster using any available PostgreSQL client.
|
||||
|
||||
{{- if not .Values.tls.enabled }}
|
||||
|
||||
For example, you can open up a SQL shell to the cluster by running:
|
||||
|
||||
kubectl run -it --rm cockroach-client \
|
||||
--image=cockroachdb/cockroach \
|
||||
--restart=Never \
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
--labels="{{ template "cockroachdb.fullname" . }}-client=true" \
|
||||
{{- end }}
|
||||
--command -- \
|
||||
./cockroach sql --insecure --host={{ template "cockroachdb.fullname" . }}-public.{{ .Release.Namespace }}
|
||||
|
||||
From there, you can interact with the SQL shell as you would any other SQL
|
||||
shell, confident that any data you write will be safe and available even if
|
||||
parts of your cluster fail.
|
||||
{{- else }}
|
||||
|
||||
Note that because the cluster is running in secure mode, any client application
|
||||
that you attempt to connect will either need to have a valid client certificate
|
||||
or a valid username and password.
|
||||
{{- end }}
|
||||
|
||||
{{- if and (.Values.networkPolicy.enabled) (not (empty .Values.networkPolicy.ingress.grpc)) }}
|
||||
|
||||
Note: Since NetworkPolicy is enabled, the only Pods allowed to connect to this
|
||||
CockroachDB cluster are:
|
||||
|
||||
1. Having the label: "{{ template "cockroachdb.fullname" . }}-client=true"
|
||||
|
||||
2. Matching the following rules: {{- toYaml .Values.networkPolicy.ingress.grpc | nindent 0 }}
|
||||
{{- end }}
|
||||
|
||||
Finally, to open up the CockroachDB admin UI, you can port-forward from your
|
||||
local machine into one of the instances in the cluster:
|
||||
|
||||
kubectl port-forward -n {{ .Release.Namespace }} {{ template "cockroachdb.fullname" . }}-0 {{ index .Values.conf `http-port` | int64 }}
|
||||
|
||||
Then you can access the admin UI at http{{ if .Values.tls.enabled }}s{{ end }}://localhost:{{ index .Values.conf `http-port` | int64 }}/ in your web browser.
|
||||
|
||||
For more information on using CockroachDB, please see the project's docs at:
|
||||
https://www.cockroachlabs.com/docs/
|
|
@ -0,0 +1,291 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "cockroachdb.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 56 | 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 "cockroachdb.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 56 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 56 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name for cluster scope resource.
|
||||
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 with release namespace appended at the end.
|
||||
*/}}
|
||||
{{- define "cockroachdb.clusterfullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- printf "%s-%s" .Values.fullnameOverride .Release.Namespace | trunc 56 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- printf "%s-%s" .Release.Name .Release.Namespace | trunc 56 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s-%s" .Release.Name $name .Release.Namespace | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "cockroachdb.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the ServiceAccount to use.
|
||||
*/}}
|
||||
{{- define "cockroachdb.serviceAccount.name" -}}
|
||||
{{- if .Values.statefulset.serviceAccount.create -}}
|
||||
{{- default (include "cockroachdb.fullname" .) .Values.statefulset.serviceAccount.name -}}
|
||||
{{- else -}}
|
||||
{{- default "default" .Values.statefulset.serviceAccount.name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for NetworkPolicy.
|
||||
*/}}
|
||||
{{- define "cockroachdb.networkPolicy.apiVersion" -}}
|
||||
{{- if semverCompare ">=1.4-0, <=1.7-0" .Capabilities.KubeVersion.Version -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- else if semverCompare "^1.7-0" .Capabilities.KubeVersion.Version -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for StatefulSets
|
||||
*/}}
|
||||
{{- define "cockroachdb.statefulset.apiVersion" -}}
|
||||
{{- if semverCompare "<1.12-0" .Capabilities.KubeVersion.Version -}}
|
||||
{{- print "apps/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "apps/v1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return CockroachDB store expression
|
||||
*/}}
|
||||
{{- define "cockroachdb.conf.store" -}}
|
||||
{{- $isInMemory := eq (.Values.conf.store.type | toString) "mem" -}}
|
||||
{{- $persistentSize := empty .Values.conf.store.size | ternary .Values.storage.persistentVolume.size .Values.conf.store.size -}}
|
||||
|
||||
{{- $store := dict -}}
|
||||
{{- $_ := set $store "type" ($isInMemory | ternary "type=mem" "") -}}
|
||||
{{- $_ := set $store "path" ($isInMemory | ternary "" (print "path=" .Values.conf.path)) -}}
|
||||
{{- $_ := set $store "size" (print "size=" ($isInMemory | ternary .Values.conf.store.size $persistentSize)) -}}
|
||||
{{- $_ := set $store "attrs" (empty .Values.conf.store.attrs | ternary "" (print "attrs=" .Values.conf.store.attrs)) -}}
|
||||
|
||||
{{ compact (values $store) | join "," }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Define the default values for the certificate selfSigner inputs
|
||||
*/}}
|
||||
{{- define "selfcerts.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cockroachdb.fullname" .) "self-signer" | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "rotatecerts.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cockroachdb.fullname" .) "rotate-self-signer" | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "selfcerts.minimumCertDuration" -}}
|
||||
{{- if .Values.tls.certs.selfSigner.minimumCertDuration -}}
|
||||
{{- print (.Values.tls.certs.selfSigner.minimumCertDuration | trimSuffix "h") -}}
|
||||
{{- else }}
|
||||
{{- $minCertDuration := min (sub (.Values.tls.certs.selfSigner.clientCertDuration | trimSuffix "h" ) (.Values.tls.certs.selfSigner.clientCertExpiryWindow | trimSuffix "h")) (sub (.Values.tls.certs.selfSigner.nodeCertDuration | trimSuffix "h") (.Values.tls.certs.selfSigner.nodeCertExpiryWindow | trimSuffix "h")) -}}
|
||||
{{- print $minCertDuration -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Define the cron schedules for certificate rotate jobs and converting from hours to valid cron string.
|
||||
We assume that each month has 31 days, hence the cron job may run few days earlier in a year. In a cron schedule,
|
||||
we can not set a cron of more than a year, hence we try to run the cron in such a way that the cron run comes to
|
||||
as close possible to the expiry window. However, it is possible that cron may run earlier than the expiry window.
|
||||
*/}}
|
||||
{{- define "selfcerts.caRotateSchedule" -}}
|
||||
{{- $tempHours := sub (.Values.tls.certs.selfSigner.caCertDuration | trimSuffix "h") (.Values.tls.certs.selfSigner.caCertExpiryWindow | trimSuffix "h") -}}
|
||||
{{- $days := "*" -}}
|
||||
{{- $months := "*" -}}
|
||||
{{- $hours := mod $tempHours 24 -}}
|
||||
{{- if not (eq $hours $tempHours) -}}
|
||||
{{- $tempDays := div $tempHours 24 -}}
|
||||
{{- $days = mod $tempDays 31 -}}
|
||||
{{- if not (eq $days $tempDays) -}}
|
||||
{{- $days = add $days 1 -}}
|
||||
{{- $tempMonths := div $tempDays 31 -}}
|
||||
{{- $months = mod $tempMonths 12 -}}
|
||||
{{- if not (eq $months $tempMonths) -}}
|
||||
{{- $months = add $months 1 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if ne (toString $months) "*" -}}
|
||||
{{- $months = printf "*/%s" (toString $months) -}}
|
||||
{{- else -}}
|
||||
{{- if ne (toString $days) "*" -}}
|
||||
{{- $days = printf "*/%s" (toString $days) -}}
|
||||
{{- else -}}
|
||||
{{- if ne $hours 0 -}}
|
||||
{{- $hours = printf "*/%s" (toString $hours) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- printf "0 %s %s %s *" (toString $hours) (toString $days) (toString $months) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "selfcerts.clientRotateSchedule" -}}
|
||||
{{- $tempHours := int64 (include "selfcerts.minimumCertDuration" .) -}}
|
||||
{{- $days := "*" -}}
|
||||
{{- $months := "*" -}}
|
||||
{{- $hours := mod $tempHours 24 -}}
|
||||
{{- if not (eq $hours $tempHours) -}}
|
||||
{{- $tempDays := div $tempHours 24 -}}
|
||||
{{- $days = mod $tempDays 31 -}}
|
||||
{{- if not (eq $days $tempDays) -}}
|
||||
{{- $days = add $days 1 -}}
|
||||
{{- $tempMonths := div $tempDays 31 -}}
|
||||
{{- $months = mod $tempMonths 12 -}}
|
||||
{{- if not (eq $months $tempMonths) -}}
|
||||
{{- $months = add $months 1 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if ne (toString $months) "*" -}}
|
||||
{{- $months = printf "*/%s" (toString $months) -}}
|
||||
{{- else -}}
|
||||
{{- if ne (toString $days) "*" -}}
|
||||
{{- $days = printf "*/%s" (toString $days) -}}
|
||||
{{- else -}}
|
||||
{{- if ne $hours 0 -}}
|
||||
{{- $hours = printf "*/%s" (toString $hours) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- printf "0 %s %s %s *" (toString $hours) (toString $days) (toString $months) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Define the appropriate validations for the certificate selfSigner inputs
|
||||
*/}}
|
||||
|
||||
{{/*
|
||||
Validate that if caProvided is true, then the caSecret must not be empty and secret must be present in the namespace.
|
||||
*/}}
|
||||
{{- define "cockroachdb.tls.certs.selfSigner.caProvidedValidation" -}}
|
||||
{{- if .Values.tls.certs.selfSigner.caProvided -}}
|
||||
{{- if eq "" .Values.tls.certs.selfSigner.caSecret -}}
|
||||
{{ fail "CA secret can't be empty if caProvided is set to true" }}
|
||||
{{- else -}}
|
||||
{{- if not (lookup "v1" "Secret" .Release.Namespace .Values.tls.certs.selfSigner.caSecret) }}
|
||||
{{ fail "CA secret is not present in the release namespace" }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate that if caCertDuration or caCertExpiryWindow must not be empty and caCertExpiryWindow must be greater than
|
||||
minimumCertDuration.
|
||||
*/}}
|
||||
{{- define "cockroachdb.tls.certs.selfSigner.caCertValidation" -}}
|
||||
{{- if not .Values.tls.certs.selfSigner.caProvided -}}
|
||||
{{- if or (not .Values.tls.certs.selfSigner.caCertDuration) (not .Values.tls.certs.selfSigner.caCertExpiryWindow) }}
|
||||
{{ fail "CA cert duration or CA cert expiry window can not be empty" }}
|
||||
{{- else }}
|
||||
{{- if gt (int64 (include "selfcerts.minimumCertDuration" .)) (int64 (.Values.tls.certs.selfSigner.caCertExpiryWindow | trimSuffix "h")) -}}
|
||||
{{ fail "CA cert expiration window should not be less than minimum Cert duration" }}
|
||||
{{- end -}}
|
||||
{{- if gt (int64 (include "selfcerts.minimumCertDuration" .)) (sub (.Values.tls.certs.selfSigner.caCertDuration | trimSuffix "h") (.Values.tls.certs.selfSigner.caCertExpiryWindow | trimSuffix "h")) -}}
|
||||
{{ fail "CA cert Duration minus CA cert expiration window should not be less than minimum Cert duration" }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate that if clientCertDuration must not be empty and it must be greater than minimumCertDuration.
|
||||
*/}}
|
||||
{{- define "cockroachdb.tls.certs.selfSigner.clientCertValidation" -}}
|
||||
{{- if or (not .Values.tls.certs.selfSigner.clientCertDuration) (not .Values.tls.certs.selfSigner.clientCertExpiryWindow) }}
|
||||
{{ fail "Client cert duration can not be empty" }}
|
||||
{{- else }}
|
||||
{{- if lt (sub (.Values.tls.certs.selfSigner.clientCertDuration | trimSuffix "h") (.Values.tls.certs.selfSigner.clientCertExpiryWindow | trimSuffix "h")) (int64 (include "selfcerts.minimumCertDuration" .)) }}
|
||||
{{ fail "Client cert duration minus client cert expiry window should not be less than minimum Cert duration" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate that nodeCertDuration must not be empty and nodeCertDuration minus nodeCertExpiryWindow must be greater than minimumCertDuration.
|
||||
*/}}
|
||||
{{- define "cockroachdb.tls.certs.selfSigner.nodeCertValidation" -}}
|
||||
{{- if or (not .Values.tls.certs.selfSigner.nodeCertDuration) (not .Values.tls.certs.selfSigner.nodeCertExpiryWindow) }}
|
||||
{{ fail "Node cert duration can not be empty" }}
|
||||
{{- else }}
|
||||
{{- if lt (sub (.Values.tls.certs.selfSigner.nodeCertDuration | trimSuffix "h") (.Values.tls.certs.selfSigner.nodeCertExpiryWindow | trimSuffix "h")) (int64 (include "selfcerts.minimumCertDuration" .))}}
|
||||
{{ fail "Node cert duration minus node cert expiry window should not be less than minimum Cert duration" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate that if user enabled tls, then either self-signed certificates or certificate manager is enabled
|
||||
*/}}
|
||||
{{- define "cockroachdb.tlsValidation" -}}
|
||||
{{- if .Values.tls.enabled -}}
|
||||
{{- if and .Values.tls.certs.selfSigner.enabled .Values.tls.certs.certManager -}}
|
||||
{{ fail "Can not enable the self signed certificates and certificate manager at the same time" }}
|
||||
{{- end -}}
|
||||
{{- if and (not .Values.tls.certs.selfSigner.enabled) (not .Values.tls.certs.certManager) -}}
|
||||
{{- if not .Values.tls.certs.provided -}}
|
||||
{{ fail "You have to enable either self signed certificates or certificate manager, if you have enabled tls" }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{- define "cockroachdb.tls.certs.selfSigner.validation" -}}
|
||||
{{ include "cockroachdb.tls.certs.selfSigner.caProvidedValidation" . }}
|
||||
{{ include "cockroachdb.tls.certs.selfSigner.caCertValidation" . }}
|
||||
{{ include "cockroachdb.tls.certs.selfSigner.clientCertValidation" . }}
|
||||
{{ include "cockroachdb.tls.certs.selfSigner.nodeCertValidation" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "cockroachdb.securityContext.versionValidation" }}
|
||||
{{- /* Allow using `securityContext` for custom images. */}}
|
||||
{{- if ne "cockroachdb/cockroach" .Values.image.repository -}}
|
||||
{{ print true }}
|
||||
{{- else -}}
|
||||
{{- if semverCompare ">=22.1.2" .Values.image.tag -}}
|
||||
{{ print true }}
|
||||
{{- else -}}
|
||||
{{- if semverCompare ">=21.2.13, <22.1.0" .Values.image.tag -}}
|
||||
{{ print true }}
|
||||
{{- else -}}
|
||||
{{ print false }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,21 @@
|
|||
{{- if .Values.iap.enabled }}
|
||||
apiVersion: cloud.google.com/v1beta1
|
||||
kind: BackendConfig
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
iap:
|
||||
enabled: true
|
||||
oauthclientCredentials:
|
||||
secretName: {{ template "cockroachdb.fullname" . }}.iap
|
||||
timeoutSec: 120
|
||||
{{- end }}
|
|
@ -0,0 +1,33 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.certManager }}
|
||||
{{- if .Values.tls.certs.certManagerIssuer.isSelfSignedIssuer }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-ca-cert
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
duration: {{ .Values.tls.certs.certManagerIssuer.caCertDuration }}
|
||||
renewBefore: {{ .Values.tls.certs.certManagerIssuer.caCertExpiryWindow }}
|
||||
isCA: true
|
||||
secretName: {{ .Values.tls.certs.caSecret }}
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
commonName: root
|
||||
subject:
|
||||
organizations:
|
||||
- Cockroach
|
||||
issuerRef:
|
||||
name: {{ .Values.tls.certs.certManagerIssuer.name }}
|
||||
kind: {{ .Values.tls.certs.certManagerIssuer.kind }}
|
||||
group: {{ .Values.tls.certs.certManagerIssuer.group }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,40 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.certManager }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-root-client
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
duration: {{ .Values.tls.certs.certManagerIssuer.clientCertDuration }}
|
||||
renewBefore: {{ .Values.tls.certs.certManagerIssuer.clientCertExpiryWindow }}
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
privateKey:
|
||||
algorithm: RSA
|
||||
size: 2048
|
||||
commonName: root
|
||||
subject:
|
||||
organizations:
|
||||
- Cockroach
|
||||
secretName: {{ .Values.tls.certs.clientRootSecret }}
|
||||
issuerRef:
|
||||
{{- if .Values.tls.certs.certManagerIssuer.isSelfSignedIssuer }}
|
||||
name: {{ template "cockroachdb.fullname" . }}-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
{{- else }}
|
||||
name: {{ .Values.tls.certs.certManagerIssuer.name }}
|
||||
kind: {{ .Values.tls.certs.certManagerIssuer.kind }}
|
||||
group: {{ .Values.tls.certs.certManagerIssuer.group }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,20 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.certManager }}
|
||||
{{- if .Values.tls.certs.certManagerIssuer.isSelfSignedIssuer }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-ca-issuer
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ca:
|
||||
secretName: {{ .Values.tls.certs.caSecret }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,50 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.certManager }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-node
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
duration: {{ .Values.tls.certs.certManagerIssuer.nodeCertDuration }}
|
||||
renewBefore: {{ .Values.tls.certs.certManagerIssuer.nodeCertExpiryWindow }}
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- server auth
|
||||
- client auth
|
||||
privateKey:
|
||||
algorithm: RSA
|
||||
size: 2048
|
||||
commonName: node
|
||||
subject:
|
||||
organizations:
|
||||
- Cockroach
|
||||
dnsNames:
|
||||
- "localhost"
|
||||
- "127.0.0.1"
|
||||
- {{ printf "%s-public" (include "cockroachdb.fullname" .) | quote }}
|
||||
- {{ printf "%s-public.%s" (include "cockroachdb.fullname" .) .Release.Namespace | quote }}
|
||||
- {{ printf "%s-public.%s.svc.%s" (include "cockroachdb.fullname" .) .Release.Namespace .Values.clusterDomain | quote }}
|
||||
- {{ printf "*.%s" (include "cockroachdb.fullname" .) | quote }}
|
||||
- {{ printf "*.%s.%s" (include "cockroachdb.fullname" .) .Release.Namespace | quote }}
|
||||
- {{ printf "*.%s.%s.svc.%s" (include "cockroachdb.fullname" .) .Release.Namespace .Values.clusterDomain | quote }}
|
||||
secretName: {{ .Values.tls.certs.nodeSecret }}
|
||||
issuerRef:
|
||||
{{- if .Values.tls.certs.certManagerIssuer.isSelfSignedIssuer }}
|
||||
name: {{ template "cockroachdb.fullname" . }}-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
{{- else }}
|
||||
name: {{ .Values.tls.certs.certManagerIssuer.name }}
|
||||
kind: {{ .Values.tls.certs.certManagerIssuer.kind }}
|
||||
group: {{ .Values.tls.certs.certManagerIssuer.group }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,19 @@
|
|||
{{- if and .Values.tls.enabled (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager) }}
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.clusterfullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups: ["certificates.k8s.io"]
|
||||
resources: ["certificatesigningrequests"]
|
||||
verbs: ["create", "get", "watch"]
|
||||
{{- end }}
|
|
@ -0,0 +1,23 @@
|
|||
{{- if and .Values.tls.enabled (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager) }}
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.clusterfullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: {{ template "cockroachdb.clusterfullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
|
@ -0,0 +1,62 @@
|
|||
{{- if and .Values.tls.enabled (and .Values.tls.certs.selfSigner.enabled (not .Values.tls.certs.selfSigner.caProvided)) }}
|
||||
{{- if .Values.tls.certs.selfSigner.rotateCerts }}
|
||||
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}
|
||||
apiVersion: batch/v1
|
||||
{{- else }}
|
||||
apiVersion: batch/v1beta1
|
||||
{{- end }}
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
spec:
|
||||
schedule: {{ template "selfcerts.caRotateSchedule" . }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.tls.selfSigner.labels }}
|
||||
labels: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.annotations }}
|
||||
annotations: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
{{- with .Values.tls.selfSigner.affinity }}
|
||||
affinity: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: cert-rotate-job
|
||||
image: "{{ .Values.tls.selfSigner.image.registry }}/{{ .Values.tls.selfSigner.image.repository }}:{{ .Values.tls.selfSigner.image.tag }}"
|
||||
imagePullPolicy: "{{ .Values.tls.selfSigner.image.pullPolicy }}"
|
||||
args:
|
||||
- rotate
|
||||
- --ca
|
||||
- --ca-duration={{ .Values.tls.certs.selfSigner.caCertDuration }}
|
||||
- --ca-expiry={{ .Values.tls.certs.selfSigner.caCertExpiryWindow }}
|
||||
- --ca-cron={{ template "selfcerts.caRotateSchedule" . }}
|
||||
- --readiness-wait={{ .Values.tls.certs.selfSigner.readinessWait }}
|
||||
- --pod-update-timeout={{ .Values.tls.certs.selfSigner.podUpdateTimeout }}
|
||||
env:
|
||||
- name: STATEFULSET_NAME
|
||||
value: {{ template "cockroachdb.fullname" . }}
|
||||
- name: NAMESPACE
|
||||
value: {{ .Release.Namespace }}
|
||||
- name: CLUSTER_DOMAIN
|
||||
value: {{ .Values.clusterDomain}}
|
||||
serviceAccountName: {{ template "rotatecerts.fullname" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,69 @@
|
|||
{{- if and .Values.tls.certs.selfSigner.enabled .Values.tls.certs.selfSigner.rotateCerts }}
|
||||
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}
|
||||
apiVersion: batch/v1
|
||||
{{- else }}
|
||||
apiVersion: batch/v1beta1
|
||||
{{- end }}
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ template "rotatecerts.fullname" . }}-client
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
spec:
|
||||
schedule: {{ template "selfcerts.clientRotateSchedule" . }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.tls.selfSigner.labels }}
|
||||
labels: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.annotations }}
|
||||
annotations: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
{{- with .Values.tls.selfSigner.affinity }}
|
||||
affinity: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: cert-rotate-job
|
||||
image: "{{ .Values.tls.selfSigner.image.registry }}/{{ .Values.tls.selfSigner.image.repository }}:{{ .Values.tls.selfSigner.image.tag }}"
|
||||
imagePullPolicy: "{{ .Values.tls.selfSigner.image.pullPolicy }}"
|
||||
args:
|
||||
- rotate
|
||||
{{- if .Values.tls.certs.selfSigner.caProvided }}
|
||||
- --ca-secret={{ .Values.tls.certs.selfSigner.caSecret }}
|
||||
{{- else }}
|
||||
- --ca-duration={{ .Values.tls.certs.selfSigner.caCertDuration }}
|
||||
- --ca-expiry={{ .Values.tls.certs.selfSigner.caCertExpiryWindow }}
|
||||
{{- end }}
|
||||
- --client
|
||||
- --client-duration={{ .Values.tls.certs.selfSigner.clientCertDuration }}
|
||||
- --client-expiry={{ .Values.tls.certs.selfSigner.clientCertExpiryWindow }}
|
||||
- --node
|
||||
- --node-duration={{ .Values.tls.certs.selfSigner.nodeCertDuration }}
|
||||
- --node-expiry={{ .Values.tls.certs.selfSigner.nodeCertExpiryWindow }}
|
||||
- --node-client-cron={{ template "selfcerts.clientRotateSchedule" . }}
|
||||
- --readiness-wait={{ .Values.tls.certs.selfSigner.readinessWait }}
|
||||
- --pod-update-timeout={{ .Values.tls.certs.selfSigner.podUpdateTimeout }}
|
||||
env:
|
||||
- name: STATEFULSET_NAME
|
||||
value: {{ template "cockroachdb.fullname" . }}
|
||||
- name: NAMESPACE
|
||||
value: {{ .Release.Namespace }}
|
||||
- name: CLUSTER_DOMAIN
|
||||
value: {{ .Values.clusterDomain}}
|
||||
serviceAccountName: {{ template "rotatecerts.fullname" . }}
|
||||
{{- end}}
|
|
@ -0,0 +1,90 @@
|
|||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $paths := .Values.ingress.paths -}}
|
||||
{{- $ports := .Values.service.ports -}}
|
||||
{{- $fullName := include "cockroachdb.fullname" . -}}
|
||||
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
{{- else if $.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" }}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
{{- end }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
{{- if or .Values.ingress.annotations .Values.iap.enabled }}
|
||||
annotations:
|
||||
{{- range $key, $value := .Values.ingress.annotations }}
|
||||
{{ $key }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.iap.enabled }}
|
||||
kubernetes.io/ingress.class: "gce"
|
||||
kubernetes.io/ingress.allow-http: "false"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
name: {{ $fullName }}-ingress
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ $.Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ $.Release.Service | quote }}
|
||||
{{- if .Values.ingress.labels }}
|
||||
{{- toYaml .Values.ingress.labels | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
rules:
|
||||
{{- if .Values.ingress.hosts }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
- host: {{ $host }}
|
||||
http:
|
||||
paths:
|
||||
{{- range $path := $paths }}
|
||||
- path: {{ $path | quote }}
|
||||
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
|
||||
{{- if $.Values.iap.enabled }}
|
||||
pathType: ImplementationSpecific
|
||||
{{- else }}
|
||||
pathType: Prefix
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
|
||||
service:
|
||||
name: {{ $fullName }}-public
|
||||
port:
|
||||
name: {{ $ports.http.name | quote }}
|
||||
{{- else }}
|
||||
serviceName: {{ $fullName }}-public
|
||||
servicePort: {{ $ports.http.name | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- http:
|
||||
paths:
|
||||
{{- range $path := $paths }}
|
||||
- path: {{ $path | quote }}
|
||||
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
|
||||
{{- if $.Values.iap.enabled }}
|
||||
pathType: ImplementationSpecific
|
||||
{{- else }}
|
||||
pathType: Prefix
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
|
||||
service:
|
||||
name: {{ $fullName }}-public
|
||||
port:
|
||||
name: {{ $ports.http.name | quote }}
|
||||
{{- else }}
|
||||
serviceName: {{ $fullName }}-public
|
||||
servicePort: {{ $ports.http.name | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- toYaml .Values.ingress.tls | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,83 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
annotations:
|
||||
# This is what defines this resource as a hook. Without this line, the
|
||||
# job is considered part of the release.
|
||||
"helm.sh/hook": pre-install,pre-upgrade
|
||||
"helm.sh/hook-weight": "4"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.tls.selfSigner.labels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.annotations }}
|
||||
annotations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: "RuntimeDefault"
|
||||
runAsGroup: 1000
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
runAsNonRoot: true
|
||||
{{- end }}
|
||||
restartPolicy: Never
|
||||
{{- with .Values.tls.selfSigner.affinity }}
|
||||
affinity: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: cert-generate-job
|
||||
image: "{{ .Values.tls.selfSigner.image.registry }}/{{ .Values.tls.selfSigner.image.repository }}:{{ .Values.tls.selfSigner.image.tag }}"
|
||||
imagePullPolicy: "{{ .Values.tls.selfSigner.image.pullPolicy }}"
|
||||
args:
|
||||
- generate
|
||||
{{- if .Values.tls.certs.selfSigner.caProvided }}
|
||||
- --ca-secret={{ .Values.tls.certs.selfSigner.caSecret }}
|
||||
{{- else }}
|
||||
- --ca-duration={{ .Values.tls.certs.selfSigner.caCertDuration }}
|
||||
- --ca-expiry={{ .Values.tls.certs.selfSigner.caCertExpiryWindow }}
|
||||
{{- end }}
|
||||
- --client-duration={{ .Values.tls.certs.selfSigner.clientCertDuration }}
|
||||
- --client-expiry={{ .Values.tls.certs.selfSigner.clientCertExpiryWindow }}
|
||||
- --node-duration={{ .Values.tls.certs.selfSigner.nodeCertDuration }}
|
||||
- --node-expiry={{ .Values.tls.certs.selfSigner.nodeCertExpiryWindow }}
|
||||
env:
|
||||
- name: STATEFULSET_NAME
|
||||
value: {{ template "cockroachdb.fullname" . }}
|
||||
- name: NAMESPACE
|
||||
value: {{ .Release.Namespace | quote }}
|
||||
- name: CLUSTER_DOMAIN
|
||||
value: {{ .Values.clusterDomain}}
|
||||
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "selfcerts.fullname" . }}
|
||||
{{- end}}
|
|
@ -0,0 +1,70 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}-cleaner
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
annotations:
|
||||
# This is what defines this resource as a hook. Without this line, the
|
||||
# job is considered part of the release.
|
||||
"helm.sh/hook": pre-delete
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
template:
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}-cleaner
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.tls.selfSigner.labels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.annotations }}
|
||||
annotations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: "RuntimeDefault"
|
||||
runAsGroup: 1000
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
runAsNonRoot: true
|
||||
{{- end }}
|
||||
restartPolicy: Never
|
||||
{{- with .Values.tls.selfSigner.affinity }}
|
||||
affinity: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tls.selfSigner.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: cleaner
|
||||
image: "{{ .Values.tls.selfSigner.image.registry }}/{{ .Values.tls.selfSigner.image.repository }}:{{ .Values.tls.selfSigner.image.tag }}"
|
||||
imagePullPolicy: "{{ .Values.tls.selfSigner.image.pullPolicy }}"
|
||||
args:
|
||||
- cleanup
|
||||
- --namespace={{ .Release.Namespace }}
|
||||
env:
|
||||
- name: STATEFULSET_NAME
|
||||
value: {{ template "cockroachdb.fullname" . }}
|
||||
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "rotatecerts.fullname" . }}
|
||||
{{- end}}
|
|
@ -0,0 +1,303 @@
|
|||
{{ $isClusterInitEnabled := and (eq (len .Values.conf.join) 0) (not (index .Values.conf `single-node`)) }}
|
||||
{{ $isDatabaseProvisioningEnabled := .Values.init.provisioning.enabled }}
|
||||
{{- if or $isClusterInitEnabled $isDatabaseProvisioningEnabled }}
|
||||
{{ template "cockroachdb.tlsValidation" . }}
|
||||
kind: Job
|
||||
apiVersion: batch/v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-init
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.init.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
helm.sh/hook: post-install,post-upgrade
|
||||
helm.sh/hook-delete-policy: before-hook-creation
|
||||
{{- with .Values.init.jobAnnotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.init.labels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.init.annotations }}
|
||||
annotations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if eq (include "cockroachdb.securityContext.versionValidation" .) "true" }}
|
||||
{{- if and .Values.init.securityContext.enabled }}
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: "RuntimeDefault"
|
||||
runAsGroup: 1000
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
runAsNonRoot: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
restartPolicy: OnFailure
|
||||
terminationGracePeriodSeconds: {{ .Values.init.terminationGracePeriodSeconds }}
|
||||
{{- if or .Values.image.credentials (and .Values.tls.enabled .Values.tls.selfSigner.image.credentials (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager)) }}
|
||||
imagePullSecrets:
|
||||
{{- if .Values.image.credentials }}
|
||||
- name: {{ template "cockroachdb.fullname" . }}.db.registry
|
||||
{{- end }}
|
||||
{{- if and .Values.tls.enabled .Values.tls.selfSigner.image.credentials (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager) }}
|
||||
- name: {{ template "cockroachdb.fullname" . }}.self-signed-certs.registry
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
initContainers:
|
||||
- name: copy-certs
|
||||
image: {{ .Values.tls.copyCerts.image | quote }}
|
||||
imagePullPolicy: {{ .Values.tls.selfSigner.image.pullPolicy | quote }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- "cp -f /certs/* /cockroach-certs/; chmod 0400 /cockroach-certs/*.key"
|
||||
env:
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
{{- if and .Values.init.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: client-certs
|
||||
mountPath: /cockroach-certs/
|
||||
- name: certs-secret
|
||||
mountPath: /certs/
|
||||
{{- with .Values.tls.copyCerts.resources }}
|
||||
resources: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.init.affinity }}
|
||||
affinity: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.init.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.init.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: cluster-init
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
# Run the command in an `while true` loop because this Job is bound
|
||||
# to come up before the CockroachDB Pods (due to the time needed to
|
||||
# get PersistentVolumes attached to Nodes), and sleeping 5 seconds
|
||||
# between attempts is much better than letting the Pod fail when
|
||||
# the init command does and waiting out Kubernetes' non-configurable
|
||||
# exponential back-off for Pod restarts.
|
||||
# Command completes either when cluster initialization succeeds,
|
||||
# or when cluster has been initialized already.
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- >-
|
||||
{{- if $isClusterInitEnabled }}
|
||||
initCluster() {
|
||||
while true; do
|
||||
local output=$(
|
||||
set -x;
|
||||
|
||||
/cockroach/cockroach init \
|
||||
{{- if .Values.tls.enabled }}
|
||||
--certs-dir=/cockroach-certs/ \
|
||||
{{- else }}
|
||||
--insecure \
|
||||
{{- end }}
|
||||
{{- with index .Values.conf "cluster-name" }}
|
||||
--cluster-name={{.}} \
|
||||
{{- end }}
|
||||
--host={{ template "cockroachdb.fullname" . }}-0.{{ template "cockroachdb.fullname" . -}}
|
||||
:{{ .Values.service.ports.grpc.internal.port | int64 }} \
|
||||
{{- if .Values.init.pcr.enabled -}}
|
||||
{{- if .Values.init.pcr.isPrimary }}
|
||||
--virtualized \
|
||||
{{- else }}
|
||||
--virtualized-empty \
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
2>&1);
|
||||
|
||||
local exitCode="$?";
|
||||
echo $output;
|
||||
|
||||
if [[ "$output" =~ .*"Cluster successfully initialized".* || "$output" =~ .*"cluster has already been initialized".* ]]; then
|
||||
break;
|
||||
fi
|
||||
|
||||
echo "Cluster is not ready to be initialized, retrying in 5 seconds"
|
||||
sleep 5;
|
||||
done
|
||||
}
|
||||
|
||||
initCluster;
|
||||
{{- end }}
|
||||
|
||||
{{- if $isDatabaseProvisioningEnabled }}
|
||||
provisionCluster() {
|
||||
while true; do
|
||||
/cockroach/cockroach sql \
|
||||
{{- if .Values.tls.enabled }}
|
||||
--certs-dir=/cockroach-certs/ \
|
||||
{{- else }}
|
||||
--insecure \
|
||||
{{- end }}
|
||||
--host={{ template "cockroachdb.fullname" . }}-0.{{ template "cockroachdb.fullname" . -}}
|
||||
:{{ .Values.service.ports.grpc.internal.port | int64 }} \
|
||||
--execute="
|
||||
{{- range $clusterSetting, $clusterSettingValue := .Values.init.provisioning.clusterSettings }}
|
||||
SET CLUSTER SETTING {{ $clusterSetting }} = '${{ $clusterSetting | replace "." "_" }}_CLUSTER_SETTING';
|
||||
{{- end }}
|
||||
|
||||
{{- range $user := .Values.init.provisioning.users }}
|
||||
CREATE USER IF NOT EXISTS {{ $user.name }} WITH
|
||||
{{- if $user.password }}
|
||||
PASSWORD '${{ $user.name }}_PASSWORD'
|
||||
{{- else }}
|
||||
PASSWORD null
|
||||
{{- end }}
|
||||
{{ join " " $user.options }}
|
||||
;
|
||||
{{- end }}
|
||||
|
||||
{{- range $database := .Values.init.provisioning.databases }}
|
||||
CREATE DATABASE IF NOT EXISTS {{ $database.name }}
|
||||
{{- if $database.options }}
|
||||
{{ join " " $database.options }}
|
||||
{{- end }}
|
||||
;
|
||||
|
||||
{{- range $owner := $database.owners }}
|
||||
GRANT ALL ON DATABASE {{ $database.name }} TO {{ $owner }};
|
||||
{{- end }}
|
||||
|
||||
{{- range $owner := $database.owners_with_grant_option }}
|
||||
GRANT ALL ON DATABASE {{ $database.name }} TO {{ $owner }} WITH GRANT OPTION;
|
||||
{{- end }}
|
||||
|
||||
{{- if $database.backup }}
|
||||
CREATE SCHEDULE IF NOT EXISTS {{ $database.name }}_scheduled_backup
|
||||
FOR BACKUP DATABASE {{ $database.name }} INTO '{{ $database.backup.into }}'
|
||||
|
||||
{{- if $database.backup.options }}
|
||||
WITH {{ join "," $database.backup.options }}
|
||||
{{- end }}
|
||||
RECURRING '{{ $database.backup.recurring }}'
|
||||
{{- if $database.backup.fullBackup }}
|
||||
FULL BACKUP '{{ $database.backup.fullBackup }}'
|
||||
{{- else }}
|
||||
FULL BACKUP ALWAYS
|
||||
{{- end }}
|
||||
|
||||
{{- if and $database.backup.schedule $database.backup.schedule.options }}
|
||||
WITH SCHEDULE OPTIONS {{ join "," $database.backup.schedule.options }}
|
||||
{{- end }}
|
||||
;
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
"
|
||||
&>/dev/null;
|
||||
|
||||
local exitCode="$?";
|
||||
|
||||
if [[ "$exitCode" -eq "0" ]]
|
||||
then break;
|
||||
fi
|
||||
|
||||
sleep 5;
|
||||
done
|
||||
|
||||
echo "Provisioning completed successfully";
|
||||
}
|
||||
|
||||
provisionCluster;
|
||||
{{- end }}
|
||||
env:
|
||||
{{- $secretName := printf "%s-init" (include "cockroachdb.fullname" .) }}
|
||||
{{- range $user := .Values.init.provisioning.users }}
|
||||
{{- if $user.password }}
|
||||
- name: {{ $user.name }}_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $secretName }}
|
||||
key: {{ $user.name }}-password
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $clusterSetting, $clusterSettingValue := .Values.init.provisioning.clusterSettings }}
|
||||
{{- if $clusterSettingValue }}
|
||||
- name: {{ $clusterSetting | replace "." "_" }}_CLUSTER_SETTING
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $secretName }}
|
||||
key: {{ $clusterSetting | replace "." "-" }}-cluster-setting
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
volumeMounts:
|
||||
- name: client-certs
|
||||
mountPath: /cockroach-certs/
|
||||
{{- end }}
|
||||
{{- with .Values.init.resources }}
|
||||
resources: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.init.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
volumes:
|
||||
- name: client-certs
|
||||
emptyDir: {}
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager .Values.tls.certs.selfSigner.enabled }}
|
||||
- name: certs-secret
|
||||
{{- if or .Values.tls.certs.tlsSecret .Values.tls.certs.certManager .Values.tls.certs.selfSigner.enabled }}
|
||||
projected:
|
||||
sources:
|
||||
- secret:
|
||||
{{- if .Values.tls.certs.selfSigner.enabled }}
|
||||
name: {{ template "cockroachdb.fullname" . }}-client-secret
|
||||
{{ else }}
|
||||
name: {{ .Values.tls.certs.clientRootSecret }}
|
||||
{{ end -}}
|
||||
items:
|
||||
- key: ca.crt
|
||||
path: ca.crt
|
||||
mode: 0400
|
||||
- key: tls.crt
|
||||
path: client.root.crt
|
||||
mode: 0400
|
||||
- key: tls.key
|
||||
path: client.root.key
|
||||
mode: 0400
|
||||
{{- else }}
|
||||
secret:
|
||||
secretName: {{ .Values.tls.certs.clientRootSecret }}
|
||||
defaultMode: 0400
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,59 @@
|
|||
{{- if .Values.networkPolicy.enabled }}
|
||||
kind: NetworkPolicy
|
||||
apiVersion: {{ template "cockroachdb.networkPolicy.apiVersion" . }}
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
ingress:
|
||||
- ports:
|
||||
- port: grpc
|
||||
{{- with .Values.networkPolicy.ingress.grpc }}
|
||||
from:
|
||||
# Allow connections via custom rules.
|
||||
{{- toYaml . | nindent 8 }}
|
||||
# Allow client connection via pre-considered label.
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
{{ template "cockroachdb.fullname" . }}-client: "true"
|
||||
# Allow other CockroachDBs to connect to form a cluster.
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 14 }}
|
||||
{{- end }}
|
||||
{{- if gt (.Values.statefulset.replicas | int64) 1 }}
|
||||
# Allow init Job to connect to bootstrap a cluster.
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.init.labels }}
|
||||
{{- toYaml . | nindent 14 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
# Allow connections to admin UI and for Prometheus.
|
||||
- ports:
|
||||
- port: http
|
||||
{{- with .Values.networkPolicy.ingress.http }}
|
||||
from: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,26 @@
|
|||
kind: PodDisruptionBudget
|
||||
{{- if or (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) }}
|
||||
apiVersion: policy/v1
|
||||
{{- else }}
|
||||
apiVersion: policy/v1beta1
|
||||
{{- end }}
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-budget
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
maxUnavailable: {{ .Values.statefulset.budget.maxUnavailable | int64 }}
|
|
@ -0,0 +1,27 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["create", "get", "update", "delete"]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["statefulsets"]
|
||||
verbs: ["get"]
|
||||
resourceNames:
|
||||
- {{ template "cockroachdb.fullname" . }}
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["delete", "get"]
|
||||
{{- end }}
|
|
@ -0,0 +1,33 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
annotations:
|
||||
# This is what defines this resource as a hook. Without this line, the
|
||||
# job is considered part of the release.
|
||||
"helm.sh/hook": pre-install,pre-upgrade
|
||||
"helm.sh/hook-weight": "2"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["create", "get", "update", "delete"]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["statefulsets"]
|
||||
verbs: ["get"]
|
||||
resourceNames:
|
||||
- {{ template "cockroachdb.fullname" . }}
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["delete", "get"]
|
||||
{{- end }}
|
|
@ -0,0 +1,23 @@
|
|||
{{- if .Values.tls.enabled }}
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager }}
|
||||
verbs: ["get"]
|
||||
{{- else }}
|
||||
verbs: ["create", "get"]
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,23 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
|
@ -0,0 +1,29 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
annotations:
|
||||
# This is what defines this resource as a hook. Without this line, the
|
||||
# job is considered part of the release.
|
||||
"helm.sh/hook": pre-install,pre-upgrade
|
||||
"helm.sh/hook-weight": "3"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
|
@ -0,0 +1,23 @@
|
|||
{{- if .Values.tls.enabled }}
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
|
@ -0,0 +1,25 @@
|
|||
{{- if .Values.iap.enabled }}
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}.iap
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
type: Opaque
|
||||
data:
|
||||
{{- if eq "" .Values.iap.clientId }}
|
||||
{{ fail "iap.clientID can't be empty if iap.enabled is set to true" }}
|
||||
{{- end }}
|
||||
client_id: {{ .Values.iap.clientId | b64enc }}
|
||||
{{- if eq "" .Values.iap.clientSecret }}
|
||||
{{ fail "iap.clientSecret can't be empty if iap.enabled is set to true" }}
|
||||
{{- end }}
|
||||
client_secret: {{ .Values.iap.clientSecret | b64enc }}
|
||||
{{- end }}
|
|
@ -0,0 +1,19 @@
|
|||
{{- if .Values.conf.log.enabled }}
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-log-config
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
log-config.yaml: |
|
||||
{{- toYaml .Values.conf.log.config | nindent 4 }}
|
||||
{{- end }}
|
|
@ -0,0 +1,23 @@
|
|||
{{- range $name, $cred := dict "db" (.Values.image.credentials) "init-certs" (.Values.tls.selfSigner.image.credentials) }}
|
||||
{{- if not (empty $cred) }}
|
||||
{{- if or (and (eq $name "init-certs") $.Values.tls.enabled) (ne $name "init-certs") }}
|
||||
---
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" $ }}.{{ $name }}.registry
|
||||
namespace: {{ $.Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" $ }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" $ }}
|
||||
app.kubernetes.io/instance: {{ $.Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ $.Release.Service | quote }}
|
||||
{{- with $.Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
data:
|
||||
.dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` ($cred.registry | quote) (printf "%s:%s" $cred.username $cred.password | b64enc) | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,20 @@
|
|||
{{- if .Values.init.provisioning.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-init
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
|
||||
{{- range $user := .Values.init.provisioning.users }}
|
||||
{{- if $user.password }}
|
||||
{{ $user.name }}-password: {{ $user.password | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $clusterSetting, $clusterSettingValue := .Values.init.provisioning.clusterSettings }}
|
||||
{{ $clusterSetting | replace "." "-" }}-cluster-setting: {{ $clusterSettingValue | quote }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
|
@ -0,0 +1,64 @@
|
|||
# This service only exists to create DNS entries for each pod in
|
||||
# the StatefulSet such that they can resolve each other's IP addresses.
|
||||
# It does not create a load-balanced ClusterIP and should not be used directly
|
||||
# by clients in most circumstances.
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.service.discovery.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
# Use this annotation in addition to the actual field below because the
|
||||
# annotation will stop being respected soon, but the field is broken in
|
||||
# some versions of Kubernetes:
|
||||
# https://github.com/kubernetes/kubernetes/issues/58662
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
# Enable automatic monitoring of all instances when Prometheus is running
|
||||
# in the cluster.
|
||||
{{- if .Values.prometheus.enabled }}
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/path: _status/vars
|
||||
prometheus.io/port: {{ .Values.service.ports.http.port | quote }}
|
||||
{{- end }}
|
||||
{{- with .Values.service.discovery.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
clusterIP: None
|
||||
# We want all Pods in the StatefulSet to have their addresses published for
|
||||
# the sake of the other CockroachDB Pods even before they're ready, since they
|
||||
# have to be able to talk to each other in order to become ready.
|
||||
publishNotReadyAddresses: true
|
||||
ports:
|
||||
{{- $ports := .Values.service.ports }}
|
||||
# The main port, served by gRPC, serves Postgres-flavor SQL, inter-node
|
||||
# traffic and the CLI.
|
||||
- name: {{ $ports.grpc.external.name | quote }}
|
||||
port: {{ $ports.grpc.external.port | int64 }}
|
||||
targetPort: grpc
|
||||
{{- if ne ($ports.grpc.internal.port | int64) ($ports.grpc.external.port | int64) }}
|
||||
- name: {{ $ports.grpc.internal.name | quote }}
|
||||
port: {{ $ports.grpc.internal.port | int64 }}
|
||||
targetPort: grpc
|
||||
{{- end }}
|
||||
# The secondary port serves the UI as well as health and debug endpoints.
|
||||
- name: {{ $ports.http.name | quote }}
|
||||
port: {{ $ports.http.port | int64 }}
|
||||
targetPort: http
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
|
@ -0,0 +1,55 @@
|
|||
# This Service is meant to be used by clients of the database.
|
||||
# It exposes a ClusterIP that will automatically load balance connections
|
||||
# to the different database Pods.
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-public
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.service.public.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.service.public.annotations .Values.tls.enabled .Values.iap.enabled }}
|
||||
annotations:
|
||||
{{- with .Values.service.public.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
service.alpha.kubernetes.io/app-protocols: '{"http":"HTTPS"}'
|
||||
{{- end }}
|
||||
{{- if .Values.iap.enabled }}
|
||||
beta.cloud.google.com/backend-config: '{"default": "{{ template "cockroachdb.fullname" . }}"}'
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.service.public.type | quote }}
|
||||
ports:
|
||||
{{- $ports := .Values.service.ports }}
|
||||
# The main port, served by gRPC, serves Postgres-flavor SQL, inter-node
|
||||
# traffic and the CLI.
|
||||
- name: {{ $ports.grpc.external.name | quote }}
|
||||
port: {{ $ports.grpc.external.port | int64 }}
|
||||
targetPort: grpc
|
||||
{{- if ne ($ports.grpc.internal.port | int64) ($ports.grpc.external.port | int64) }}
|
||||
- name: {{ $ports.grpc.internal.name | quote }}
|
||||
port: {{ $ports.grpc.internal.port | int64 }}
|
||||
targetPort: grpc
|
||||
{{- end }}
|
||||
# The secondary port serves the UI as well as health and debug endpoints.
|
||||
- name: {{ $ports.http.name | quote }}
|
||||
port: {{ $ports.http.port | int64 }}
|
||||
targetPort: http
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
|
@ -0,0 +1,54 @@
|
|||
{{- $serviceMonitor := .Values.serviceMonitor -}}
|
||||
{{- $ports := .Values.service.ports -}}
|
||||
{{- if $serviceMonitor.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- if $serviceMonitor.labels }}
|
||||
{{- toYaml $serviceMonitor.labels | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $serviceMonitor.annotations }}
|
||||
annotations:
|
||||
{{- toYaml $serviceMonitor.annotations | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.service.discovery.labels }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
namespaceSelector:
|
||||
{{- if $serviceMonitor.namespaced }}
|
||||
matchNames:
|
||||
- {{ .Release.Namespace }}
|
||||
{{- else }}
|
||||
any: true
|
||||
{{- end }}
|
||||
endpoints:
|
||||
- port: {{ $ports.http.name | quote }}
|
||||
path: /_status/vars
|
||||
{{- if $serviceMonitor.interval }}
|
||||
interval: {{ $serviceMonitor.interval }}
|
||||
{{- end }}
|
||||
{{- if $serviceMonitor.scrapeTimeout }}
|
||||
scrapeTimeout: {{ $serviceMonitor.scrapeTimeout }}
|
||||
{{- end }}
|
||||
{{- if .Values.serviceMonitor.tlsConfig }}
|
||||
tlsConfig: {{ toYaml .Values.serviceMonitor.tlsConfig | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,22 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
{{ template "cockroachdb.tls.certs.selfSigner.validation" . }}
|
||||
kind: ServiceAccount
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "rotatecerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.certs.selfSigner.svcAccountAnnotations }}
|
||||
annotations:
|
||||
{{- with .Values.tls.certs.selfSigner.svcAccountAnnotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,25 @@
|
|||
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
|
||||
{{ template "cockroachdb.tls.certs.selfSigner.validation" . }}
|
||||
kind: ServiceAccount
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "selfcerts.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
annotations:
|
||||
# This is what defines this resource as a hook. Without this line, the
|
||||
# job is considered part of the release.
|
||||
"helm.sh/hook": pre-install,pre-upgrade
|
||||
"helm.sh/hook-weight": "1"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
|
||||
{{- with .Values.tls.certs.selfSigner.svcAccountAnnotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,21 @@
|
|||
{{- if .Values.statefulset.serviceAccount.create }}
|
||||
kind: ServiceAccount
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.statefulset.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- with .Values.statefulset.serviceAccount.annotations }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,422 @@
|
|||
kind: StatefulSet
|
||||
apiVersion: {{ template "cockroachdb.statefulset.apiVersion" . }}
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels:
|
||||
helm.sh/chart: {{ template "cockroachdb.chart" . }}
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
serviceName: {{ template "cockroachdb.fullname" . }}
|
||||
replicas: {{ .Values.statefulset.replicas | int64 }}
|
||||
updateStrategy: {{- toYaml .Values.statefulset.updateStrategy | nindent 4 }}
|
||||
podManagementPolicy: {{ .Values.statefulset.podManagementPolicy | quote }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.annotations }}
|
||||
annotations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if or .Values.image.credentials (and .Values.tls.enabled .Values.tls.selfSigner.image.credentials (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager)) }}
|
||||
imagePullSecrets:
|
||||
{{- if .Values.image.credentials }}
|
||||
- name: {{ template "cockroachdb.fullname" . }}.db.registry
|
||||
{{- end }}
|
||||
{{- if and .Values.tls.enabled .Values.tls.selfSigner.image.credentials (not .Values.tls.certs.provided) (not .Values.tls.certs.certManager) }}
|
||||
- name: {{ template "cockroachdb.fullname" . }}.self-signed-certs.registry
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "cockroachdb.serviceAccount.name" . }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
initContainers:
|
||||
- name: copy-certs
|
||||
image: {{ .Values.tls.copyCerts.image | quote }}
|
||||
imagePullPolicy: {{ .Values.tls.selfSigner.image.pullPolicy | quote }}
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- "cp -f /certs/* /cockroach-certs/; chmod 0400 /cockroach-certs/*.key"
|
||||
env:
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
{{- if .Values.statefulset.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
privileged: false
|
||||
readOnlyRootFilesystem: true
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: certs
|
||||
mountPath: /cockroach-certs/
|
||||
- name: certs-secret
|
||||
mountPath: /certs/
|
||||
{{- with .Values.tls.copyCerts.resources }}
|
||||
resources: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if or .Values.statefulset.nodeAffinity .Values.statefulset.podAffinity .Values.statefulset.podAntiAffinity }}
|
||||
affinity:
|
||||
{{- with .Values.statefulset.nodeAffinity }}
|
||||
nodeAffinity: {{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.podAffinity }}
|
||||
podAffinity: {{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.statefulset.podAntiAffinity }}
|
||||
podAntiAffinity:
|
||||
{{- if .Values.statefulset.podAntiAffinity.type }}
|
||||
{{- if eq .Values.statefulset.podAntiAffinity.type "hard" }}
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- topologyKey: {{ .Values.statefulset.podAntiAffinity.topologyKey }}
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 18 }}
|
||||
{{- end }}
|
||||
{{- else if eq .Values.statefulset.podAntiAffinity.type "soft" }}
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: {{ .Values.statefulset.podAntiAffinity.weight | int64 }}
|
||||
podAffinityTerm:
|
||||
topologyKey: {{ .Values.statefulset.podAntiAffinity.topologyKey }}
|
||||
labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 20 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- toYaml .Values.statefulset.podAntiAffinity | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.Version }}
|
||||
topologySpreadConstraints:
|
||||
- labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.statefulset.labels }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.topologySpreadConstraints }}
|
||||
maxSkew: {{ .maxSkew }}
|
||||
topologyKey: {{ .topologyKey }}
|
||||
whenUnsatisfiable: {{ .whenUnsatisfiable }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.nodeSelector }}
|
||||
nodeSelector: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.statefulset.priorityClassName }}
|
||||
priorityClassName: {{ .Values.statefulset.priorityClassName }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.tolerations }}
|
||||
tolerations: {{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
# No pre-stop hook is required, a SIGTERM plus some time is all that's
|
||||
# needed for graceful shutdown of a node.
|
||||
terminationGracePeriodSeconds: {{ .Values.init.terminationGracePeriodSeconds }}
|
||||
containers:
|
||||
- name: db
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
args:
|
||||
- shell
|
||||
- -ecx
|
||||
# The use of qualified `hostname -f` is crucial:
|
||||
# Other nodes aren't able to look up the unqualified hostname.
|
||||
#
|
||||
# `--join` CLI flag is hardcoded to exactly 3 Pods, because:
|
||||
# 1. Having `--join` value depending on `statefulset.replicas`
|
||||
# will trigger undesired restart of existing Pods when
|
||||
# StatefulSet is scaled up/down. We want to scale without
|
||||
# restarting existing Pods.
|
||||
# 2. At least one Pod in `--join` is enough to successfully
|
||||
# join CockroachDB cluster and gossip with all other existing
|
||||
# Pods, even if there are 3 or more Pods.
|
||||
# 3. It's harmless for `--join` to have 3 Pods even for 1-Pod
|
||||
# clusters, while it gives us opportunity to scale up even if
|
||||
# some Pods of existing cluster are down (for whatever reason).
|
||||
# See details explained here:
|
||||
# https://github.com/helm/charts/pull/18993#issuecomment-558795102
|
||||
- >-
|
||||
exec /cockroach/cockroach
|
||||
{{- if index .Values.conf `single-node` }}
|
||||
start-single-node
|
||||
{{- else }}
|
||||
start --join=
|
||||
{{- if .Values.conf.join }}
|
||||
{{- join `,` .Values.conf.join -}}
|
||||
{{- else }}
|
||||
{{- range $i, $_ := until 3 -}}
|
||||
{{- if gt $i 0 -}},{{- end -}}
|
||||
${STATEFULSET_NAME}-{{ $i }}.${STATEFULSET_FQDN}:{{ $.Values.service.ports.grpc.internal.port | int64 -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
{{- with index .Values.conf `cluster-name` }}
|
||||
--cluster-name={{ . }}
|
||||
{{- if index $.Values.conf `disable-cluster-name-verification` }}
|
||||
--disable-cluster-name-verification
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
--advertise-host=$(hostname).${STATEFULSET_FQDN}
|
||||
{{- if .Values.tls.enabled }}
|
||||
--certs-dir=/cockroach/cockroach-certs/
|
||||
{{- else }}
|
||||
--insecure
|
||||
{{- end }}
|
||||
{{- with .Values.conf.attrs }}
|
||||
--attrs={{ join `:` . }}
|
||||
{{- end }}
|
||||
{{- if index .Values.conf `http-port` }}
|
||||
--http-port={{ index .Values.conf `http-port` | int64 }}
|
||||
{{- else }}
|
||||
--http-port={{ index .Values.service.ports.http.port | int64 }}
|
||||
{{- end }}
|
||||
{{ if .Values.conf.port }}
|
||||
--port={{ .Values.conf.port | int64 }}
|
||||
{{- else }}
|
||||
--port={{ .Values.service.ports.grpc.internal.port | int64 }}
|
||||
{{- end }}
|
||||
--cache={{ .Values.conf.cache }}
|
||||
{{- with index .Values.conf `max-disk-temp-storage` }}
|
||||
--max-disk-temp-storage={{ . }}
|
||||
{{- end }}
|
||||
{{- with index .Values.conf `max-offset` }}
|
||||
--max-offset={{ . }}
|
||||
{{- end }}
|
||||
--max-sql-memory={{ index .Values.conf `max-sql-memory` }}
|
||||
{{- with .Values.conf.locality }}
|
||||
--locality={{ . }}
|
||||
{{- end }}
|
||||
{{- with index .Values.conf `sql-audit-dir` }}
|
||||
--sql-audit-dir={{ . }}
|
||||
{{- end }}
|
||||
{{- if .Values.conf.store.enabled }}
|
||||
--store={{ template "cockroachdb.conf.store" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.conf.log.enabled }}
|
||||
--log-config-file=/cockroach/log-config/log-config.yaml
|
||||
{{- else }}
|
||||
--logtostderr={{ .Values.conf.logtostderr }}
|
||||
{{- end }}
|
||||
{{- range .Values.statefulset.args }}
|
||||
{{ . }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: STATEFULSET_NAME
|
||||
value: {{ template "cockroachdb.fullname" . }}
|
||||
- name: STATEFULSET_FQDN
|
||||
value: {{ template "cockroachdb.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
|
||||
- name: COCKROACH_CHANNEL
|
||||
value: kubernetes-helm
|
||||
{{- with .Values.statefulset.env }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: grpc
|
||||
{{ if .Values.conf.port }}
|
||||
containerPort: {{ .Values.conf.port | int64 }}
|
||||
{{- else }}
|
||||
containerPort: {{ .Values.service.ports.grpc.internal.port | int64 }}
|
||||
{{- end }}
|
||||
protocol: TCP
|
||||
- name: http
|
||||
{{- if index .Values.conf `http-port` }}
|
||||
containerPort: {{ index .Values.conf `http-port` | int64 }}
|
||||
{{- else }}
|
||||
containerPort: {{ index .Values.service.ports.http.port | int64 }}
|
||||
{{- end }}
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
- name: datadir
|
||||
mountPath: /cockroach/{{ .Values.conf.path }}/
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: certs
|
||||
mountPath: /cockroach/cockroach-certs/
|
||||
{{- if .Values.tls.certs.provided }}
|
||||
- name: certs-secret
|
||||
mountPath: /cockroach/certs/
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range .Values.statefulset.secretMounts }}
|
||||
- name: {{ printf "secret-%s" . | quote }}
|
||||
mountPath: {{ printf "/etc/cockroach/secrets/%s" . | quote }}
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.conf.log.enabled }}
|
||||
- name: log-config
|
||||
mountPath: /cockroach/log-config
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.statefulset.customStartupProbe }}
|
||||
startupProbe:
|
||||
{{ toYaml .Values.statefulset.customStartupProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
livenessProbe:
|
||||
{{- if .Values.statefulset.customLivenessProbe }}
|
||||
{{ toYaml .Values.statefulset.customLivenessProbe | nindent 12 }}
|
||||
{{- else }}
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
{{- if .Values.tls.enabled }}
|
||||
scheme: HTTPS
|
||||
{{- end }}
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
{{- end }}
|
||||
readinessProbe:
|
||||
{{- if .Values.statefulset.customReadinessProbe }}
|
||||
{{ toYaml .Values.statefulset.customReadinessProbe | nindent 12 }}
|
||||
{{- else }}
|
||||
httpGet:
|
||||
path: /health?ready=1
|
||||
port: http
|
||||
{{- if .Values.tls.enabled }}
|
||||
scheme: HTTPS
|
||||
{{- end }}
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
failureThreshold: 2
|
||||
{{- end }}
|
||||
{{- if eq (include "cockroachdb.securityContext.versionValidation" .) "true" }}
|
||||
{{- if .Values.statefulset.securityContext.enabled }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
privileged: false
|
||||
readOnlyRootFilesystem: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.resources }}
|
||||
resources: {{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: datadir
|
||||
{{- if .Values.storage.persistentVolume.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: datadir
|
||||
{{- else if .Values.storage.hostPath }}
|
||||
hostPath:
|
||||
path: {{ .Values.storage.hostPath | quote }}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: certs
|
||||
emptyDir: {}
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager .Values.tls.certs.selfSigner.enabled }}
|
||||
- name: certs-secret
|
||||
{{- if or .Values.tls.certs.tlsSecret .Values.tls.certs.certManager .Values.tls.certs.selfSigner.enabled }}
|
||||
projected:
|
||||
sources:
|
||||
- secret:
|
||||
{{- if .Values.tls.certs.selfSigner.enabled }}
|
||||
name: {{ template "cockroachdb.fullname" . }}-node-secret
|
||||
{{ else }}
|
||||
name: {{ .Values.tls.certs.nodeSecret }}
|
||||
{{ end -}}
|
||||
items:
|
||||
- key: ca.crt
|
||||
path: ca.crt
|
||||
mode: 256
|
||||
- key: tls.crt
|
||||
path: node.crt
|
||||
mode: 256
|
||||
- key: tls.key
|
||||
path: node.key
|
||||
mode: 256
|
||||
{{- else }}
|
||||
secret:
|
||||
secretName: {{ .Values.tls.certs.nodeSecret }}
|
||||
defaultMode: 256
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range .Values.statefulset.secretMounts }}
|
||||
- name: {{ printf "secret-%s" . | quote }}
|
||||
secret:
|
||||
secretName: {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.conf.log.enabled }}
|
||||
- name: log-config
|
||||
secret:
|
||||
secretName: {{ template "cockroachdb.fullname" . }}-log-config
|
||||
{{- end }}
|
||||
{{- if eq (include "cockroachdb.securityContext.versionValidation" .) "true" }}
|
||||
{{- if and .Values.securityContext.enabled }}
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: "RuntimeDefault"
|
||||
fsGroup: 1000
|
||||
runAsGroup: 1000
|
||||
runAsUser: 1000
|
||||
runAsNonRoot: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.storage.persistentVolume.enabled }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: datadir
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ template "cockroachdb.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||
{{- with .Values.storage.persistentVolume.labels }}
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with .Values.labels }}
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with .Values.storage.persistentVolume.annotations }}
|
||||
annotations: {{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
{{- if .Values.storage.persistentVolume.storageClass }}
|
||||
{{- if (eq "-" .Values.storage.persistentVolume.storageClass) }}
|
||||
storageClassName: ""
|
||||
{{- else }}
|
||||
storageClassName: {{ .Values.storage.persistentVolume.storageClass | quote}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.storage.persistentVolume.size | quote }}
|
||||
{{- end }}
|
|
@ -0,0 +1,65 @@
|
|||
kind: Pod
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ template "cockroachdb.fullname" . }}-test
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
labels:
|
||||
{{ template "cockroachdb.fullname" . }}-client: "true"
|
||||
{{- end }}
|
||||
annotations:
|
||||
helm.sh/hook: test-success
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
{{- if .Values.image.credentials }}
|
||||
imagePullSecrets:
|
||||
- name: {{ template "cockroachdb.fullname" . }}.db.registry
|
||||
{{- end }}
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager }}
|
||||
volumes:
|
||||
- name: client-certs
|
||||
{{- if or .Values.tls.certs.tlsSecret .Values.tls.certs.certManager }}
|
||||
projected:
|
||||
sources:
|
||||
- secret:
|
||||
name: {{ .Values.tls.certs.clientRootSecret }}
|
||||
items:
|
||||
- key: ca.crt
|
||||
path: ca.crt
|
||||
mode: 0400
|
||||
- key: tls.crt
|
||||
path: client.root.crt
|
||||
mode: 0400
|
||||
- key: tls.key
|
||||
path: client.root.key
|
||||
mode: 0400
|
||||
{{- else }}
|
||||
secret:
|
||||
secretName: {{ .Values.tls.certs.clientRootSecret }}
|
||||
defaultMode: 0400
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: client-test
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager }}
|
||||
volumeMounts:
|
||||
- name: client-certs
|
||||
mountPath: /cockroach-certs
|
||||
{{- end }}
|
||||
command:
|
||||
- /cockroach/cockroach
|
||||
- sql
|
||||
{{- if or .Values.tls.certs.provided .Values.tls.certs.certManager }}
|
||||
- --certs-dir
|
||||
- /cockroach-certs
|
||||
{{- else }}
|
||||
- --insecure
|
||||
{{- end}}
|
||||
- --host
|
||||
- {{ template "cockroachdb.fullname" . }}-public.{{ .Release.Namespace }}
|
||||
- --port
|
||||
- {{ .Values.service.ports.grpc.external.port | quote }}
|
||||
- -e
|
||||
- SHOW DATABASES;
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"tls": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"certs": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"selfSigner": {
|
||||
"type": "object",
|
||||
"required": ["enabled", "caProvided"],
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"caProvided": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"if": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"const": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"if": {
|
||||
"properties": {
|
||||
"caProvided": {
|
||||
"const": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"caCertDuration" : {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
},
|
||||
"caCertExpiryWindow": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"clientCertDuration": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
},
|
||||
"clientCertExpiryWindow": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
},
|
||||
"nodeCertDuration": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
},
|
||||
"nodeCertExpiryWindow": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]*h$"
|
||||
},
|
||||
"rotateCerts": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"selfSigner": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"image": {
|
||||
"type": "object",
|
||||
"required": ["repository", "tag", "pullPolicy"],
|
||||
"properties": {
|
||||
"repository": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
},
|
||||
"pullPolicy": {
|
||||
"type": "string",
|
||||
"pattern": "^(Always|Never|IfNotPresent)$"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,618 @@
|
|||
# Generated file, DO NOT EDIT. Source: build/templates/values.yaml
|
||||
# Overrides the chart name against the label "app.kubernetes.io/name: " placed on every resource this chart creates.
|
||||
nameOverride: ""
|
||||
|
||||
# Override the resource names created by this chart which originally is generated using release and chart name.
|
||||
fullnameOverride: ""
|
||||
|
||||
image:
|
||||
repository: cockroachdb/cockroach
|
||||
tag: v24.2.3
|
||||
pullPolicy: IfNotPresent
|
||||
credentials: {}
|
||||
# registry: docker.io
|
||||
# username: john_doe
|
||||
# password: changeme
|
||||
|
||||
|
||||
# Additional labels to apply to all Kubernetes resources created by this chart.
|
||||
labels: {}
|
||||
# app.kubernetes.io/part-of: my-app
|
||||
|
||||
|
||||
# Cluster's default DNS domain.
|
||||
# You should overwrite it if you're using a different one,
|
||||
# otherwise CockroachDB nodes discovery won't work.
|
||||
clusterDomain: cluster.local
|
||||
|
||||
|
||||
conf:
|
||||
# An ordered list of CockroachDB node attributes.
|
||||
# Attributes are arbitrary strings specifying machine capabilities.
|
||||
# Machine capabilities might include specialized hardware or number of cores
|
||||
# (e.g. "gpu", "x16c").
|
||||
attrs: []
|
||||
# - x16c
|
||||
# - gpu
|
||||
|
||||
# Total size in bytes for caches, shared evenly if there are multiple
|
||||
# storage devices. Size suffixes are supported (e.g. `1GB` and `1GiB`).
|
||||
# A percentage of physical memory can also be specified (e.g. `.25`).
|
||||
cache: 25%
|
||||
|
||||
# Sets a name to verify the identity of a cluster.
|
||||
# The value must match between all nodes specified via `conf.join`.
|
||||
# This can be used as an additional verification when either the node or
|
||||
# cluster, or both, have not yet been initialized and do not yet know their
|
||||
# cluster ID.
|
||||
# To introduce a cluster name into an already-initialized cluster, pair this
|
||||
# option with `conf.disable-cluster-name-verification: yes`.
|
||||
cluster-name: ""
|
||||
|
||||
# Tell the server to ignore `conf.cluster-name` mismatches.
|
||||
# This is meant for use when opting an existing cluster into starting to use
|
||||
# cluster name verification, or when changing the cluster name.
|
||||
# The cluster should be restarted once with `conf.cluster-name` and
|
||||
# `conf.disable-cluster-name-verification: yes` combined, and once all nodes
|
||||
# have been updated to know the new cluster name, the cluster can be restarted
|
||||
# again with `conf.disable-cluster-name-verification: no`.
|
||||
# This option has no effect if `conf.cluster-name` is not specified.
|
||||
disable-cluster-name-verification: false
|
||||
|
||||
# The addresses for connecting a CockroachDB nodes to an existing cluster.
|
||||
# If you are deploying a second CockroachDB instance that should join a first
|
||||
# one, use the below list to join to the existing instance.
|
||||
# Each item in the array should be a FQDN (and port if needed) resolvable by
|
||||
# new Pods.
|
||||
join: []
|
||||
|
||||
# New logging configuration.
|
||||
log:
|
||||
enabled: false
|
||||
# https://www.cockroachlabs.com/docs/v21.1/configure-logs
|
||||
config: {}
|
||||
# file-defaults:
|
||||
# dir: /custom/dir/path/
|
||||
# fluent-defaults:
|
||||
# format: json-fluent
|
||||
# sinks:
|
||||
# stderr:
|
||||
# channels: [DEV]
|
||||
|
||||
# Logs at or above this threshold to STDERR. Ignored when "log" is enabled
|
||||
logtostderr: INFO
|
||||
|
||||
# Maximum storage capacity available to store temporary disk-based data for
|
||||
# SQL queries that exceed the memory budget (e.g. join, sorts, etc are
|
||||
# sometimes able to spill intermediate results to disk).
|
||||
# Accepts numbers interpreted as bytes, size suffixes (e.g. `32GB` and
|
||||
# `32GiB`) or a percentage of disk size (e.g. `10%`).
|
||||
# The location of the temporary files is within the first store dir.
|
||||
# If expressed as a percentage, `max-disk-temp-storage` is interpreted
|
||||
# relative to the size of the storage device on which the first store is
|
||||
# placed. The temp space usage is never counted towards any store usage
|
||||
# (although it does share the device with the first store) so, when
|
||||
# configuring this, make sure that the size of this temp storage plus the size
|
||||
# of the first store don't exceed the capacity of the storage device.
|
||||
# If the first store is an in-memory one (i.e. `type=mem`), then this
|
||||
# temporary "disk" data is also kept in-memory.
|
||||
# A percentage value is interpreted as a percentage of the available internal
|
||||
# memory.
|
||||
# max-disk-temp-storage: 0GB
|
||||
|
||||
# Maximum allowed clock offset for the cluster. If observed clock offsets
|
||||
# exceed this limit, servers will crash to minimize the likelihood of
|
||||
# reading inconsistent data. Increasing this value will increase the time
|
||||
# to recovery of failures as well as the frequency of uncertainty-based
|
||||
# read restarts.
|
||||
# Note, that this value must be the same on all nodes in the cluster.
|
||||
# In order to change it, all nodes in the cluster must be stopped
|
||||
# simultaneously and restarted with the new value.
|
||||
# max-offset: 500ms
|
||||
|
||||
# Maximum memory capacity available to store temporary data for SQL clients,
|
||||
# including prepared queries and intermediate data rows during query
|
||||
# execution. Accepts numbers interpreted as bytes, size suffixes
|
||||
# (e.g. `1GB` and `1GiB`) or a percentage of physical memory (e.g. `.25`).
|
||||
max-sql-memory: 25%
|
||||
|
||||
# An ordered, comma-separated list of key-value pairs that describe the
|
||||
# topography of the machine. Topography might include country, datacenter
|
||||
# or rack designations. Data is automatically replicated to maximize
|
||||
# diversities of each tier. The order of tiers is used to determine
|
||||
# the priority of the diversity, so the more inclusive localities like
|
||||
# country should come before less inclusive localities like datacenter.
|
||||
# The tiers and order must be the same on all nodes. Including more tiers
|
||||
# is better than including fewer. For example:
|
||||
# locality: country=us,region=us-west,datacenter=us-west-1b,rack=12
|
||||
# locality: country=ca,region=ca-east,datacenter=ca-east-2,rack=4
|
||||
# locality: planet=earth,province=manitoba,colo=secondary,power=3
|
||||
locality: ""
|
||||
|
||||
# Run CockroachDB instances in standalone mode with replication disabled
|
||||
# (replication factor = 1).
|
||||
# Enabling this option makes the following values to be ignored:
|
||||
# - `conf.cluster-name`
|
||||
# - `conf.disable-cluster-name-verification`
|
||||
# - `conf.join`
|
||||
#
|
||||
# WARNING: Enabling this option makes each deployed Pod as a STANDALONE
|
||||
# CockroachDB instance, so the StatefulSet does NOT FORM A CLUSTER.
|
||||
# Don't use this option for production deployments unless you clearly
|
||||
# understand what you're doing.
|
||||
# Usually, this option is intended to be used in conjunction with
|
||||
# `statefulset.replicas: 1` for temporary one-time deployments (like
|
||||
# running E2E tests, for example).
|
||||
single-node: false
|
||||
|
||||
# If non-empty, create a SQL audit log in the specified directory.
|
||||
sql-audit-dir: ""
|
||||
|
||||
# WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.grpc.internal.port` instead
|
||||
port: ""
|
||||
|
||||
# WARNING this parameter is deprecated and will be removed in a future version. Use `.service.ports.http.port` instead
|
||||
http-port: ""
|
||||
|
||||
# CockroachDB's data mount path.
|
||||
path: cockroach-data
|
||||
|
||||
# CockroachDB's storage configuration https://www.cockroachlabs.com/docs/v21.1/cockroach-start.html#storage
|
||||
# Uses --store flag
|
||||
store:
|
||||
enabled: false
|
||||
# Should be empty or 'mem'
|
||||
type:
|
||||
# Required for type=mem. If type and size is empty - storage.persistentVolume.size is used
|
||||
size:
|
||||
# Arbitrary strings, separated by colons, specifying disk type or capability
|
||||
attrs:
|
||||
|
||||
statefulset:
|
||||
replicas: 3
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
podManagementPolicy: Parallel
|
||||
budget:
|
||||
maxUnavailable: 1
|
||||
|
||||
# List of additional command-line arguments you want to pass to the
|
||||
# `cockroach start` command.
|
||||
args: []
|
||||
# - --disable-cluster-name-verification
|
||||
|
||||
# List of extra environment variables to pass into container
|
||||
env: []
|
||||
# - name: COCKROACH_ENGINE_MAX_SYNC_DURATION
|
||||
# value: "24h"
|
||||
|
||||
# List of Secrets names in the same Namespace as the CockroachDB cluster,
|
||||
# which shall be mounted into `/etc/cockroach/secrets/` for every cluster
|
||||
# member.
|
||||
secretMounts: []
|
||||
|
||||
# Additional labels to apply to this StatefulSet and all its Pods.
|
||||
labels:
|
||||
app.kubernetes.io/component: cockroachdb
|
||||
|
||||
# Additional annotations to apply to the Pods of this StatefulSet.
|
||||
annotations: {}
|
||||
|
||||
# Affinity rules for scheduling Pods of this StatefulSet on Nodes.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity
|
||||
nodeAffinity: {}
|
||||
# Inter-Pod Affinity rules for scheduling Pods of this StatefulSet.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity
|
||||
podAffinity: {}
|
||||
# Anti-affinity rules for scheduling Pods of this StatefulSet.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#inter-pod-affinity-and-anti-affinity
|
||||
# You may either toggle options below for default anti-affinity rules,
|
||||
# or specify the whole set of anti-affinity rules instead of them.
|
||||
podAntiAffinity:
|
||||
# The topologyKey to be used.
|
||||
# Can be used to spread across different nodes, AZs, regions etc.
|
||||
topologyKey: kubernetes.io/hostname
|
||||
# Type of anti-affinity rules: either `soft`, `hard` or empty value (which
|
||||
# disables anti-affinity rules).
|
||||
type: soft
|
||||
# Weight for `soft` anti-affinity rules.
|
||||
# Does not apply for other anti-affinity types.
|
||||
weight: 100
|
||||
|
||||
# Node selection constraints for scheduling Pods of this StatefulSet.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
|
||||
nodeSelector: {}
|
||||
|
||||
# PriorityClassName given to Pods of this StatefulSet
|
||||
# https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
|
||||
priorityClassName: ""
|
||||
|
||||
# Taints to be tolerated by Pods of this StatefulSet.
|
||||
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
|
||||
tolerations: []
|
||||
|
||||
# https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
|
||||
topologySpreadConstraints:
|
||||
maxSkew: 1
|
||||
topologyKey: topology.kubernetes.io/zone
|
||||
whenUnsatisfiable: ScheduleAnyway
|
||||
|
||||
# Uncomment the following resources definitions or pass them from
|
||||
# command line to control the CPU and memory resources allocated
|
||||
# by Pods of this StatefulSet.
|
||||
resources: {}
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 512Mi
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 512Mi
|
||||
|
||||
# terminationGracePeriodSeconds is the duration in seconds the Pod needs to terminate gracefully.
|
||||
terminationGracePeriodSeconds: 300
|
||||
|
||||
# Custom Liveness probe
|
||||
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request
|
||||
customLivenessProbe: {}
|
||||
# httpGet:
|
||||
# path: /health
|
||||
# port: http
|
||||
# scheme: HTTPS
|
||||
# initialDelaySeconds: 30
|
||||
# periodSeconds: 5
|
||||
|
||||
# Custom Rediness probe
|
||||
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes
|
||||
customReadinessProbe: {}
|
||||
# httpGet:
|
||||
# path: /health
|
||||
# port: http
|
||||
# scheme: HTTPS
|
||||
# initialDelaySeconds: 30
|
||||
# periodSeconds: 5
|
||||
|
||||
# Custom Startup Probe
|
||||
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes
|
||||
customStartupProbe: {}
|
||||
# httpGet:
|
||||
# path: /health
|
||||
# port: http
|
||||
# scheme: HTTPS
|
||||
# initialDelaySeconds: 30
|
||||
# periodSeconds: 5
|
||||
|
||||
securityContext:
|
||||
enabled: true
|
||||
|
||||
serviceAccount:
|
||||
# Specifies whether this ServiceAccount should be created.
|
||||
create: true
|
||||
# The name of this ServiceAccount to use.
|
||||
# If not set and `create` is `true`, then service account is auto-generated.
|
||||
# If not set and `create` is `false`, then it uses default service account.
|
||||
name: ""
|
||||
# Additional serviceAccount annotations (e.g. for attaching AWS IAM roles to pods)
|
||||
annotations: {}
|
||||
|
||||
service:
|
||||
ports:
|
||||
# You can set a different external and internal gRPC ports and their name.
|
||||
grpc:
|
||||
external:
|
||||
port: 26257
|
||||
name: grpc
|
||||
# If the port number is different than `external.port`, then it will be
|
||||
# named as `internal.name` in Service.
|
||||
internal:
|
||||
# CockroachDB's port to listen to inter-communications and client connections.
|
||||
port: 26257
|
||||
# If using Istio set it to `cockroach`.
|
||||
name: grpc-internal
|
||||
http:
|
||||
# CockroachDB's port to listen to HTTP requests.
|
||||
port: 8080
|
||||
name: http
|
||||
|
||||
# This Service is meant to be used by clients of the database.
|
||||
# It exposes a ClusterIP that will automatically load balance connections
|
||||
# to the different database Pods.
|
||||
public:
|
||||
type: ClusterIP
|
||||
# Additional labels to apply to this Service.
|
||||
labels:
|
||||
app.kubernetes.io/component: cockroachdb
|
||||
# Additional annotations to apply to this Service.
|
||||
annotations: {}
|
||||
|
||||
# This service only exists to create DNS entries for each pod in
|
||||
# the StatefulSet such that they can resolve each other's IP addresses.
|
||||
# It does not create a load-balanced ClusterIP and should not be used directly
|
||||
# by clients in most circumstances.
|
||||
discovery:
|
||||
# Additional labels to apply to this Service.
|
||||
labels:
|
||||
app.kubernetes.io/component: cockroachdb
|
||||
# Additional annotations to apply to this Service.
|
||||
annotations: {}
|
||||
|
||||
# CockroachDB's ingress for web ui.
|
||||
ingress:
|
||||
enabled: false
|
||||
labels: {}
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: nginx
|
||||
# cert-manager.io/cluster-issuer: letsencrypt
|
||||
paths: [/]
|
||||
hosts: []
|
||||
# - cockroachlabs.com
|
||||
tls: []
|
||||
# - hosts: [cockroachlabs.com]
|
||||
# secretName: cockroachlabs-tls
|
||||
|
||||
prometheus:
|
||||
enabled: true
|
||||
|
||||
securityContext:
|
||||
enabled: true
|
||||
|
||||
# CockroachDB's Prometheus operator ServiceMonitor support
|
||||
serviceMonitor:
|
||||
enabled: false
|
||||
labels: {}
|
||||
annotations: {}
|
||||
interval: 10s
|
||||
# scrapeTimeout: 10s
|
||||
# Limits the ServiceMonitor to the current namespace if set to `true`.
|
||||
namespaced: false
|
||||
|
||||
# tlsConfig: TLS configuration to use when scraping the endpoint.
|
||||
# Of type: https://github.com/coreos/prometheus-operator/blob/main/Documentation/api.md#tlsconfig
|
||||
tlsConfig: {}
|
||||
|
||||
# CockroachDB's data persistence.
|
||||
# If neither `persistentVolume` nor `hostPath` is used, then data will be
|
||||
# persisted in ad-hoc `emptyDir`.
|
||||
storage:
|
||||
# Absolute path on host to store CockroachDB's data.
|
||||
# If not specified, then `emptyDir` will be used instead.
|
||||
# If specified, but `persistentVolume.enabled` is `true`, then has no effect.
|
||||
hostPath: ""
|
||||
|
||||
# If `enabled` is `true` then a PersistentVolumeClaim will be created and
|
||||
# used to store CockroachDB's data, otherwise `hostPath` is used.
|
||||
persistentVolume:
|
||||
enabled: true
|
||||
|
||||
size: 100Gi
|
||||
|
||||
# If defined, then `storageClassName: <storageClass>`.
|
||||
# If set to "-", then `storageClassName: ""`, which disables dynamic
|
||||
# provisioning.
|
||||
# If undefined or empty (default), then no `storageClassName` spec is set,
|
||||
# so the default provisioner will be chosen (gp2 on AWS, standard on
|
||||
# GKE, AWS & OpenStack).
|
||||
storageClass: ""
|
||||
|
||||
# Additional labels to apply to the created PersistentVolumeClaims.
|
||||
labels: {}
|
||||
# Additional annotations to apply to the created PersistentVolumeClaims.
|
||||
annotations: {}
|
||||
|
||||
|
||||
# Kubernetes Job which initializes multi-node CockroachDB cluster.
|
||||
# It's not created if `statefulset.replicas` is `1`.
|
||||
init:
|
||||
# Additional labels to apply to this Job and its Pod.
|
||||
labels:
|
||||
app.kubernetes.io/component: init
|
||||
|
||||
# Additional annotations to apply to this Job.
|
||||
jobAnnotations: {}
|
||||
|
||||
# Additional annotations to apply to the Pod of this Job.
|
||||
annotations: {}
|
||||
|
||||
# Affinity rules for scheduling the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity
|
||||
affinity: {}
|
||||
|
||||
# Node selection constraints for scheduling the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
|
||||
nodeSelector: {}
|
||||
|
||||
# Taints to be tolerated by the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
|
||||
tolerations: []
|
||||
|
||||
# The init Pod runs at cluster creation to initialize CockroachDB. It finishes
|
||||
# quickly and doesn't continue to consume resources in the Kubernetes
|
||||
# cluster. Normally, you should leave this section commented out, but if your
|
||||
# Kubernetes cluster uses Resource Quotas and requires all pods to specify
|
||||
# resource requests or limits, you can set those here.
|
||||
resources: {}
|
||||
# requests:
|
||||
# cpu: "10m"
|
||||
# memory: "128Mi"
|
||||
# limits:
|
||||
# cpu: "10m"
|
||||
# memory: "128Mi"
|
||||
|
||||
# terminationGracePeriodSeconds is the duration in seconds the Pod needs to terminate gracefully.
|
||||
terminationGracePeriodSeconds: 300
|
||||
|
||||
securityContext:
|
||||
enabled: true
|
||||
|
||||
# Setup Physical Cluster Replication (PCR) between primary and standby cluster.
|
||||
# If isPrimary is set to true, the CockroachDB cluster created is the primary cluster.
|
||||
# If isPrimary is set to false, the CockroachDB cluster created is the standby cluster.
|
||||
pcr:
|
||||
enabled: false
|
||||
# isPrimary: true
|
||||
|
||||
provisioning:
|
||||
enabled: false
|
||||
# https://www.cockroachlabs.com/docs/stable/cluster-settings.html
|
||||
clusterSettings:
|
||||
# cluster.organization: "'FooCorp - Local Testing'"
|
||||
# enterprise.license: "'xxxxx'"
|
||||
users: []
|
||||
# - name:
|
||||
# password:
|
||||
# # https://www.cockroachlabs.com/docs/stable/create-user.html#parameters
|
||||
# options: [LOGIN]
|
||||
databases: []
|
||||
# - name:
|
||||
# # https://www.cockroachlabs.com/docs/stable/create-database.html#parameters
|
||||
# options: [encoding='utf-8']
|
||||
# owners: []
|
||||
# # https://www.cockroachlabs.com/docs/stable/grant.html#parameters
|
||||
# owners_with_grant_option: []
|
||||
# # Backup schedules are not idemponent for now and will fail on next run
|
||||
# # https://github.com/cockroachdb/cockroach/issues/57892
|
||||
# backup:
|
||||
# into: s3://
|
||||
# # Enterprise-only option (revision_history)
|
||||
# # https://www.cockroachlabs.com/docs/stable/create-schedule-for-backup.html#backup-options
|
||||
# options: [revision_history]
|
||||
# recurring: '@always'
|
||||
# # Enterprise-only feature. Remove this value to use `FULL BACKUP ALWAYS`
|
||||
# fullBackup: '@daily'
|
||||
# schedule:
|
||||
# # https://www.cockroachlabs.com/docs/stable/create-schedule-for-backup.html#schedule-options
|
||||
# options: [first_run = 'now']
|
||||
|
||||
|
||||
# Whether to run securely using TLS certificates.
|
||||
tls:
|
||||
enabled: true
|
||||
copyCerts:
|
||||
image: busybox
|
||||
certs:
|
||||
# Bring your own certs scenario. If provided, tls.init section will be ignored.
|
||||
provided: false
|
||||
# Secret name for the client root cert.
|
||||
clientRootSecret: cockroachdb-root
|
||||
# Secret name for node cert.
|
||||
nodeSecret: cockroachdb-node
|
||||
# Secret name for CA cert
|
||||
caSecret: cockroach-ca
|
||||
# Enable if the secret is a dedicated TLS.
|
||||
# TLS secrets are created by cert-mananger, for example.
|
||||
tlsSecret: false
|
||||
# Enable if the you want cockroach db to create its own certificates
|
||||
selfSigner:
|
||||
# If set, the cockroach db will generate its own certificates
|
||||
enabled: true
|
||||
# Run selfSigner as non-root
|
||||
securityContext:
|
||||
enabled: true
|
||||
# If set, the user should provide the CA certificate to sign other certificates.
|
||||
caProvided: false
|
||||
# It holds the name of the secret with caCerts. If caProvided is set, this can not be empty.
|
||||
caSecret: ""
|
||||
# Minimum Certificate duration for all the certificates, all certs duration will be validated against this.
|
||||
minimumCertDuration: 624h
|
||||
# Duration of CA certificates in hour
|
||||
caCertDuration: 43800h
|
||||
# Expiry window of CA certificates means a window before actual expiry in which CA certs should be rotated.
|
||||
caCertExpiryWindow: 648h
|
||||
# Duration of Client certificates in hour
|
||||
clientCertDuration: 672h
|
||||
# Expiry window of client certificates means a window before actual expiry in which client certs should be rotated.
|
||||
clientCertExpiryWindow: 48h
|
||||
# Duration of node certificates in hour
|
||||
nodeCertDuration: 8760h
|
||||
# Expiry window of node certificates means a window before actual expiry in which node certs should be rotated.
|
||||
nodeCertExpiryWindow: 168h
|
||||
# If set, the cockroachdb cert selfSigner will rotate the certificates before expiry.
|
||||
rotateCerts: true
|
||||
# Wait time for each cockroachdb replica to become ready once it comes in running state. Only considered when rotateCerts is set to true
|
||||
readinessWait: 30s
|
||||
# Wait time for each cockroachdb replica to get to running state. Only considered when rotateCerts is set to true
|
||||
podUpdateTimeout: 2m
|
||||
# ServiceAccount annotations for selfSigner jobs (e.g. for attaching AWS IAM roles to pods)
|
||||
svcAccountAnnotations: {}
|
||||
|
||||
# Use cert-manager to issue certificates for mTLS.
|
||||
certManager: false
|
||||
# Specify an Issuer or a ClusterIssuer to use, when issuing
|
||||
# node and client certificates. The values correspond to the
|
||||
# issuerRef specified in the certificate.
|
||||
certManagerIssuer:
|
||||
group: cert-manager.io
|
||||
kind: Issuer
|
||||
name: cockroachdb
|
||||
# Make it false when you are providing your own CA issuer
|
||||
isSelfSignedIssuer: true
|
||||
# Duration of CA certificates in hour
|
||||
caCertDuration: 43800h
|
||||
# Expiry window of CA certificates means a window before actual expiry in which CA certs should be rotated.
|
||||
caCertExpiryWindow: 648h
|
||||
# Duration of Client certificates in hours
|
||||
clientCertDuration: 672h
|
||||
# Expiry window of client certificates means a window before actual expiry in which client certs should be rotated.
|
||||
clientCertExpiryWindow: 48h
|
||||
# Duration of node certificates in hours
|
||||
nodeCertDuration: 8760h
|
||||
# Expiry window of node certificates means a window before actual expiry in which node certs should be rotated.
|
||||
nodeCertExpiryWindow: 168h
|
||||
|
||||
selfSigner:
|
||||
# Additional labels to apply to the Pod of this Job.
|
||||
labels: {}
|
||||
|
||||
# Additional annotations to apply to the Pod of this Job.
|
||||
annotations: {}
|
||||
|
||||
# Affinity rules for scheduling the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity
|
||||
affinity: {}
|
||||
|
||||
# Node selection constraints for scheduling the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
|
||||
nodeSelector: {}
|
||||
|
||||
# Taints to be tolerated by the Pod of this Job.
|
||||
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
|
||||
tolerations: []
|
||||
|
||||
# Image Placeholder for the selfSigner utility. This will be changed once the CI workflows for the image is in place.
|
||||
image:
|
||||
repository: cockroachlabs-helm-charts/cockroach-self-signer-cert
|
||||
tag: "1.5"
|
||||
pullPolicy: IfNotPresent
|
||||
credentials: {}
|
||||
registry: gcr.io
|
||||
# username: john_doe
|
||||
# password: changeme
|
||||
|
||||
networkPolicy:
|
||||
enabled: false
|
||||
|
||||
ingress:
|
||||
# List of sources which should be able to access the CockroachDB Pods via
|
||||
# gRPC port. Items in this list are combined using a logical OR operation.
|
||||
# Rules for allowing inter-communication are applied automatically.
|
||||
# If empty, then connections from any Pod is allowed.
|
||||
grpc: []
|
||||
# - podSelector:
|
||||
# matchLabels:
|
||||
# app.kubernetes.io/name: my-app-django
|
||||
# app.kubernetes.io/instance: my-app
|
||||
|
||||
# List of sources which should be able to access the CockroachDB Pods via
|
||||
# HTTP port. Items in this list are combined using a logical OR operation.
|
||||
# If empty, then connections from any Pod is allowed.
|
||||
http: []
|
||||
# - namespaceSelector:
|
||||
# matchLabels:
|
||||
# project: my-project
|
||||
|
||||
# To put the admin interface behind Identity Aware Proxy (IAP) on Google Cloud Platform
|
||||
# make sure to set ingress.paths: ['/*']
|
||||
iap:
|
||||
enabled: false
|
||||
# Create Google Cloud OAuth credentials and set client id and secret
|
||||
# clientId:
|
||||
# clientSecret:
|
|
@ -0,0 +1,3 @@
|
|||
tests/
|
||||
.ci/
|
||||
test-values/
|
|
@ -0,0 +1,28 @@
|
|||
annotations:
|
||||
artifacthub.io/changes: |
|
||||
- kind: security
|
||||
description: "updating cf-debugger"
|
||||
artifacthub.io/containsSecurityUpdates: "false"
|
||||
catalog.cattle.io/certified: partner
|
||||
catalog.cattle.io/display-name: Codefresh
|
||||
catalog.cattle.io/kube-version: '>=1.18-0'
|
||||
catalog.cattle.io/release-name: cf-runtime
|
||||
apiVersion: v2
|
||||
dependencies:
|
||||
- name: cf-common
|
||||
repository: file://./charts/cf-common
|
||||
version: 0.16.0
|
||||
description: A Helm chart for Codefresh Runner
|
||||
home: https://codefresh.io/
|
||||
icon: file://assets/icons/cf-runtime.png
|
||||
keywords:
|
||||
- codefresh
|
||||
- runner
|
||||
kubeVersion: '>=1.18-0'
|
||||
maintainers:
|
||||
- name: codefresh
|
||||
url: https://codefresh-io.github.io/
|
||||
name: cf-runtime
|
||||
sources:
|
||||
- https://github.com/codefresh-io/venona
|
||||
version: 6.4.2
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "-----"
|
||||
echo "API_HOST: ${API_HOST}"
|
||||
echo "AGENT_NAME: ${AGENT_NAME}"
|
||||
echo "RUNTIME_NAME: ${RUNTIME_NAME}"
|
||||
echo "AGENT: ${AGENT}"
|
||||
echo "AGENT_SECRET_NAME: ${AGENT_SECRET_NAME}"
|
||||
echo "DIND_SECRET_NAME: ${DIND_SECRET_NAME}"
|
||||
echo "-----"
|
||||
|
||||
auth() {
|
||||
codefresh auth create-context --api-key ${API_TOKEN} --url ${API_HOST}
|
||||
}
|
||||
|
||||
remove_runtime() {
|
||||
if [ "$AGENT" == "true" ]; then
|
||||
codefresh delete re ${RUNTIME_NAME} || true
|
||||
else
|
||||
codefresh delete sys-re ${RUNTIME_NAME} || true
|
||||
fi
|
||||
}
|
||||
|
||||
remove_agent() {
|
||||
codefresh delete agent ${AGENT_NAME} || true
|
||||
}
|
||||
|
||||
remove_secrets() {
|
||||
kubectl patch secret $(kubectl get secret -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge || true
|
||||
kubectl delete secret $AGENT_SECRET_NAME || true
|
||||
kubectl delete secret $DIND_SECRET_NAME || true
|
||||
}
|
||||
|
||||
auth
|
||||
remove_runtime
|
||||
remove_agent
|
||||
remove_secrets
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
#---
|
||||
fatal() {
|
||||
echo "ERROR: $1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg() { echo -e "\e[32mINFO ---> $1\e[0m"; }
|
||||
err() { echo -e "\e[31mERR ---> $1\e[0m" ; return 1; }
|
||||
|
||||
exit_trap () {
|
||||
local lc="$BASH_COMMAND" rc=$?
|
||||
if [ $rc != 0 ]; then
|
||||
if [[ -n "$SLEEP_ON_ERROR" ]]; then
|
||||
echo -e "\nSLEEP_ON_ERROR is set - Sleeping to fix error"
|
||||
sleep $SLEEP_ON_ERROR
|
||||
fi
|
||||
fi
|
||||
}
|
||||
trap exit_trap EXIT
|
||||
|
||||
usage() {
|
||||
echo "Usage:
|
||||
$0 [-n | --namespace] [--server-cert-cn] [--server-cert-extra-sans] codefresh-api-host codefresh-api-token
|
||||
|
||||
Example:
|
||||
$0 -n workflow https://g.codefresh.io 21341234.423141234.412431234
|
||||
|
||||
"
|
||||
}
|
||||
|
||||
# Args
|
||||
while [[ $1 =~ ^(-(n|h)|--(namespace|server-cert-cn|server-cert-extra-sans|help)) ]]
|
||||
do
|
||||
key=$1
|
||||
value=$2
|
||||
|
||||
case $key in
|
||||
-h|--help)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
-n|--namespace)
|
||||
NAMESPACE="$value"
|
||||
shift
|
||||
;;
|
||||
--server-cert-cn)
|
||||
SERVER_CERT_CN="$value"
|
||||
shift
|
||||
;;
|
||||
--server-cert-extra-sans)
|
||||
SERVER_CERT_EXTRA_SANS="$value"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
API_HOST=${1:-"$CF_API_HOST"}
|
||||
API_TOKEN=${2:-"$CF_API_TOKEN"}
|
||||
|
||||
[[ -z "$API_HOST" ]] && usage && fatal "Missing API_HOST"
|
||||
[[ -z "$API_TOKEN" ]] && usage && fatal "Missing token"
|
||||
|
||||
|
||||
API_SIGN_PATH=${API_SIGN_PATH:-"api/custom_clusters/signServerCerts"}
|
||||
|
||||
NAMESPACE=${NAMESPACE:-default}
|
||||
RELEASE=${RELEASE:-cf-runtime}
|
||||
|
||||
DIR=$(dirname $0)
|
||||
TMPDIR=/tmp/codefresh/
|
||||
|
||||
TMP_CERTS_FILE_ZIP=$TMPDIR/cf-certs.zip
|
||||
TMP_CERTS_HEADERS_FILE=$TMPDIR/cf-certs-response-headers.txt
|
||||
CERTS_DIR=$TMPDIR/ssl
|
||||
SRV_TLS_CA_CERT=${CERTS_DIR}/ca.pem
|
||||
SRV_TLS_KEY=${CERTS_DIR}/server-key.pem
|
||||
SRV_TLS_CSR=${CERTS_DIR}/server-cert.csr
|
||||
SRV_TLS_CERT=${CERTS_DIR}/server-cert.pem
|
||||
CF_SRV_TLS_CERT=${CERTS_DIR}/cf-server-cert.pem
|
||||
CF_SRV_TLS_CA_CERT=${CERTS_DIR}/cf-ca.pem
|
||||
mkdir -p $TMPDIR $CERTS_DIR
|
||||
|
||||
K8S_CERT_SECRET_NAME=codefresh-certs-server
|
||||
echo -e "\n------------------\nGenerating server tls certificates ... "
|
||||
|
||||
SERVER_CERT_CN=${SERVER_CERT_CN:-"docker.codefresh.io"}
|
||||
SERVER_CERT_EXTRA_SANS="${SERVER_CERT_EXTRA_SANS}"
|
||||
###
|
||||
|
||||
openssl genrsa -out $SRV_TLS_KEY 4096 || fatal "Failed to generate openssl key "
|
||||
openssl req -subj "/CN=${SERVER_CERT_CN}" -new -key $SRV_TLS_KEY -out $SRV_TLS_CSR || fatal "Failed to generate openssl csr "
|
||||
GENERATE_CERTS=true
|
||||
CSR=$(sed ':a;N;$!ba;s/\n/\\n/g' ${SRV_TLS_CSR})
|
||||
|
||||
SERVER_CERT_SANS="IP:127.0.0.1,DNS:dind,DNS:*.dind.${NAMESPACE},DNS:*.dind.${NAMESPACE}.svc${KUBE_DOMAIN},DNS:*.cf-cd.com,DNS:*.codefresh.io"
|
||||
if [[ -n "${SERVER_CERT_EXTRA_SANS}" ]]; then
|
||||
SERVER_CERT_SANS=${SERVER_CERT_SANS},${SERVER_CERT_EXTRA_SANS}
|
||||
fi
|
||||
echo "{\"reqSubjectAltName\": \"${SERVER_CERT_SANS}\", \"csr\": \"${CSR}\" }" > ${TMPDIR}/sign_req.json
|
||||
|
||||
rm -fv ${TMP_CERTS_HEADERS_FILE} ${TMP_CERTS_FILE_ZIP}
|
||||
|
||||
SIGN_STATUS=$(curl -k -sSL -d @${TMPDIR}/sign_req.json -H "Content-Type: application/json" -H "Authorization: ${API_TOKEN}" -H "Expect: " \
|
||||
-o ${TMP_CERTS_FILE_ZIP} -D ${TMP_CERTS_HEADERS_FILE} -w '%{http_code}' ${API_HOST}/${API_SIGN_PATH} )
|
||||
|
||||
echo "Sign request completed with HTTP_STATUS_CODE=$SIGN_STATUS"
|
||||
if [[ $SIGN_STATUS != 200 ]]; then
|
||||
echo "ERROR: Cannot sign certificates"
|
||||
if [[ -f ${TMP_CERTS_FILE_ZIP} ]]; then
|
||||
mv ${TMP_CERTS_FILE_ZIP} ${TMP_CERTS_FILE_ZIP}.error
|
||||
cat ${TMP_CERTS_FILE_ZIP}.error
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
unzip -o -d ${CERTS_DIR}/ ${TMP_CERTS_FILE_ZIP} || fatal "Failed to unzip certificates to ${CERTS_DIR} "
|
||||
cp -v ${CF_SRV_TLS_CA_CERT} $SRV_TLS_CA_CERT || fatal "received ${TMP_CERTS_FILE_ZIP} does not contains ca.pem"
|
||||
cp -v ${CF_SRV_TLS_CERT} $SRV_TLS_CERT || fatal "received ${TMP_CERTS_FILE_ZIP} does not contains cf-server-cert.pem"
|
||||
|
||||
|
||||
echo -e "\n------------------\nCreating certificate secret "
|
||||
|
||||
kubectl -n $NAMESPACE create secret generic $K8S_CERT_SECRET_NAME \
|
||||
--from-file=$SRV_TLS_CA_CERT \
|
||||
--from-file=$SRV_TLS_KEY \
|
||||
--from-file=$SRV_TLS_CERT \
|
||||
--dry-run=client -o yaml | kubectl apply --overwrite -f -
|
||||
kubectl -n $NAMESPACE label --overwrite secret ${K8S_CERT_SECRET_NAME} codefresh.io/internal=true
|
||||
kubectl -n $NAMESPACE patch secret $K8S_CERT_SECRET_NAME -p '{"metadata": {"finalizers": ["kubernetes"]}}'
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "-----"
|
||||
echo "API_HOST: ${API_HOST}"
|
||||
echo "AGENT_NAME: ${AGENT_NAME}"
|
||||
echo "KUBE_CONTEXT: ${KUBE_CONTEXT}"
|
||||
echo "KUBE_NAMESPACE: ${KUBE_NAMESPACE}"
|
||||
echo "OWNER_NAME: ${OWNER_NAME}"
|
||||
echo "RUNTIME_NAME: ${RUNTIME_NAME}"
|
||||
echo "SECRET_NAME: ${SECRET_NAME}"
|
||||
echo "-----"
|
||||
|
||||
create_agent_secret() {
|
||||
|
||||
kubectl apply -f - <<EOF
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
type: Opaque
|
||||
metadata:
|
||||
name: ${SECRET_NAME}
|
||||
namespace: ${KUBE_NAMESPACE}
|
||||
labels:
|
||||
codefresh.io/internal: "true"
|
||||
finalizers:
|
||||
- kubernetes
|
||||
ownerReferences:
|
||||
- apiVersion: apps/v1
|
||||
kind: Deploy
|
||||
name: ${OWNER_NAME}
|
||||
uid: ${OWNER_UID}
|
||||
stringData:
|
||||
agent-codefresh-token: ${1}
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
OWNER_UID=$(kubectl get deploy ${OWNER_NAME} --namespace ${KUBE_NAMESPACE} -o jsonpath='{.metadata.uid}')
|
||||
echo "got owner uid: ${OWNER_UID}"
|
||||
|
||||
if [ ! -z "${AGENT_CODEFRESH_TOKEN}" ]; then
|
||||
echo "-----"
|
||||
echo "runtime and agent are already initialized"
|
||||
echo "-----"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -z "${EXISTING_AGENT_CODEFRESH_TOKEN}" ]; then
|
||||
echo "using existing agentToken value"
|
||||
create_agent_secret $EXISTING_AGENT_CODEFRESH_TOKEN
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${USER_CODEFRESH_TOKEN}" ]; then
|
||||
echo "-----"
|
||||
echo "missing codefresh user token. must supply \".global.codefreshToken\" if agent-codefresh-token does not exist"
|
||||
echo "-----"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
codefresh auth create-context --api-key ${USER_CODEFRESH_TOKEN} --url ${API_HOST}
|
||||
|
||||
# AGENT_TOKEN might be empty, in which case it will be returned by the call
|
||||
RES=$(codefresh install agent \
|
||||
--name ${AGENT_NAME} \
|
||||
--kube-context-name ${KUBE_CONTEXT} \
|
||||
--kube-namespace ${KUBE_NAMESPACE} \
|
||||
--agent-kube-namespace ${KUBE_NAMESPACE} \
|
||||
--install-runtime \
|
||||
--runtime-name ${RUNTIME_NAME} \
|
||||
--skip-cluster-creation \
|
||||
--platform-only)
|
||||
|
||||
AGENT_CODEFRESH_TOKEN=$(echo "${RES}" | tail -n 1)
|
||||
echo "generated agent + runtime in platform"
|
||||
|
||||
create_agent_secret $AGENT_CODEFRESH_TOKEN
|
||||
|
||||
echo "-----"
|
||||
echo "done initializing runtime and agent"
|
||||
echo "-----"
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "-----"
|
||||
echo "API_HOST: ${API_HOST}"
|
||||
echo "KUBE_CONTEXT: ${KUBE_CONTEXT}"
|
||||
echo "KUBE_NAMESPACE: ${KUBE_NAMESPACE}"
|
||||
echo "OWNER_NAME: ${OWNER_NAME}"
|
||||
echo "RUNTIME_NAME: ${RUNTIME_NAME}"
|
||||
echo "CONFIGMAP_NAME: ${CONFIGMAP_NAME}"
|
||||
echo "RECONCILE_INTERVAL: ${RECONCILE_INTERVAL}"
|
||||
echo "-----"
|
||||
|
||||
msg() { echo -e "\e[32mINFO ---> $1\e[0m"; }
|
||||
err() { echo -e "\e[31mERR ---> $1\e[0m" ; return 1; }
|
||||
|
||||
|
||||
if [ -z "${USER_CODEFRESH_TOKEN}" ]; then
|
||||
err "missing codefresh user token. must supply \".global.codefreshToken\" if agent-codefresh-token does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
codefresh auth create-context --api-key ${USER_CODEFRESH_TOKEN} --url ${API_HOST}
|
||||
|
||||
while true; do
|
||||
msg "Reconciling ${RUNTIME_NAME} runtime"
|
||||
|
||||
sleep $RECONCILE_INTERVAL
|
||||
|
||||
codefresh get re \
|
||||
--name ${RUNTIME_NAME} \
|
||||
-o yaml \
|
||||
| yq 'del(.version, .metadata.changedBy, .metadata.creationTime)' > /tmp/runtime.yaml
|
||||
|
||||
kubectl get cm ${CONFIGMAP_NAME} -n ${KUBE_NAMESPACE} -o yaml \
|
||||
| yq 'del(.metadata.resourceVersion, .metadata.uid)' \
|
||||
| yq eval '.data["runtime.yaml"] = load_str("/tmp/runtime.yaml")' \
|
||||
| kubectl apply -f -
|
||||
done
|
|
@ -0,0 +1,70 @@
|
|||
{{- define "app-proxy.resources.deployment" -}}
|
||||
{{ $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
labels:
|
||||
{{- include "app-proxy.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicasCount }}
|
||||
strategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "app-proxy.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "app-proxy.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include (printf "%s.image.pullSecrets" $cfCommonTplSemver ) . | nindent 8 }}
|
||||
serviceAccountName: {{ include "app-proxy.serviceAccountName" . }}
|
||||
{{- if .Values.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: app-proxy
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
|
||||
env:
|
||||
{{- include "app-proxy.environment-variables" . | nindent 8 }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
{{- with .Values.extraVolumeMounts }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- with .Values.extraVolumes }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,19 @@
|
|||
{{- define "app-proxy.environment-variables.defaults" }}
|
||||
PORT: 3000
|
||||
{{- end }}
|
||||
|
||||
{{- define "app-proxy.environment-variables.calculated" }}
|
||||
CODEFRESH_HOST: {{ include "runtime.runtime-environment-spec.codefresh-host" . }}
|
||||
{{- with .Values.ingress.pathPrefix }}
|
||||
API_PATH_PREFIX: {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "app-proxy.environment-variables" }}
|
||||
{{- $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
{{- $defaults := (include "app-proxy.environment-variables.defaults" . | fromYaml) }}
|
||||
{{- $calculated := (include "app-proxy.environment-variables.calculated" . | fromYaml) }}
|
||||
{{- $overrides := .Values.env }}
|
||||
{{- $mergedValues := mergeOverwrite (merge $defaults $calculated) $overrides }}
|
||||
{{- include (printf "%s.env-vars" $cfCommonTplSemver) (dict "Values" $mergedValues "context" .) }}
|
||||
{{- end }}
|
|
@ -0,0 +1,43 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "app-proxy.name" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.name" .) "app-proxy" | 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 "app-proxy.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "app-proxy" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "app-proxy.labels" -}}
|
||||
{{ include "cf-runtime.labels" . }}
|
||||
codefresh.io/application: app-proxy
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "app-proxy.selectorLabels" -}}
|
||||
{{ include "cf-runtime.selectorLabels" . }}
|
||||
codefresh.io/application: app-proxy
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "app-proxy.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "app-proxy.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,32 @@
|
|||
{{- define "app-proxy.resources.ingress" -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
labels: {{- include "app-proxy.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.ingress.class (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||
ingressClassName: {{ .Values.ingress.class }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tlsSecret }}
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ .Values.ingress.host }}
|
||||
secretName: {{ .Values.tlsSecret }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- host: {{ .Values.ingress.host }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ .Values.ingress.pathPrefix | default "/" }}
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
port:
|
||||
number: 80
|
||||
{{- end -}}
|
|
@ -0,0 +1,47 @@
|
|||
{{- define "app-proxy.resources.rbac" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "app-proxy.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "app-proxy.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
labels:
|
||||
{{- include "app-proxy.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [ "" ]
|
||||
resources: [ "secrets" ]
|
||||
verbs: [ "get" ]
|
||||
{{- with .Values.rbac.rules }}
|
||||
{{ toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if and .Values.serviceAccount.create .Values.rbac.create }}
|
||||
kind: {{ .Values.rbac.namespaced | ternary "RoleBinding" "ClusterRoleBinding" }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
labels:
|
||||
{{- include "app-proxy.labels" . | nindent 4 }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "app-proxy.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,17 @@
|
|||
{{- define "app-proxy.resources.service" -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "app-proxy.fullname" . }}
|
||||
labels:
|
||||
{{- include "app-proxy.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 3000
|
||||
selector:
|
||||
{{- include "app-proxy.selectorLabels" . | nindent 4 }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,62 @@
|
|||
{{- define "event-exporter.resources.deployment" -}}
|
||||
{{ $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicasCount }}
|
||||
strategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "event-exporter.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "event-exporter.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include (printf "%s.image.pullSecrets" $cfCommonTplSemver ) . | nindent 8 }}
|
||||
serviceAccountName: {{ include "event-exporter.serviceAccountName" . }}
|
||||
{{- if .Values.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: event-exporter
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
|
||||
args: [--running-in-cluster=true]
|
||||
env:
|
||||
{{- include "event-exporter.environment-variables" . | nindent 8 }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9102
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
{{- with .Values.extraVolumeMounts }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- with .Values.extraVolumes }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,14 @@
|
|||
{{- define "event-exporter.environment-variables.defaults" }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "event-exporter.environment-variables.calculated" }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "event-exporter.environment-variables" }}
|
||||
{{- $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
{{- $defaults := (include "event-exporter.environment-variables.defaults" . | fromYaml) }}
|
||||
{{- $calculated := (include "event-exporter.environment-variables.calculated" . | fromYaml) }}
|
||||
{{- $overrides := .Values.env }}
|
||||
{{- $mergedValues := mergeOverwrite (merge $defaults $calculated) $overrides }}
|
||||
{{- include (printf "%s.env-vars" $cfCommonTplSemver) (dict "Values" $mergedValues "context" .) }}
|
||||
{{- end }}
|
|
@ -0,0 +1,43 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "event-exporter.name" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.name" .) "event-exporter" | 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 "event-exporter.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "event-exporter" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "event-exporter.labels" -}}
|
||||
{{ include "cf-runtime.labels" . }}
|
||||
app: event-exporter
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "event-exporter.selectorLabels" -}}
|
||||
{{ include "cf-runtime.selectorLabels" . }}
|
||||
app: event-exporter
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "event-exporter.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "event-exporter.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,47 @@
|
|||
{{- define "event-exporter.resources.rbac" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "event-exporter.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: [events]
|
||||
verbs: [get, list, watch]
|
||||
{{- with .Values.rbac.rules }}
|
||||
{{ toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if and .Values.serviceAccount.create .Values.rbac.create }}
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "event-exporter.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,17 @@
|
|||
{{- define "event-exporter.resources.service" -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: metrics
|
||||
port: 9102
|
||||
targetPort: metrics
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "event-exporter.selectorLabels" . | nindent 4 }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,14 @@
|
|||
{{- define "event-exporter.resources.serviceMonitor" -}}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ include "event-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "event-exporter.labels" . | nindent 4 }}
|
||||
spec:
|
||||
endpoints:
|
||||
- port: metrics
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "event-exporter.selectorLabels" . | nindent 6 }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,70 @@
|
|||
{{- define "monitor.resources.deployment" -}}
|
||||
{{ $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "monitor.fullname" . }}
|
||||
labels:
|
||||
{{- include "monitor.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicasCount }}
|
||||
strategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "monitor.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "monitor.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include (printf "%s.image.pullSecrets" $cfCommonTplSemver ) . | nindent 8 }}
|
||||
serviceAccountName: {{ include "monitor.serviceAccountName" . }}
|
||||
{{- if .Values.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: monitor
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
|
||||
env:
|
||||
{{- include "monitor.environment-variables" . | nindent 8 }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 9020
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
httpGet:
|
||||
path: /api/ping
|
||||
port: 9020
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
{{- with .Values.extraVolumeMounts }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
{{- with .Values.extraVolumes }}
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,26 @@
|
|||
{{- define "monitor.environment-variables.defaults" }}
|
||||
SERVICE_NAME: {{ include "monitor.fullname" . }}
|
||||
PORT: 9020
|
||||
HELM3: true
|
||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||
{{- end }}
|
||||
|
||||
{{- define "monitor.environment-variables.calculated" }}
|
||||
API_TOKEN: {{ include "runtime.installation-token-env-var-value" . | nindent 2 }}
|
||||
CLUSTER_ID: {{ include "runtime.runtime-environment-spec.context-name" . }}
|
||||
API_URL: {{ include "runtime.runtime-environment-spec.codefresh-host" . }}/api/k8s-monitor/events
|
||||
ACCOUNT_ID: {{ .Values.global.accountId }}
|
||||
NAMESPACE: {{ .Release.Namespace }}
|
||||
{{- if .Values.rbac.namespaced }}
|
||||
ROLE_BINDING: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "monitor.environment-variables" }}
|
||||
{{- $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
{{- $defaults := (include "monitor.environment-variables.defaults" . | fromYaml) }}
|
||||
{{- $calculated := (include "monitor.environment-variables.calculated" . | fromYaml) }}
|
||||
{{- $overrides := .Values.env }}
|
||||
{{- $mergedValues := mergeOverwrite (merge $defaults $calculated) $overrides }}
|
||||
{{- include (printf "%s.env-vars" $cfCommonTplSemver) (dict "Values" $mergedValues "context" .) }}
|
||||
{{- end }}
|
|
@ -0,0 +1,42 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "monitor.name" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.name" .) "monitor" | 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 "monitor.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "monitor" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "monitor.labels" -}}
|
||||
{{ include "cf-runtime.labels" . }}
|
||||
codefresh.io/application: monitor
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "monitor.selectorLabels" -}}
|
||||
{{ include "cf-runtime.selectorLabels" . }}
|
||||
codefresh.io/application: monitor
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "monitor.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "monitor.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,56 @@
|
|||
{{- define "monitor.resources.rbac" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "monitor.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "monitor.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "monitor.fullname" . }}
|
||||
labels:
|
||||
{{- include "monitor.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [ "" ]
|
||||
resources: [ "*" ]
|
||||
verbs: [ "get", "list", "watch", "create", "delete" ]
|
||||
- apiGroups: [ "" ]
|
||||
resources: [ "pods" ]
|
||||
verbs: [ "get", "list", "watch", "create", "deletecollection" ]
|
||||
- apiGroups: [ "extensions" ]
|
||||
resources: [ "*" ]
|
||||
verbs: [ "get", "list", "watch" ]
|
||||
- apiGroups: [ "apps" ]
|
||||
resources: [ "*" ]
|
||||
verbs: [ "get", "list", "watch" ]
|
||||
{{- with .Values.rbac.rules }}
|
||||
{{ toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if and .Values.serviceAccount.create .Values.rbac.create }}
|
||||
kind: {{ .Values.rbac.namespaced | ternary "RoleBinding" "ClusterRoleBinding" }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "monitor.fullname" . }}
|
||||
labels:
|
||||
{{- include "monitor.labels" . | nindent 4 }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "monitor.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
|
||||
name: {{ include "monitor.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,17 @@
|
|||
{{- define "monitor.resources.service" -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "monitor.fullname" . }}
|
||||
labels:
|
||||
{{- include "monitor.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 9020
|
||||
selector:
|
||||
{{- include "monitor.selectorLabels" . | nindent 4 }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,103 @@
|
|||
{{- define "runner.resources.deployment" -}}
|
||||
{{ $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "runner.fullname" . }}
|
||||
labels:
|
||||
{{- include "runner.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicasCount }}
|
||||
strategy:
|
||||
type: {{ .Values.updateStrategy.type }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "runner.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "runner.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include (printf "%s.image.pullSecrets" $cfCommonTplSemver ) . | nindent 8 }}
|
||||
serviceAccountName: {{ include "runner.serviceAccountName" . }}
|
||||
{{- if .Values.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
initContainers:
|
||||
- name: init
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.init.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.init.image.pullPolicy | default "IfNotPresent" }}
|
||||
command:
|
||||
- /bin/bash
|
||||
args:
|
||||
- -ec
|
||||
- | {{ .Files.Get "files/init-runtime.sh" | nindent 10 }}
|
||||
env:
|
||||
{{- include "runner-init.environment-variables" . | nindent 8 }}
|
||||
{{- with .Values.init.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: runner
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
|
||||
env:
|
||||
{{- include "runner.environment-variables" . | nindent 8 }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
{{- with .Values.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- with .Values.extraVolumeMounts }}
|
||||
volumeMounts:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sidecar.enabled }}
|
||||
- name: reconcile-runtime
|
||||
image: {{ include (printf "%s.image.name" $cfCommonTplSemver ) (dict "image" .Values.sidecar.image "context" .) }}
|
||||
imagePullPolicy: {{ .Values.sidecar.image.pullPolicy | default "IfNotPresent" }}
|
||||
command:
|
||||
- /bin/bash
|
||||
args:
|
||||
- -ec
|
||||
- | {{ .Files.Get "files/reconcile-runtime.sh" | nindent 10 }}
|
||||
env:
|
||||
{{- include "runner-sidecar.environment-variables" . | nindent 8 }}
|
||||
{{- with .Values.sidecar.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- with .Values.extraVolumes }}
|
||||
volumes:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
|
@ -0,0 +1,42 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "runner.name" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.name" .) "runner" | 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 "runner.fullname" -}}
|
||||
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "runner" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "runner.labels" -}}
|
||||
{{ include "cf-runtime.labels" . }}
|
||||
codefresh.io/application: runner
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "runner.selectorLabels" -}}
|
||||
{{ include "cf-runtime.selectorLabels" . }}
|
||||
codefresh.io/application: runner
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "runner.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "runner.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
|
@ -0,0 +1,53 @@
|
|||
{{- define "runner.resources.rbac" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "runner.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "runner.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.rbac.create }}
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "runner.fullname" . }}
|
||||
labels:
|
||||
{{- include "runner.labels" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [ "" ]
|
||||
resources: [ "pods", "persistentvolumeclaims" ]
|
||||
verbs: [ "get", "create", "delete", patch ]
|
||||
- apiGroups: [ "" ]
|
||||
resources: [ "configmaps", "secrets" ]
|
||||
verbs: [ "get", "create", "update", patch ]
|
||||
- apiGroups: [ "apps" ]
|
||||
resources: [ "deployments" ]
|
||||
verbs: [ "get" ]
|
||||
{{- with .Values.rbac.rules }}
|
||||
{{ toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if and .Values.serviceAccount.create .Values.rbac.create }}
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ include "runner.fullname" . }}
|
||||
labels:
|
||||
{{- include "runner.labels" . | nindent 4 }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "runner.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "runner.fullname" . }}
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- end }}
|
||||
{{- end -}}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue