Add stackgres chart

This commit is contained in:
2024-05-30 20:42:52 +08:00
parent 1026f0ea9b
commit db34ed82a3
49 changed files with 21734 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
Release Name: {{ .Release.Name }}
StackGres Version: {{ .Chart.Version }}
_____ _ _ _____
/ ____| | | | / ____|
| (___ | |_ __ _ ___| | _| | __ _ __ ___ ___
\___ \| __/ _` |/ __| |/ / | |_ | '__/ _ \/ __|
____) | || (_| | (__| <| |__| | | | __/\__ \
|_____/ \__\__,_|\___|_|\_\\_____|_| \___||___/
by OnGres, Inc.
{{- if not .Values.cert.autoapprove }}
To complete the process approve operator certificate signing request:
kubectl certificate approve {{ .Release.Name }}
{{- end }}
Check if the operator was successfully deployed and is available:
kubectl describe deployment -n {{ .Release.Namespace }} {{ .Release.Name }}
kubectl wait -n {{ .Release.Namespace }} deployment/{{ .Release.Name }} --for condition=Available
Check if the restapi was successfully deployed and is available:
kubectl describe deployment -n {{ .Release.Namespace }} {{ .Values.restapi.name }}
kubectl wait -n {{ .Release.Namespace }} deployment/{{ .Values.restapi.name }} --for condition=Available
{{- if .Values.deploy.restapi }}
To access StackGres Operator UI from localhost, run the below commands:
POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "stackgres.io/restapi=true" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward "$POD_NAME" 8443:9443 --namespace {{ .Release.Namespace }}
Read more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/
Now you can access the StackGres Operator UI on:
https://localhost:8443
{{- if (eq .Values.authentication.type "jwt") }}
To get the username, run the command:
kubectl get secret -n {{ .Release.Namespace }} stackgres-restapi-admin --template '{{ "{{" }} printf "username = %s\n" (.data.k8sUsername | base64decode) {{ "}}" }}'
{{- if and (not .Values.authentication.password) (not (.Values.authentication.secretRef).name) }}
To get the generated password, run the command:
kubectl get secret -n {{ .Release.Namespace }} stackgres-restapi-admin --template '{{ "{{" }} printf "password = %s\n" (.data.clearPassword | base64decode) {{ "}}" }}'
Remember to remove the generated password hint from the secret to avoid security flaws:
kubectl patch secret --namespace {{ .Release.Namespace }} stackgres-restapi-admin --type json -p '[{"op":"remove","path":"/data/clearPassword"}]'
{{- end }}
{{- end }}
{{- end }}
+65
View File
@@ -0,0 +1,65 @@
{{- define "kubectl.image" }}
{{- if semverCompare ">=1.27" .Capabilities.KubeVersion.Version -}}
{{- printf "%s/ongres/kubectl:v1.28.8-build-6.31" .Values.containerRegistry -}}
{{- else if semverCompare ">=1.24" .Capabilities.KubeVersion.Version -}}
{{- printf "%s/ongres/kubectl:v1.25.16-build-6.31" .Values.containerRegistry -}}
{{- else if semverCompare ">=1.21" .Capabilities.KubeVersion.Version -}}
{{- printf "%s/ongres/kubectl:v1.22.17-build-6.31" .Values.containerRegistry -}}
{{- else if semverCompare ">=1.18" .Capabilities.KubeVersion.Version -}}
{{- printf "%s/ongres/kubectl:v1.19.16-build-6.31" .Values.containerRegistry -}}
{{- else -}}
{{- printf "%s/ongres/kubectl:v1.28.8-build-6.31" .Values.containerRegistry -}}
{{- end -}}
{{- end -}}
{{- define "operator-image" }}
{{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.operator.image.name) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.operator.image.name }}:{{ .Values.operator.image.tag }}
{{- end }}
{{- define "restapi-image" }}
{{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.restapi.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.restapi.image.name }}:{{ .Values.restapi.image.tag }}
{{- end }}
{{- define "adminui-image" }}
{{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.adminui.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.adminui.image.name }}:{{ .Values.adminui.image.tag }}
{{- end }}
{{- define "jobs-image" }}
{{- if not (regexMatch "^[^/]+\\.[^/]+/.*$" .Values.jobs.image.name ) }}{{ .Values.containerRegistry }}/{{ end }}{{ .Values.jobs.image.name }}:{{ .Values.jobs.image.tag }}
{{- end }}
{{- define "cert-name" }}
{{- .Values.cert.secretName | default (printf "%s-%s" .Release.Name "certs") }}
{{- end }}
{{- define "web-cert-name" }}
{{- .Values.cert.webSecretName | default (printf "%s-%s" .Release.Name "web-certs") }}
{{- end }}
{{- define "stackgres.operator.missingSGConfigCrd" }}
{{- if .Release.IsUpgrade }}
{{- $missingSGConfigCrd := true }}
{{- $configCrd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" "sgconfigs.stackgres.io" }}
{{- if $configCrd }}
{{- $missingSGConfigCrd = false }}
{{- end }}
{{- if $missingSGConfigCrd }}true{{- else }}false{{- end }}
{{- else }}
false
{{- end }}
{{- end }}
{{- define "stackgres.operator.unmodificableWebapiAdminClusterRoleBinding" }}
{{- if .Release.IsUpgrade }}
{{- $unmodificableWebapiAdminClusterRoleBinding := false }}
{{- $webapiAdminClusterRoleBinding := lookup "rbac.authorization.k8s.io/v1" "ClusterRoleBinding" "" "stackgres-restapi-admin" }}
{{- if $webapiAdminClusterRoleBinding }}
{{- if not (eq $webapiAdminClusterRoleBinding.roleRef.name "stackgres-restapi-admin") }}
{{- $unmodificableWebapiAdminClusterRoleBinding = true }}
{{- end }}
{{- end }}
{{- if $unmodificableWebapiAdminClusterRoleBinding }}true{{- else }}false{{- end }}
{{- else }}
false
{{- end }}
{{- end }}
@@ -0,0 +1,12 @@
{{ if and .Release.IsInstall .Values.deploy.operator }}
{{ $deployments := lookup "apps/v1" "Deployment" "" "" }}
{{ range $deployments.items }}
{{ if .metadata.labels }}
{{ if .metadata.labels.group }}
{{ if eq .metadata.labels.group "stackgres.io" }}
{{ fail (print "StackGres Operator Helm Chart can only install one operator instance. Multiple operator instances is not supported.") }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
@@ -0,0 +1,34 @@
{{ if .Release.IsUpgrade }}
{{ $chart := .Chart }}
{{ $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" "sgclusters.stackgres.io" }}
{{ if $crd }}
{{ $deployment := lookup "apps/v1" "Deployment" .Release.Namespace .Release.Name }}
{{ if $deployment }}
{{ if $deployment.metadata.labels }}
{{ if $deployment.metadata.labels.version }}
{{ $version := $deployment.metadata.labels.version }}
{{ if not .Values.forceUpgradeFromUnsupportedVersion }}
{{ if or (not (regexMatch "^(1\\.8\\.|1\\.9\\.|1\\.10\\.)" $version)) (and (not (eq $version $chart.Version)) (regexMatch "(-alpha[0-9]|-beta[0-9])" $version)) }}
{{ fail (print "Upgrading from version " $version " version is not supported. You may force upgrading from an unsupported version setting the parameter \"forceUpgradeFromUnsupportedVersion\" to \"true\". If you do so do it at your own risk. It has not been tested and some functionality may break. We recommend to perform security upgrades all your SGCluster as soon as possible after upgrading from an unsupported version of the operator") }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ $clusters := lookup "stackgres.io/v1" "SGCluster" "" "" }}
{{ if $clusters }}
{{ if $clusters.items }}
{{ range $cluster := $clusters.items }}
{{ if $cluster.metadata.annotations }}
{{ if (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
{{ $version := (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
{{ if (not (regexMatch "^(1\\.8\\.|1\\.9\\.|1\\.10\\.)" $version)) }}
{{ fail (print "Can not upgrade due to some SGCluster still at version " $version ". You have to run a SGDbOps of type securityUpgrade on those SGClusters first.") }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
@@ -0,0 +1,40 @@
{{- if .Values.cert.certManager.autoConfigure }}
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: "{{ .Release.Name }}-self-signed-issuer"
namespace: "{{ .Release.Namespace }}"
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: "{{ .Release.Name }}-certs"
namespace: "{{ .Release.Namespace }}"
spec:
secretName: "{{ include "cert-name" . }}"
duration: "{{ .Values.cert.certManager.duration }}"
renewBefore: "{{ .Values.cert.certManager.renewBefore }}"
subject:
organizations:
- OnGres
isCA: true
privateKey:
algorithm: RSA
encoding: "{{ .Values.cert.certManager.encoding }}"
size: {{ .Values.cert.certManager.size }}
usages:
- server auth
- client auth
dnsNames:
- {{ .Release.Name }}
- {{ .Release.Name }}.{{ .Release.Namespace }}
- {{ .Release.Name }}.{{ .Release.Namespace }}.svc
- {{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
name: "{{ .Release.Name }}-self-signed-issuer"
kind: Issuer
group: cert-manager.io
{{ end }}
@@ -0,0 +1,46 @@
{{- if .Values.extensions.cache.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-extensions-cache
namespace: {{ .Release.Namespace }}
{{- if .Values.qutePreprocess }}#comment.preprocess.start{{- end }}
data:
nginx.conf: |
pid /var/run/nginx.pid;
error_log /dev/stdout;
error_log /var/log/nginx/error.log;
events{
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
stackgres-operator-extensions-cache.conf: |
server {
server_name localhost;
listen 8080;
root /opt/app-root/src;
location / {
try_files /$host$uri =404;
}
}
extensions-cache-conciliator.sh: |
{{ .Files.Get "extensions-cache-conciliator.sh" | indent 4 }}
{{- if .Values.qutePreprocess }}#comment.preprocess.end{{- end }}
{{- end }}
@@ -0,0 +1,102 @@
{{- if .Values.extensions.cache.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-extensions-cache
namespace: {{ .Release.Namespace }}
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
{{- if .Values.serviceAccount.repoCredentials }}
imagePullSecrets:
{{- range .Values.serviceAccount.repoCredentials }}
- name: {{ . }}
{{- end }}
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-extensions-cache
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups: ["stackgres.io"]
resources:
- sgclusters
- sgdistributedlogs
verbs:
- list
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-extensions-cache
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-extensions-cache
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}-extensions-cache
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}-extensions-cache
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups: ["", "apps"]
resources:
- serviceaccounts
- statefulsets
verbs:
- get
- patch
- update
resourceNames:
- {{ .Release.Name }}-extensions-cache
- apiGroups: [""]
resources:
- pods
verbs:
- delete
resourceNames:
- {{ .Release.Name }}-extensions-cache-0
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}-extensions-cache
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-extensions-cache
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-extensions-cache
apiGroup: rbac.authorization.k8s.io
{{- end }}
@@ -0,0 +1,21 @@
{{- if .Values.extensions.cache.enabled }}
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}-extensions-cache
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
selector:
app: {{ .Release.Name }}-extensions-cache
ports:
- name: http
protocol: TCP
port: 80
targetPort: http
{{- end }}
@@ -0,0 +1,201 @@
{{- if .Values.extensions.cache.enabled }}
apiVersion: "apps/v1"
kind: "StatefulSet"
metadata:
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
app: {{ .Release.Name }}-extensions-cache
version: "{{ .Chart.Version }}"
group: stackgres.io
name: {{ .Release.Name }}-extensions-cache
namespace: {{ .Release.Namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-extensions-cache
group: stackgres.io
serviceName: {{ .Release.Name }}-extensions-cache
template:
metadata:
labels:
app: {{ .Release.Name }}-extensions-cache
group: stackgres.io
spec:
securityContext:
{{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
fsGroup: 1000
{{- end }}
serviceAccountName: {{ .Release.Name }}-extensions-cache
shareProcessNamespace: true
terminationGracePeriodSeconds: 0
restartPolicy: Always
containers:
- name: http
image: "registry.access.redhat.com/ubi8/nginx-120:1-92.1679484498"
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- if and (or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser) (not .Values.extensions.cache.hostPath) }}
runAsNonRoot: true
runAsUser: 998
runAsGroup: 1000
{{- end }}
{{- if .Values.extensions.cache.hostPath }}
runAsUser: 0
{{- end }}
args:
- '/bin/sh'
- '-ec'
{{- if .Values.developer.showDebug }}
- '-x'
{{- end }}
- |
mkdir -p /var/lib/nginx/tmp
exec nginx -g 'daemon off;'
ports:
- containerPort: 8080
name: "http"
protocol: "TCP"
readinessProbe:
tcpSocket:
port: 8080
volumeMounts:
- name: extensions-cache-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
readOnly: true
- name: extensions-cache-config
mountPath: /etc/nginx/conf.d/stackgres-operator-extensions-cache.conf
subPath: stackgres-operator-extensions-cache.conf
readOnly: true
- name: extensions-cache-nginx-var
subPath: var/cache/nginx
mountPath: /var/cache/nginx
readOnly: false
- name: extensions-cache-nginx-var
subPath: var/run
mountPath: /var/run
readOnly: false
- name: extensions-cache-nginx-var
subPath: var/lib/nginx
mountPath: /var/lib/nginx
readOnly: false
- name: extensions-cache-nginx-var
subPath: var/log/nginx
mountPath: /var/log/nginx
readOnly: false
- name: {{ .Release.Name }}-extensions-cache
subPath: repository
mountPath: /opt/app-root/src
readOnly: true
- name: "controller"
image: {{ template "kubectl.image" . }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
securityContext:
{{- if and (or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser) (not .Values.extensions.cache.hostPath) }}
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
{{- end }}
{{- if .Values.extensions.cache.hostPath }}
runAsUser: 0
{{- end }}
env:
- name: HOME
value: /tmp
- name: EXTENSIONS_REPOSITORY_URLS
value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element }}{{ end }}"
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
{{- if .Values.developer.logLevel }}
- name: EXTENSIONS_CACHE_LOG_LEVEL
value: "{{ .Values.developer.logLevel }}"
{{- end }}
{{- range .Values.developer.extraOpts }}
{{- if . | hasPrefix "-Dquarkus.log.category.\"stackgres-extensions-cache\".level=" }}
- name: EXTENSIONS_CACHE_LOG_LEVEL
value: "{{ . | trimPrefix "-Dquarkus.log.category.\"stackgres-extensions-cache\".level=" }}"
{{- end }}
{{- end }}
{{- if .Values.extensions.cache.preloadedExtensions }}
- name: EXTENSIONS_CACHE_PRELOADED_EXTENSIONS
value: {{ .Values.extensions.cache.preloadedExtensions | toJson | squote }}
{{- end }}
command:
- "/bin/bash"
- "-ec"
- |
echo "$EXTENSIONS_CACHE_LOG_LEVEL" | grep -v -q '^\(DEBUG\|TRACE\)$' || set -x
cd /opt/app-root/src
sh /usr/local/bin/extensions-cache-conciliator.sh run "$OPERATOR_NAMESPACE" '{{ .Release.Name }}-extensions-cache'
readinessProbe:
exec:
command:
- test
- -f
- /tmp/extensions-cache-ready
volumeMounts:
- name: extensions-cache-config
mountPath: /usr/local/bin/extensions-cache-conciliator.sh
subPath: extensions-cache-conciliator.sh
readOnly: true
- name: {{ .Release.Name }}-extensions-cache
subPath: repository
mountPath: /opt/app-root/src
readOnly: false
- name: extensions-cache-nginx-var
subPath: var/log/nginx
mountPath: /var/log/nginx
readOnly: true
volumes:
{{- if .Values.extensions.cache.hostPath }}
- name: {{ .Release.Name }}-extensions-cache
hostPath:
path: "{{ .Values.extensions.cache.hostPath }}"
type: DirectoryOrCreate
{{- end }}
- name: extensions-cache-config
configMap:
name: {{ .Release.Name }}-extensions-cache
optional: false
items:
- key: nginx.conf
path: nginx.conf
- key: stackgres-operator-extensions-cache.conf
path: stackgres-operator-extensions-cache.conf
- key: extensions-cache-conciliator.sh
path: extensions-cache-conciliator.sh
- name: extensions-cache-nginx-var
emptyDir: {}
{{- if not .Values.extensions.cache.hostPath }}
volumeClaimTemplates:
- metadata:
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
app: {{ .Release.Name }}-extensions-cache
version: "{{ .Chart.Version }}"
group: stackgres.io
name: {{ .Release.Name }}-extensions-cache
spec:
accessModes: [ "ReadWriteOnce" ]
{{- if .Values.extensions.cache.persistentVolume.storageClass }}
{{- if eq "-" .Values.extensions.cache.persistentVolume.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.extensions.cache.persistentVolume.storageClass }}"
{{- end }}
{{- end }}
resources:
requests:
storage: "{{ .Values.extensions.cache.persistentVolume.size }}"
{{- end }}
{{- end }}
@@ -0,0 +1,116 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-init
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-100"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-100"
name: {{ .Release.Name }}-init
rules:
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
- clusterrolebinding
verbs:
- create
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
verbs:
- get
- apiGroups: ["rbac.authorization.k8s.io"]
resources:
- clusterrolebindings
resourceNames:
- stackgres-restapi-admin
verbs:
- get
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Release.Name }}-init
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-100"
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-init
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}-init
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-100"
name: {{ .Release.Name }}-init
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs
verbs:
- create
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs
resourceNames:
- {{ .Release.Name }}
verbs:
- get
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Release.Name }}-init
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "-100"
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-init
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-init
apiGroup: rbac.authorization.k8s.io
@@ -0,0 +1,217 @@
{{- $cert := "Cg==" }}
{{- $certSecret := lookup "v1" "Secret" .Release.Namespace (include "cert-name" .) }}
{{- if $certSecret }}
{{- if (index $certSecret.data "tls.crt") }}
{{- $cert = (index $certSecret.data "tls.crt") }}
{{- end }}
{{- end }}
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
webhooks:
- name: sgcluster.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgclusters"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgcluster'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgpgconfig.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgpgconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgpgconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgpoolconfig.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgpoolconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgpoolconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sginstanceprofile.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sginstanceprofiles"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sginstanceprofile'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgbackupconfig.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgbackupconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgbackupconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgbackup.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgbackups"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgbackup'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgdistributedlogs.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgdistributedlogs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgdistributedlogs'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgdbops.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgdbops"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgdbops'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgobjectstorage.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgobjectstorages"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgobjectstorage'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgscripts.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgscripts"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgscript'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardedclusters.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardedclusters"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgshardedcluster'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardedbackups.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardedbackups"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgshardedbackup'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardeddbops.mutating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardeddbops"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/mutation/sgshardeddbops'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
@@ -0,0 +1,18 @@
{{- if .Values.serviceAccount.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
@@ -0,0 +1,239 @@
{{- if .Values.serviceAccount.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Release.Name }}
rules:
- apiGroups: ["", "apps", "extensions", "rbac.authorization.k8s.io", "batch"]
resources:
- pods
- pods/exec
- pods/log
- services
- endpoints
- endpoints/restricted
- persistentvolumeclaims
- configmaps
- secrets
- deployments
- statefulsets
- serviceaccounts
- namespaces
- roles
- rolebindings
- events
- cronjobs
- jobs
verbs:
- get
- list
- watch
- update
- create
- delete
- deletecollection
- patch
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list"]
- apiGroups: ["stackgres.io"]
resources:
- sgclusters
- sgpgconfigs
- sginstanceprofiles
- sgpoolconfigs
- sgbackupconfigs
- sgbackups
- sgdistributedlogs
- sgdbops
- sgobjectstorages
- sgscripts
- sgshardedclusters
- sgshardedbackups
- sgshardeddbops
- sgconfigs
verbs:
- create
- watch
- list
- get
- update
- patch
- delete
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs/status
- sgclusters/status
- sgdistributedlogs/status
- sgclusters/finalizers
- sgpgconfigs/finalizers
- sginstanceprofiles/finalizers
- sgpoolconfigs/finalizers
- sgbackupconfigs/finalizers
- sgbackups/finalizers
- sgdistributedlogs/finalizers
- sgdbops/finalizers
- sgobjectstorages/finalizers
- sgscripts/finalizers
- sgshardedclusters/finalizers
- sgshardedbackups/finalizers
- sgshardeddbops/finalizers
- sgconfigs/finalizers
verbs:
- update
- apiGroups: ["", "apps", "batch"]
resources:
- statefulsets/finalizers
- persistentvolumeclaims/finalizers
- deployments/finalizers
- services/finalizers
- endpoints/finalizers
- cronjobs/finalizers
- jobs/finalizers
- pods/finalizers
verbs:
- update
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
- sgclusters.stackgres.io
- sginstanceprofiles.stackgres.io
- sgpgconfigs.stackgres.io
- sgpoolconfigs.stackgres.io
- sgbackups.stackgres.io
- sgbackupconfigs.stackgres.io
- sgobjectstorages.stackgres.io
- sgdbops.stackgres.io
- sgdistributedlogs.stackgres.io
- sgshardedclusters.stackgres.io
- sgshardedbackups.stackgres.io
- sgshardeddbops.stackgres.io
- sgscripts.stackgres.io
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- list
- apiGroups: ["snapshot.storage.k8s.io"]
resources:
- volumesnapshots
verbs:
- list
- get
- watch
- create
{{- if .Values.prometheus.allowAutobind }}
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- prometheuses.monitoring.coreos.com
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- list
- apiGroups: ["monitoring.coreos.com"]
resources:
- servicemonitors
- podmonitors
verbs:
- list
- get
- create
- delete
- update
- patch
- apiGroups: ["monitoring.coreos.com"]
resources:
- prometheus
- prometheuses
- podmonitors
verbs:
- list
- get
{{- end }}
{{- if not .Values.disableCRDcreation }}
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
- validatingwebhookconfigurations
resourceNames:
- {{ .Release.Name }}
verbs:
- get
- patch
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- create
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
- sgclusters.stackgres.io
- sginstanceprofiles.stackgres.io
- sgpgconfigs.stackgres.io
- sgpoolconfigs.stackgres.io
- sgbackups.stackgres.io
- sgbackupconfigs.stackgres.io
- sgobjectstorages.stackgres.io
- sgdbops.stackgres.io
- sgdistributedlogs.stackgres.io
- sgshardedclusters.stackgres.io
- sgshardedbackups.stackgres.io
- sgshardeddbops.stackgres.io
- sgscripts.stackgres.io
verbs:
- patch
- update
{{- end }}
{{- end }}
- apiGroups: ["shardingsphere.apache.org"]
resources:
- computenodes
verbs:
- get
- list
- watch
- update
- create
- delete
- patch
- apiGroups: ["keda.sh"]
resources:
- scaledobjects
- triggerauthentications
verbs:
- get
- list
- watch
- update
- create
- delete
- patch
- apiGroups: ["autoscaling.k8s.io"]
resources:
- verticalpodautoscalers
verbs:
- get
- list
- watch
- update
- create
- delete
- patch
@@ -0,0 +1,239 @@
{{- if .Values.deploy.operator }}
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
{{- with .Values.operator.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app: {{ .Release.Name }}
version: "{{ .Chart.Version }}"
group: stackgres.io
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}
group: stackgres.io
template:
metadata:
labels:
app: {{ .Release.Name }}
group: stackgres.io
spec:
{{- with .Values.operator.affinity}}
affinity:
{{- toYaml . | nindent 8 }}
{{- end}}
serviceAccountName: {{ .Release.Name }}
{{- if .Values.serviceAccount.create }}
{{- if .Values.serviceAccount.repoCredentials }}
imagePullSecrets:
{{- range .Values.serviceAccount.repoCredentials }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.operator.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end}}
securityContext:
{{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
runAsNonRoot: true
{{- if .Values.operator.image.tag | hasSuffix "-jvm" }}
runAsUser: 185
runAsGroup: 185
fsGroup: 185
{{- else }}
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
{{- end }}
{{- end }}
containers:
{{- if not (and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort) }}
- name: {{ .Release.Name }}
image: "{{ include "operator-image" . }}"
imagePullPolicy: {{ .Values.operator.image.pullPolicy }}
env:
- name: OPERATOR_NAME
value: "{{ .Release.Name }}"
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: OPERATOR_IMAGE_VERSION
value: "{{ .Values.operator.image.tag }}"
- name: DISABLE_RECONCILIATION
value: "false"
- name: INSTALL_CRDS
value: "true"
- name: INSTALL_WEBHOOKS
value: "true"
{{- if not .Values.cert.certManager.autoConfigure }}
- name: INSTALL_CERTS
value: "true"
{{- end }}
- name: PROMETHEUS_AUTOBIND
value: "{{ .Values.prometheus.allowAutobind }}"
{{- if and (.Capabilities.APIVersions.Has "project.openshift.io/v1") (not .Values.developer.disableArbitraryUser) }}
- name: USE_ARBITRARY_USER
value: "true"
{{- end }}
{{- if .Values.developer.logLevel }}
- name: OPERATOR_LOG_LEVEL
value: "{{ .Values.developer.logLevel }}"
{{- end }}
{{- if .Values.developer.showStackTraces }}
- name: OPERATOR_SHOW_STACK_TRACES
value: "{{ .Values.developer.showStackTraces }}"
{{- end }}
{{- if .Values.developer.extraOpts }}
- name: APP_OPTS
value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
{{- end }}
{{- if .Values.developer.extraOpts }}
- name: JAVA_OPTS
value: '{{ range .Values.developer.extraOpts }}{{ . }} {{ end }}'
{{- end }}
{{- if .Values.developer.enableJvmDebug }}
- name: DEBUG_OPERATOR
value: "{{ .Values.developer.enableJvmDebug }}"
{{- end }}
{{- if .Values.developer.enableJvmDebugSuspend }}
- name: DEBUG_OPERATOR_SUSPEND
value: "{{ .Values.developer.enableJvmDebugSuspend }}"
{{- end }}
- name: OPERATOR_SERVICE_ACCOUNT
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.serviceAccountName
- name: OPERATOR_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: OPERATOR_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- if and .Values.grafana.url .Values.grafana.token .Values.grafana.webHost }}
- name: GRAFANA_EMBEDDED
value: "true"
{{ end }}
- name: SG_CONTAINER_REGISTRY
value: "{{ .Values.containerRegistry }}"
- name: SG_IMAGE_PULL_POLICY
value: "{{ .Values.imagePullPolicy }}"
{{- if .Values.extensions.cache.enabled }}
- name: EXTENSIONS_REPOSITORY_URLS
value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element := regexReplaceAll "([?&])proxyUrl=[^&]+[&]" $element "${1}" }}{{ $element := regexReplaceAll "([?&])proxyUrl=[^&]+$" $element "" }}{{ $element }}{{ if $element | contains "?" }}&{{ else }}?{{ end }}proxyUrl=http%3A%2F%2F{{ $.Release.Name }}-extensions-cache.{{ $.Release.Namespace }}%3FsetHttpScheme%3Dtrue&retry=3%3A5{{ end }}"
{{- else }}
- name: EXTENSIONS_REPOSITORY_URLS
value: "{{ range $index, $element := .Values.extensions.repositoryUrls }}{{ if $index }},{{ end }}{{ $element }}{{ end }}"
{{- end }}
{{- if .Values.developer.extraEnv }}
{{- range $name,$value := .Values.developer.extraEnv }}
- name: {{ $name }}
value: {{ $value }}
{{- end }}
{{- end }}
{{- with .Values.developer.version }}
- name: OPERATOR_VERSION
value: {{ . | quote }}
{{- end }}
ports:
- containerPort: 8080
name: "http"
protocol: "TCP"
- containerPort: 8443
name: "https"
protocol: "TCP"
livenessProbe:
httpGet:
path: "/q/health/live"
port: 8080
scheme: "HTTP"
initialDelaySeconds: 10
periodSeconds: 60
timeoutSeconds: 10
readinessProbe:
httpGet:
path: "/q/health/ready"
port: 8080
scheme: "HTTP"
initialDelaySeconds: 0
periodSeconds: 2
timeoutSeconds: 1
{{- with .Values.operator.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- name: operator-certs
mountPath: /etc/operator/certs
readOnly: true
{{- with ((.Values.developer.patches).operator).volumeMounts }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- else }}
- name: {{ .Release.Name }}-nginx
image: "registry.access.redhat.com/ubi8/nginx-120:1-92"
imagePullPolicy: IfNotPresent
args:
- '/bin/sh'
- '-ec'
{{- if .Values.developer.showDebug }}
- '-x'
{{- end }}
- exec nginx -g 'daemon off;'
ports:
- containerPort: 9443
name: "proxyhttps"
protocol: "TCP"
volumeMounts:
- name: operator-certs
mountPath: /etc/operator/certs
readOnly: true
- name: operator-nginx-conf
mountPath: /etc/nginx/conf.d
readOnly: true
- name: operator-nginx
subPath: var/cache/nginx
mountPath: /var/cache/nginx
readOnly: false
- name: operator-nginx
subPath: var/run
mountPath: /var/run
readOnly: false
{{- end }}
volumes:
- name: operator-certs
secret:
secretName: {{ include "cert-name" . }}
optional: true
{{- if and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort }}
- name: operator-nginx-conf
configMap:
name: {{ .Release.Name }}-nginx
optional: false
items:
- key: stackgres-operator.conf
path: stackgres-operator.conf
- name: operator-nginx
emptyDir: {}
{{- end }}
{{- with ((.Values.developer.patches).operator).volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.operator.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,28 @@
{{ if and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-nginx
namespace: {{ .Release.Namespace }}
{{- if .Values.qutePreprocess }}#comment.preprocess.start{{- end }}
data:
stackgres-operator.conf: |
server {
server_name localhost;
listen 9443 ssl;
ssl_certificate /etc/operator/certs/server.crt;
ssl_certificate_key /etc/operator/certs/root.key;
location ~ ^/stackgres {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://{{ .Release.Name }}-api:8080;
}
}
{{- if .Values.qutePreprocess }}#comment.preprocess.end{{- end}}
{{- end }}
@@ -0,0 +1,17 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
{{- with .Values.operator.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.serviceAccount.repoCredentials }}
imagePullSecrets:
{{- range .Values.serviceAccount.repoCredentials }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,41 @@
{{ if and .Values.deploy.operator (not (and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort)) }}
apiVersion: v1
kind: Service
metadata:
{{- with .Values.operator.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
spec:
type: ClusterIP
selector:
app: {{ .Release.Name }}
ports:
- name: https
protocol: TCP
port: 443
targetPort: https
{{ else }}
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
spec:
ports:
- port: 443
targetPort: {{ .Values.developer.externalOperatorPort }}
---
kind: Endpoints
apiVersion: v1
metadata:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
subsets:
- addresses:
- ip: "{{ .Values.developer.externalOperatorIp }}"
ports:
- port: {{ .Values.developer.externalOperatorPort }}
{{ end }}
@@ -0,0 +1,78 @@
{{- if eq "true" (include "stackgres.operator.missingSGConfigCrd" .) }}
apiVersion: batch/v1
kind: Job
metadata:
namespace: {{ .Release.Namespace }}
name: "{{ .Release.Name }}-install-crd-and-sgconfig"
labels:
app: stackgres-operator-init
job: install-crd-and-sgconfig
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "10"
{{- with .Values.jobs.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ttlSecondsAfterFinished: 3600
template:
metadata:
labels:
app: stackgres-operator-init
job: install-crd-and-sgconfig
spec:
serviceAccountName: {{ .Release.Name }}-init
restartPolicy: OnFailure
terminationGracePeriodSeconds: 0
{{- with .Values.jobs.affinity}}
affinity:
{{- toYaml . | nindent 8 }}
{{- end}}
{{- with .Values.jobs.nodeSelector}}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.jobs.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: "install-crd-and-sgconfig"
image: {{ template "kubectl.image" . }}
imagePullPolicy: "IfNotPresent"
{{- with .Values.jobs.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
command:
- "/bin/bash"
- "-ecx"
- |
cat << 'EOF' > /tmp/SGConfig.yaml
{{ .Files.Get "crds/SGConfig.yaml" | nindent 12 }}
EOF
kubectl create -f /tmp/SGConfig.yaml || kubectl get -f /tmp/SGConfig.yaml -o name > /dev/null
cat << 'EOF' | kubectl apply -f -
apiVersion: stackgres.io/v1
kind: SGConfig
metadata:
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
{{ regexReplaceAll "[^ ]+: null" (toYaml .Values | nindent 14) "" }}
EOF
{{- else }}
apiVersion: stackgres.io/v1
kind: SGConfig
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
{{ regexReplaceAll "[^ ]+: null" (toYaml .Values | nindent 2) "" }}
{{- end }}
@@ -0,0 +1,47 @@
---
{{ if and .Values.deploy.operator (not (and .Values.developer.externalOperatorIp .Values.developer.externalOperatorPort)) }}
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-test-connection"
labels:
app: "{{ .Release.Name }}"
group: helm-tests
annotations:
"helm.sh/hook": test
spec:
{{- with .Values.jobs.affinity}}
affinity:
{{- toYaml . | nindent 8 }}
{{- end}}
{{- with .Values.jobs.nodeSelector}}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Release.Name }}
restartPolicy: Never
terminationGracePeriodSeconds: 0
{{- with .Values.jobs.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- if or (not (.Capabilities.APIVersions.Has "project.openshift.io/v1")) .Values.developer.disableArbitraryUser }}
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
{{- end }}
containers:
- name: conn-check
image: '{{ template "kubectl.image" . }}'
imagePullPolicy: "IfNotPresent"
command:
- "bash"
- "-xe"
- "-c"
- |
POD_NAME=$(kubectl get pod -n {{ .Release.Namespace }} -o name | grep -v {{ .Release.Name }}-test-connection | grep {{ .Release.Name }})
POD_IP=$(kubectl get ${POD_NAME} -n {{ .Release.Namespace }} -o jsonpath="{ .status.podIP }")
curl -v ${POD_IP}:8080/q/health/live
{{ end }}
@@ -0,0 +1,217 @@
{{- $cert := "Cg==" }}
{{- $certSecret := lookup "v1" "Secret" .Release.Namespace (include "cert-name" .) }}
{{- if $certSecret }}
{{- if (index ($certSecret.data) "tls.crt") }}
{{- $cert = (index $certSecret.data "tls.crt") }}
{{- end }}
{{- end }}
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
{{- with .Values.clusterOwnerRefereces }}
ownerReferences:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
webhooks:
- name: sgcluster.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgclusters"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgcluster'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgpgconfig.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgpgconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgpgconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgpoolconfig.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgpoolconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgpoolconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sginstanceprofile.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sginstanceprofiles"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sginstanceprofile'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgbackupconfig.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgbackupconfigs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgbackupconfig'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgbackup.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgbackups"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgbackup'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgdistributedlogs.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgdistributedlogs"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgdistributedlogs'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgdbops.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgdbops"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgdbops'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgobjectstorage.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgobjectstorages"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgobjectstorage'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgscripts.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgscripts"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgscript'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardedclusters.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardedclusters"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgshardedcluster'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardedbackups.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardedbackups"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgshardedbackup'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
- name: sgshardeddbops.validating-webhook.stackgres.io
sideEffects: None
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["stackgres.io"]
apiVersions: ["*"]
resources: ["sgshardeddbops"]
failurePolicy: Fail
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Release.Name }}
path: '/stackgres/validation/sgshardeddbops'
caBundle: {{ $cert }}
admissionReviewVersions: ["v1"]
@@ -0,0 +1,67 @@
{{- if and .Values.deploy.restapi }}
{{- if eq "true" (include "stackgres.operator.unmodificableWebapiAdminClusterRoleBinding" .) }}
apiVersion: batch/v1
kind: Job
metadata:
namespace: {{ .Release.Namespace }}
name: "{{ .Release.Name }}-delete-webapi-admin-clusterrolebinding"
labels:
app: stackgres-operator-init
job: delete-webapi-admin-clusterrolebinding
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
"helm.sh/hook-weight": "10"
{{- with .Values.jobs.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ttlSecondsAfterFinished: 3600
template:
metadata:
labels:
app: stackgres-operator-init
job: delete-webapi-admin-clusterrolebinding
spec:
serviceAccountName: {{ .Release.Name }}-init
restartPolicy: OnFailure
terminationGracePeriodSeconds: 0
{{- with .Values.jobs.affinity}}
affinity:
{{- toYaml . | nindent 8 }}
{{- end}}
{{- with .Values.jobs.nodeSelector}}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.jobs.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: "delete-webapi-admin-clusterrolebinding"
image: {{ template "kubectl.image" . }}
imagePullPolicy: "IfNotPresent"
{{- with .Values.jobs.resources }}
resources:
{{- toYaml . | nindent 10 }}
{{- end }}
command:
- "/bin/bash"
- "-ecx"
- |
kubectl delete clusterrolebinding stackgres-restapi-admin --ignore-not-found
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: stackgres-restapi-admin
subjects:
- kind: User
name: {{ .Values.authentication.user | quote }}
roleRef:
kind: ClusterRole
name: stackgres-restapi-admin
apiGroup: rbac.authorization.k8s.io
{{- end }}
@@ -0,0 +1,119 @@
{{- if and .Values.deploy.restapi }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
api.stackgres.io/auth: user
name: stackgres-restapi-admin
rules:
- apiGroups: ["", "batch"]
resources:
- pods/exec
- configmaps
- secrets
- jobs
verbs:
- create
- apiGroups: [""]
resources:
- pods/exec
verbs:
- get
- apiGroups: ["", "batch"]
resources:
- configmaps
- secrets
- jobs
verbs:
- delete
- apiGroups: [""]
resources:
- configmaps
- secrets
verbs:
- patch
- update
- apiGroups: ["", "batch", "storage.k8s.io"]
resources:
- namespaces
- storageclasses
- pods
- services
- configmaps
- secrets
- persistentvolumes
- persistentvolumeclaims
- events
- jobs
verbs:
- get
- list
- watch
- apiGroups: ["stackgres.io"]
resources:
- sgclusters
- sgpgconfigs
- sginstanceprofiles
- sgpoolconfigs
- sgbackupconfigs
- sgbackups
- sgdistributedlogs
- sgdbops
- sgobjectstorages
- sgscripts
- sgshardedclusters
verbs:
- create
- watch
- list
- get
- update
- patch
- delete
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs
verbs:
- watch
- list
- get
- update
- patch
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
- sgclusters.stackgres.io
- sginstanceprofiles.stackgres.io
- sgpgconfigs.stackgres.io
- sgpoolconfigs.stackgres.io
- sgbackups.stackgres.io
- sgbackupconfigs.stackgres.io
- sgobjectstorages.stackgres.io
- sgdbops.stackgres.io
- sgdistributedlogs.stackgres.io
- sgshardedclusters.stackgres.io
- sgscripts.stackgres.io
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- list
- apiGroups: ["rbac.authorization.k8s.io"]
resources:
- roles
- rolebindings
- clusterroles
- clusterrolebindings
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
{{- end }}
@@ -0,0 +1,19 @@
{{- if and .Values.deploy.restapi .Values.serviceAccount.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Values.restapi.name }}
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
subjects:
- kind: ServiceAccount
name: {{ .Values.restapi.name }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Values.restapi.name }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
@@ -0,0 +1,33 @@
{{- if and .Values.deploy.restapi .Values.serviceAccount.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Values.restapi.name }}
annotations:
meta.helm.sh/release-name: {{ .Release.Name }}
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups:
- ""
resources:
- users
- groups
- serviceaccount
verbs:
- impersonate
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- ""
resources:
- secrets # Secret Verification authentication
verbs:
- get
- list
{{- end }}
@@ -0,0 +1,82 @@
{{- if and .Values.deploy.restapi }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
api.stackgres.io/auth: user
name: stackgres-restapi-reader
rules:
- apiGroups: ["", "batch"]
resources:
- pods/exec
verbs:
- create
- apiGroups: [""]
resources:
- pods/exec
verbs:
- get
- apiGroups: ["", "batch", "storage.k8s.io"]
resources:
- namespaces
- storageclasses
- pods
- services
- configmaps
- secrets
- persistentvolumes
- persistentvolumeclaims
- events
- jobs
verbs:
- get
- list
- watch
- apiGroups: ["stackgres.io"]
resources:
- sgclusters
- sgpgconfigs
- sginstanceprofiles
- sgpoolconfigs
- sgbackupconfigs
- sgbackups
- sgdistributedlogs
- sgdbops
- sgobjectstorages
- sgscripts
- sgshardedclusters
verbs:
- watch
- list
- get
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs
verbs:
- watch
- list
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
- sgclusters.stackgres.io
- sginstanceprofiles.stackgres.io
- sgpgconfigs.stackgres.io
- sgpoolconfigs.stackgres.io
- sgbackups.stackgres.io
- sgbackupconfigs.stackgres.io
- sgobjectstorages.stackgres.io
- sgdbops.stackgres.io
- sgdistributedlogs.stackgres.io
- sgshardedclusters.stackgres.io
- sgscripts.stackgres.io
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- list
{{- end }}
@@ -0,0 +1,105 @@
{{- if and .Values.deploy.restapi }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
api.stackgres.io/auth: user
name: stackgres-restapi-writer
rules:
- apiGroups: ["", "batch"]
resources:
- pods/exec
- configmaps
- secrets
- jobs
verbs:
- create
- apiGroups: [""]
resources:
- pods/exec
verbs:
- get
- apiGroups: ["", "batch"]
resources:
- configmaps
- secrets
- jobs
verbs:
- delete
- apiGroups: [""]
resources:
- configmaps
- secrets
verbs:
- patch
- update
- apiGroups: ["", "batch", "storage.k8s.io"]
resources:
- namespaces
- storageclasses
- pods
- services
- configmaps
- secrets
- persistentvolumes
- persistentvolumeclaims
- events
- jobs
verbs:
- get
- list
- watch
- apiGroups: ["stackgres.io"]
resources:
- sgclusters
- sgpgconfigs
- sginstanceprofiles
- sgpoolconfigs
- sgbackupconfigs
- sgbackups
- sgdistributedlogs
- sgdbops
- sgobjectstorages
- sgscripts
- sgshardedclusters
verbs:
- create
- watch
- list
- get
- update
- patch
- delete
- apiGroups: ["stackgres.io"]
resources:
- sgconfigs
verbs:
- watch
- list
- get
- update
- patch
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
resourceNames:
- sgconfigs.stackgres.io
- sgclusters.stackgres.io
- sginstanceprofiles.stackgres.io
- sgpgconfigs.stackgres.io
- sgpoolconfigs.stackgres.io
- sgbackups.stackgres.io
- sgbackupconfigs.stackgres.io
- sgobjectstorages.stackgres.io
- sgdbops.stackgres.io
- sgdistributedlogs.stackgres.io
- sgshardedclusters.stackgres.io
- sgscripts.stackgres.io
verbs:
- get
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- list
{{- end }}