Merge "Bring necessary upstream commits"
This commit is contained in:
commit
3356ea6a6f
2 files changed
+792
No files matched your search
+791
@@ -0,0 +1,791 @@
|
||||
From 820f3770b4134e58c59d10eb667bd84229d82e6d Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Caires <DanielMarques.Caires@windriver.com>
|
||||
Date: Wed, 12 Mar 2025 07:57:44 -0300
|
||||
Subject: [PATCH] Bring necessary upstream commits
|
||||
|
||||
MariaDB Helm-chart was creating a service that had no clear
|
||||
definition and had no labels. This patch brings 3 commits
|
||||
from upstream OSH-I in which they changed the location
|
||||
where the service is created and added the proper labels.
|
||||
|
||||
Commits:
|
||||
https://opendev.org/openstack/openstack-helm-infra/commit/954e338d17e2dc8394dcd076cceca1e7777c8968
|
||||
https://opendev.org/openstack/openstack-helm-infra/commit/475a0c4b44b9c815fbbafaf1b1d485c9d2973878
|
||||
https://opendev.org/openstack/openstack-helm-infra/commit/d27ea2474504653383d005adcbc043b34d62eccd
|
||||
|
||||
---
|
||||
.../templates/snippets/_service_params.tpl | 61 ++++++++
|
||||
.../templates/bin/_mariadb_controller.py.tpl | 112 ++++++++++++++
|
||||
mariadb/templates/bin/_start.py.tpl | 143 +-----------------
|
||||
mariadb/templates/configmap-bin.yaml | 4 +
|
||||
mariadb/templates/deployment-controller.yaml | 119 +++++++++++++++
|
||||
mariadb/templates/service-discovery.yaml | 5 +
|
||||
mariadb/templates/service-master.yaml | 33 ++++
|
||||
mariadb/templates/service.yaml | 1 +
|
||||
mariadb/templates/statefulset.yaml | 37 +----
|
||||
mariadb/values.yaml | 34 ++++-
|
||||
10 files changed, 376 insertions(+), 173 deletions(-)
|
||||
create mode 100644 helm-toolkit/templates/snippets/_service_params.tpl
|
||||
create mode 100644 mariadb/templates/bin/_mariadb_controller.py.tpl
|
||||
create mode 100644 mariadb/templates/deployment-controller.yaml
|
||||
create mode 100644 mariadb/templates/service-master.yaml
|
||||
|
||||
diff --git a/helm-toolkit/templates/snippets/_service_params.tpl b/helm-toolkit/templates/snippets/_service_params.tpl
|
||||
new file mode 100644
|
||||
index 00000000..6233a935
|
||||
--- /dev/null
|
||||
+++ b/helm-toolkit/templates/snippets/_service_params.tpl
|
||||
@@ -0,0 +1,61 @@
|
||||
+{{/*
|
||||
+Copyright 2017 The Openstack-Helm Authors.
|
||||
+
|
||||
+Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+you may not use this file except in compliance with the License.
|
||||
+You may obtain a copy of the License at
|
||||
+
|
||||
+ http://www.apache.org/licenses/LICENSE-2.0
|
||||
+
|
||||
+Unless required by applicable law or agreed to in writing, software
|
||||
+distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+See the License for the specific language governing permissions and
|
||||
+limitations under the License.
|
||||
+*/}}
|
||||
+{{/*
|
||||
+abstract: |
|
||||
+ Inserts kubernetes service parameters from values as is.
|
||||
+values: |
|
||||
+ network:
|
||||
+ serviceExample:
|
||||
+ service:
|
||||
+ type: loadBalancer
|
||||
+ loadBalancerIP: 1.1.1.1
|
||||
+usage: |
|
||||
+ ---
|
||||
+ apiVersion: v1
|
||||
+ kind: Service
|
||||
+ metadata:
|
||||
+ name: 'serviceExample'
|
||||
+ spec:
|
||||
+ ports:
|
||||
+ - name: s-example
|
||||
+ port: 1111
|
||||
+ {{ .Values.network.serviceExample | include "helm-toolkit.snippets.service_params" | indent 2 }}
|
||||
+return: |
|
||||
+ type: loadBalancer
|
||||
+ loadBalancerIP: 1.1.1.1
|
||||
+*/}}
|
||||
+
|
||||
+{{- define "helm-toolkit.snippets.service_params" }}
|
||||
+{{- $serviceParams := dict }}
|
||||
+{{- if hasKey . "service" }}
|
||||
+{{- $serviceParams = .service }}
|
||||
+{{- end }}
|
||||
+{{- if hasKey . "node_port" }}
|
||||
+{{- if hasKey .node_port "enabled" }}
|
||||
+{{- if .node_port.enabled }}
|
||||
+{{- $_ := set $serviceParams "type" "NodePort" }}
|
||||
+{{- end }}
|
||||
+{{- end }}
|
||||
+{{- end }}
|
||||
+{{- if hasKey . "external_policy_local" }}
|
||||
+{{- if .external_policy_local }}
|
||||
+{{- $_ := set $serviceParams "externalTrafficPolicy" "Local" }}
|
||||
+{{- end }}
|
||||
+{{- end }}
|
||||
+{{- if $serviceParams }}
|
||||
+{{- $serviceParams | toYaml }}
|
||||
+{{- end }}
|
||||
+{{- end }}
|
||||
diff --git a/mariadb/templates/bin/_mariadb_controller.py.tpl b/mariadb/templates/bin/_mariadb_controller.py.tpl
|
||||
new file mode 100644
|
||||
index 00000000..faf5195a
|
||||
--- /dev/null
|
||||
+++ b/mariadb/templates/bin/_mariadb_controller.py.tpl
|
||||
@@ -0,0 +1,112 @@
|
||||
+#!/usr/bin/env python3
|
||||
+
|
||||
+"""
|
||||
+Mariadb controller
|
||||
+
|
||||
+The script is responsible for set mariadb_role: primary to first
|
||||
+active pod in mariadb deployment.
|
||||
+
|
||||
+Env variables:
|
||||
+MARIADB_CONTROLLER_DEBUG: Flag to enable debug when set to 1.
|
||||
+MARIADB_CONTROLLER_CHECK_PODS_DELAY: The delay between check pod attempts.
|
||||
+MARIADB_CONTROLLER_PYKUBE_REQUEST_TIMEOUT: The timeout for kubernetes http session
|
||||
+MARIADB_CONTROLLER_PODS_NAMESPACE: The namespace to look for mariadb pods.
|
||||
+MARIADB_MASTER_SERVICE_NAME: The name of master service for mariadb.
|
||||
+
|
||||
+Changelog:
|
||||
+0.1.0: Initial varsion
|
||||
+"""
|
||||
+
|
||||
+
|
||||
+import logging
|
||||
+import os
|
||||
+import sys
|
||||
+import time
|
||||
+
|
||||
+import pykube
|
||||
+
|
||||
+MARIADB_CONTROLLER_DEBUG = os.getenv("MARIADB_CONTROLLER_DEBUG")
|
||||
+MARIADB_CONTROLLER_CHECK_PODS_DELAY = int(
|
||||
+ os.getenv("MARIADB_CONTROLLER_CHECK_PODS_DELAY", 10)
|
||||
+)
|
||||
+MARIADB_CONTROLLER_PYKUBE_REQUEST_TIMEOUT = int(
|
||||
+ os.getenv("MARIADB_CONTROLLER_PYKUBE_REQUEST_TIMEOUT", 60)
|
||||
+)
|
||||
+MARIADB_CONTROLLER_PODS_NAMESPACE = os.getenv(
|
||||
+ "MARIADB_CONTROLLER_PODS_NAMESPACE", "openstack"
|
||||
+)
|
||||
+MARIADB_MASTER_SERVICE_NAME = os.getenv(
|
||||
+ "MARIADB_MASTER_SERVICE_NAME", "mariadb"
|
||||
+)
|
||||
+
|
||||
+log_level = "DEBUG" if MARIADB_CONTROLLER_DEBUG else "INFO"
|
||||
+logging.basicConfig(
|
||||
+ stream=sys.stdout,
|
||||
+ format="%(asctime)s %(levelname)s %(name)s %(message)s",
|
||||
+ datefmt="%Y-%m-%d %H:%M:%S",
|
||||
+)
|
||||
+LOG = logging.getLogger("mariadb-controller")
|
||||
+
|
||||
+LOG.setLevel(log_level)
|
||||
+
|
||||
+
|
||||
+def login():
|
||||
+ config = pykube.KubeConfig.from_env()
|
||||
+ client = pykube.HTTPClient(
|
||||
+ config=config, timeout=MARIADB_CONTROLLER_PYKUBE_REQUEST_TIMEOUT
|
||||
+ )
|
||||
+ LOG.info(f"Created k8s api client from context {config.current_context}")
|
||||
+ return client
|
||||
+
|
||||
+
|
||||
+api = login()
|
||||
+
|
||||
+
|
||||
+def resource_list(klass, selector, namespace=None):
|
||||
+ return klass.objects(api).filter(namespace=namespace, selector=selector)
|
||||
+
|
||||
+
|
||||
+def get_mariadb_pods():
|
||||
+ sorted_pods = sorted(
|
||||
+ resource_list(
|
||||
+ pykube.Pod,
|
||||
+ {"application": "mariadb", "component": "server"},
|
||||
+ MARIADB_CONTROLLER_PODS_NAMESPACE,
|
||||
+ ).iterator(),
|
||||
+ key=lambda i: i.name,
|
||||
+ )
|
||||
+ return sorted_pods
|
||||
+
|
||||
+
|
||||
+def get_mariadb_master_service(namespace):
|
||||
+ return pykube.Service.objects(api).filter(namespace=namespace).get(name=MARIADB_MASTER_SERVICE_NAME)
|
||||
+
|
||||
+
|
||||
+def link_master_service(pod):
|
||||
+ svc = get_mariadb_master_service(MARIADB_CONTROLLER_PODS_NAMESPACE)
|
||||
+ svc.reload()
|
||||
+ if svc.obj['spec']['selector'].get('statefulset.kubernetes.io/pod-name') == pod.name:
|
||||
+ LOG.debug(f"Nothing to do, master service points to {pod.name}")
|
||||
+ else:
|
||||
+ svc.obj['spec']['selector']['statefulset.kubernetes.io/pod-name'] = pod.name
|
||||
+ svc.update()
|
||||
+ LOG.info(f"Link master service with {pod.name}")
|
||||
+
|
||||
+
|
||||
+def is_ready(pod):
|
||||
+ if pod.ready and "deletionTimestamp" not in pod.metadata:
|
||||
+ return True
|
||||
+
|
||||
+
|
||||
+def main():
|
||||
+ while True:
|
||||
+ for pod in get_mariadb_pods():
|
||||
+ pod.reload()
|
||||
+ if is_ready(pod):
|
||||
+ link_master_service(pod)
|
||||
+ break
|
||||
+ LOG.debug(f"Sleeping for {MARIADB_CONTROLLER_CHECK_PODS_DELAY}")
|
||||
+ time.sleep(MARIADB_CONTROLLER_CHECK_PODS_DELAY)
|
||||
+
|
||||
+
|
||||
+main()
|
||||
diff --git a/mariadb/templates/bin/_start.py.tpl b/mariadb/templates/bin/_start.py.tpl
|
||||
index aae1294c..edf166ed 100644
|
||||
--- a/mariadb/templates/bin/_start.py.tpl
|
||||
+++ b/mariadb/templates/bin/_start.py.tpl
|
||||
@@ -80,10 +80,6 @@ if check_env_var("STATE_CONFIGMAP"):
|
||||
state_configmap_name = os.environ['STATE_CONFIGMAP']
|
||||
logger.info("Will use \"{0}\" configmap for cluster state info".format(
|
||||
state_configmap_name))
|
||||
-if check_env_var("PRIMARY_SERVICE_NAME"):
|
||||
- primary_service_name = os.environ['PRIMARY_SERVICE_NAME']
|
||||
- logger.info("Will use \"{0}\" service as primary".format(
|
||||
- primary_service_name))
|
||||
if check_env_var("POD_NAMESPACE"):
|
||||
pod_namespace = os.environ['POD_NAMESPACE']
|
||||
if check_env_var("DIRECT_SVC_NAME"):
|
||||
@@ -96,8 +92,6 @@ if check_env_var("DISCOVERY_DOMAIN"):
|
||||
discovery_domain = os.environ['DISCOVERY_DOMAIN']
|
||||
if check_env_var("WSREP_PORT"):
|
||||
wsrep_port = os.environ['WSREP_PORT']
|
||||
-if check_env_var("MARIADB_PORT"):
|
||||
- mariadb_port = int(os.environ['MARIADB_PORT'])
|
||||
if check_env_var("MYSQL_DBADMIN_USERNAME"):
|
||||
mysql_dbadmin_username = os.environ['MYSQL_DBADMIN_USERNAME']
|
||||
if check_env_var("MYSQL_DBADMIN_PASSWORD"):
|
||||
@@ -121,8 +115,7 @@ if mysql_dbadmin_username == mysql_dbsst_username:
|
||||
sys.exit(1)
|
||||
|
||||
# Set some variables for tuneables
|
||||
-if check_env_var("CLUSTER_LEADER_TTL"):
|
||||
- cluster_leader_ttl = int(os.environ['CLUSTER_LEADER_TTL'])
|
||||
+cluster_leader_ttl = int(os.environ['CLUSTER_LEADER_TTL'])
|
||||
state_configmap_update_period = 10
|
||||
default_sleep = 20
|
||||
|
||||
@@ -145,25 +138,6 @@ def ensure_state_configmap(pod_namespace, configmap_name, configmap_body):
|
||||
|
||||
return False
|
||||
|
||||
-def ensure_primary_service(pod_namespace, service_name, service_body):
|
||||
- """Ensure the primary service exists.
|
||||
-
|
||||
- Keyword arguments:
|
||||
- pod_namespace -- the namespace to house the service
|
||||
- service_name -- the service name
|
||||
- service_body -- the service body
|
||||
- """
|
||||
- try:
|
||||
- k8s_api_instance.read_namespaced_service(
|
||||
- name=service_name, namespace=pod_namespace)
|
||||
- return True
|
||||
- except:
|
||||
- k8s_api_instance.create_namespaced_service(
|
||||
- namespace=pod_namespace, body=service_body)
|
||||
-
|
||||
- return False
|
||||
-
|
||||
-
|
||||
|
||||
def run_cmd_with_logging(popenargs,
|
||||
logger,
|
||||
@@ -414,60 +388,6 @@ def set_configmap_data(key, value):
|
||||
return safe_update_configmap(
|
||||
configmap_dict=configmap_dict, configmap_patch=configmap_patch)
|
||||
|
||||
-def safe_update_service(service_dict, service_patch):
|
||||
- """Update a service with locking.
|
||||
-
|
||||
- Keyword arguments:
|
||||
- service_dict -- a dict representing the service to be patched
|
||||
- service_patch -- a dict containign the patch
|
||||
- """
|
||||
- logger.debug("Safe Patching service")
|
||||
- # NOTE(portdirect): Explictly set the resource version we are patching to
|
||||
- # ensure nothing else has modified the service since we read it.
|
||||
- service_patch['metadata']['resourceVersion'] = service_dict[
|
||||
- 'metadata']['resource_version']
|
||||
-
|
||||
- # Retry up to 8 times in case of 409 only. Each retry has a ~1 second
|
||||
- # sleep in between so do not want to exceed the roughly 10 second
|
||||
- # write interval per cm update.
|
||||
- for i in range(8):
|
||||
- try:
|
||||
- api_response = k8s_api_instance.patch_namespaced_service(
|
||||
- name=primary_service_name,
|
||||
- namespace=pod_namespace,
|
||||
- body=service_patch)
|
||||
- return True
|
||||
- except kubernetes.client.rest.ApiException as error:
|
||||
- if error.status == 409:
|
||||
- # This status code indicates a collision trying to write to the
|
||||
- # service while another instance is also trying the same.
|
||||
- logger.warning("Collision writing service: {0}".format(error))
|
||||
- # This often happens when the replicas were started at the same
|
||||
- # time, and tends to be persistent. Sleep with some random
|
||||
- # jitter value briefly to break the synchronization.
|
||||
- naptime = secretsGen.uniform(0.8,1.2)
|
||||
- time.sleep(naptime)
|
||||
- else:
|
||||
- logger.error("Failed to set service: {0}".format(error))
|
||||
- return error
|
||||
- logger.info("Retry writing service attempt={0} sleep={1}".format(
|
||||
- i+1, naptime))
|
||||
- return True
|
||||
-
|
||||
-def set_primary_service_spec(key, value):
|
||||
- """Update a service's endpoint via patching.
|
||||
-
|
||||
- Keyword arguments:
|
||||
- key -- the key to be patched
|
||||
- value -- the value to give the key
|
||||
- """
|
||||
- logger.debug("Setting service spec.selector key={0} to value={1}".format(key, value))
|
||||
- service_dict = k8s_api_instance.read_namespaced_service(
|
||||
- name=primary_service_name, namespace=pod_namespace).to_dict()
|
||||
- service_patch = {'spec': {'selector': {}}, 'metadata': {}}
|
||||
- service_patch['spec']['selector'][key] = value
|
||||
- return safe_update_service(
|
||||
- service_dict=service_dict, service_patch=service_patch)
|
||||
|
||||
def get_configmap_value(key, type='data'):
|
||||
"""Get a configmap's key's value.
|
||||
@@ -549,35 +469,6 @@ def get_cluster_state():
|
||||
pod_namespace=pod_namespace,
|
||||
configmap_name=state_configmap_name,
|
||||
configmap_body=initial_configmap_body)
|
||||
-
|
||||
-
|
||||
- initial_primary_service_body = {
|
||||
- "apiVersion": "v1",
|
||||
- "kind": "Service",
|
||||
- "metadata": {
|
||||
- "name": primary_service_name,
|
||||
- },
|
||||
- "spec": {
|
||||
- "ports": [
|
||||
- {
|
||||
- "name": "mysql",
|
||||
- "port": mariadb_port
|
||||
- }
|
||||
- ],
|
||||
- "selector": {
|
||||
- "application": "mariadb",
|
||||
- "component": "server",
|
||||
- "statefulset.kubernetes.io/pod-name": leader
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- if ensure_primary_service(
|
||||
- pod_namespace=pod_namespace,
|
||||
- service_name=primary_service_name,
|
||||
- service_body=initial_primary_service_body):
|
||||
- logger.info("Service {0} already exists".format(primary_service_name))
|
||||
- else:
|
||||
- logger.info("Service {0} has been successfully created".format(primary_service_name))
|
||||
return state
|
||||
|
||||
|
||||
@@ -589,38 +480,6 @@ def declare_myself_cluster_leader():
|
||||
leader_expiry = "{0}Z".format(leader_expiry_raw.isoformat("T"))
|
||||
set_configmap_annotation(
|
||||
key='openstackhelm.openstack.org/leader.node', value=local_hostname)
|
||||
- logger.info("Setting primary_service's spec.selector to {0}".format(local_hostname))
|
||||
- try:
|
||||
- set_primary_service_spec(
|
||||
- key='statefulset.kubernetes.io/pod-name', value=local_hostname)
|
||||
- except:
|
||||
- initial_primary_service_body = {
|
||||
- "apiVersion": "v1",
|
||||
- "kind": "Service",
|
||||
- "metadata": {
|
||||
- "name": primary_service_name,
|
||||
- },
|
||||
- "spec": {
|
||||
- "ports": [
|
||||
- {
|
||||
- "name": "mysql",
|
||||
- "port": mariadb_port
|
||||
- }
|
||||
- ],
|
||||
- "selector": {
|
||||
- "application": "mariadb",
|
||||
- "component": "server",
|
||||
- "statefulset.kubernetes.io/pod-name": local_hostname
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- if ensure_primary_service(
|
||||
- pod_namespace=pod_namespace,
|
||||
- service_name=primary_service_name,
|
||||
- service_body=initial_primary_service_body):
|
||||
- logger.info("Service {0} already exists".format(primary_service_name))
|
||||
- else:
|
||||
- logger.info("Service {0} has been successfully created".format(primary_service_name))
|
||||
set_configmap_annotation(
|
||||
key='openstackhelm.openstack.org/leader.expiry', value=leader_expiry)
|
||||
|
||||
diff --git a/mariadb/templates/configmap-bin.yaml b/mariadb/templates/configmap-bin.yaml
|
||||
index cc92eb69..7b6e18ab 100644
|
||||
--- a/mariadb/templates/configmap-bin.yaml
|
||||
+++ b/mariadb/templates/configmap-bin.yaml
|
||||
@@ -53,4 +53,8 @@ data:
|
||||
ks-user.sh: |
|
||||
{{ include "helm-toolkit.scripts.keystone_user" . | indent 4 }}
|
||||
{{- end }}
|
||||
+{{- if .Values.manifests.deployment_controller }}
|
||||
+ mariadb_controller.py: |
|
||||
+{{ tuple "bin/_mariadb_controller.py.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
|
||||
+{{- end }}
|
||||
{{- end }}
|
||||
diff --git a/mariadb/templates/deployment-controller.yaml b/mariadb/templates/deployment-controller.yaml
|
||||
new file mode 100644
|
||||
index 00000000..598d084a
|
||||
--- /dev/null
|
||||
+++ b/mariadb/templates/deployment-controller.yaml
|
||||
@@ -0,0 +1,119 @@
|
||||
+{{/*
|
||||
+Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+you may not use this file except in compliance with the License.
|
||||
+You may obtain a copy of the License at
|
||||
+
|
||||
+ http://www.apache.org/licenses/LICENSE-2.0
|
||||
+
|
||||
+Unless required by applicable law or agreed to in writing, software
|
||||
+distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+See the License for the specific language governing permissions and
|
||||
+limitations under the License.
|
||||
+*/}}
|
||||
+
|
||||
+{{- if .Values.manifests.deployment_controller }}
|
||||
+{{- if .Values.manifests.deployment_ingress }}
|
||||
+{{- fail ".Values.manifests.deployment_ingress and .Values.manifests.deployment_controlle are mutually exclusive" }}
|
||||
+{{- end }}
|
||||
+{{- $envAll := . }}
|
||||
+
|
||||
+{{- $serviceAccountName := "mariadb-controller" }}
|
||||
+{{ tuple $envAll "controller" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }}
|
||||
+---
|
||||
+apiVersion: rbac.authorization.k8s.io/v1
|
||||
+kind: Role
|
||||
+metadata:
|
||||
+ name: {{ $envAll.Release.Name }}-{{ $serviceAccountName }}-pod
|
||||
+ namespace: {{ $envAll.Release.Namespace }}
|
||||
+rules:
|
||||
+ - apiGroups:
|
||||
+ - ""
|
||||
+ resources:
|
||||
+ - pods
|
||||
+ verbs:
|
||||
+ - get
|
||||
+ - list
|
||||
+ - apiGroups:
|
||||
+ - ""
|
||||
+ resources:
|
||||
+ - services
|
||||
+ verbs:
|
||||
+ - update
|
||||
+ - patch
|
||||
+ - get
|
||||
+ - list
|
||||
+---
|
||||
+apiVersion: rbac.authorization.k8s.io/v1
|
||||
+kind: RoleBinding
|
||||
+metadata:
|
||||
+ name: {{ $envAll.Release.Name }}-{{ $serviceAccountName }}-pod
|
||||
+ namespace: {{ $envAll.Release.Namespace }}
|
||||
+roleRef:
|
||||
+ apiGroup: rbac.authorization.k8s.io
|
||||
+ kind: Role
|
||||
+ name: {{ $envAll.Release.Name }}-{{ $serviceAccountName }}-pod
|
||||
+subjects:
|
||||
+ - kind: ServiceAccount
|
||||
+ name: {{ $serviceAccountName }}
|
||||
+ namespace: {{ $envAll.Release.Namespace }}
|
||||
+---
|
||||
+
|
||||
+apiVersion: apps/v1
|
||||
+kind: Deployment
|
||||
+metadata:
|
||||
+ name: mariadb-controller
|
||||
+ annotations:
|
||||
+ {{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
|
||||
+ labels:
|
||||
+{{ tuple $envAll "mariadb" "controller" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
|
||||
+spec:
|
||||
+ replicas: {{ .Values.pod.replicas.controller }}
|
||||
+ selector:
|
||||
+ matchLabels:
|
||||
+{{ tuple $envAll "mariadb" "controller" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 6 }}
|
||||
+{{ tuple $envAll | include "helm-toolkit.snippets.kubernetes_upgrades_deployment" | indent 2 }}
|
||||
+ template:
|
||||
+ metadata:
|
||||
+ labels:
|
||||
+{{ tuple $envAll "mariadb" "controller" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }}
|
||||
+ annotations:
|
||||
+{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" | indent 8 }}
|
||||
+ configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
|
||||
+ spec:
|
||||
+ serviceAccountName: {{ $serviceAccountName }}
|
||||
+{{ dict "envAll" $envAll "application" "controller" | include "helm-toolkit.snippets.kubernetes_pod_security_context" | indent 6 }}
|
||||
+ affinity:
|
||||
+{{ tuple $envAll "mariadb" "controller" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }}
|
||||
+ nodeSelector:
|
||||
+ {{ .Values.labels.controller.node_selector_key }}: {{ .Values.labels.controller.node_selector_value }}
|
||||
+ initContainers:
|
||||
+{{ tuple $envAll "controller" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
|
||||
+ containers:
|
||||
+ - name: controller
|
||||
+{{ tuple $envAll "mariadb_controller" | include "helm-toolkit.snippets.image" | indent 10 }}
|
||||
+{{ dict "envAll" $envAll "application" "controller" "container" "controller" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }}
|
||||
+{{ tuple $envAll $envAll.Values.pod.resources.controller | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
|
||||
+ command:
|
||||
+ - /tmp/mariadb_controller.py
|
||||
+ env:
|
||||
+{{ include "helm-toolkit.utils.to_k8s_env_vars" .Values.pod.env.mariadb_controller | indent 12 }}
|
||||
+ - name: MARIADB_CONTROLLER_PODS_NAMESPACE
|
||||
+ value: {{ $envAll.Release.Namespace }}
|
||||
+ - name: MARIADB_MASTER_SERVICE_NAME
|
||||
+ value: {{ tuple "oslo_db" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
|
||||
+ volumeMounts:
|
||||
+ - name: pod-tmp
|
||||
+ mountPath: /tmp
|
||||
+ - mountPath: /tmp/mariadb_controller.py
|
||||
+ name: mariadb-bin
|
||||
+ readOnly: true
|
||||
+ subPath: mariadb_controller.py
|
||||
+ volumes:
|
||||
+ - name: pod-tmp
|
||||
+ emptyDir: {}
|
||||
+ - name: mariadb-bin
|
||||
+ configMap:
|
||||
+ name: mariadb-bin
|
||||
+ defaultMode: 365
|
||||
+{{- end }}
|
||||
diff --git a/mariadb/templates/service-discovery.yaml b/mariadb/templates/service-discovery.yaml
|
||||
index dec979ef..378878c0 100644
|
||||
--- a/mariadb/templates/service-discovery.yaml
|
||||
+++ b/mariadb/templates/service-discovery.yaml
|
||||
@@ -25,8 +25,13 @@ spec:
|
||||
port: {{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
- name: wsrep
|
||||
port: {{ tuple "oslo_db" "direct" "wsrep" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
+ - name: ist
|
||||
+ port: {{ tuple "oslo_db" "direct" "ist" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
+ - name: sst
|
||||
+ port: {{ tuple "oslo_db" "direct" "sst" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
clusterIP: None
|
||||
publishNotReadyAddresses: true
|
||||
selector:
|
||||
{{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
|
||||
+{{ .Values.network.mariadb_discovery | include "helm-toolkit.snippets.service_params" | indent 2 }}
|
||||
{{- end }}
|
||||
diff --git a/mariadb/templates/service-master.yaml b/mariadb/templates/service-master.yaml
|
||||
new file mode 100644
|
||||
index 00000000..1472e6a3
|
||||
--- /dev/null
|
||||
+++ b/mariadb/templates/service-master.yaml
|
||||
@@ -0,0 +1,33 @@
|
||||
+{{/*
|
||||
+Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+you may not use this file except in compliance with the License.
|
||||
+You may obtain a copy of the License at
|
||||
+
|
||||
+ http://www.apache.org/licenses/LICENSE-2.0
|
||||
+
|
||||
+Unless required by applicable law or agreed to in writing, software
|
||||
+distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+See the License for the specific language governing permissions and
|
||||
+limitations under the License.
|
||||
+*/}}
|
||||
+
|
||||
+{{- if .Values.manifests.service_master }}
|
||||
+{{- if .Values.manifests.service_ingress }}
|
||||
+{{- fail ".Values.manifests.service_ingress and .Values.manifests.service_master are mutually exclusive" }}
|
||||
+{{- end }}
|
||||
+
|
||||
+{{- $envAll := . }}
|
||||
+---
|
||||
+apiVersion: v1
|
||||
+kind: Service
|
||||
+metadata:
|
||||
+ name: {{ tuple "oslo_db" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
|
||||
+spec:
|
||||
+ ports:
|
||||
+ - name: mysql
|
||||
+ port: {{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
+ selector:
|
||||
+{{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
|
||||
+{{ .Values.network.mariadb_master | include "helm-toolkit.snippets.service_params" | indent 2 }}
|
||||
+{{- end }}
|
||||
diff --git a/mariadb/templates/service.yaml b/mariadb/templates/service.yaml
|
||||
index 3f7a7190..e68cbc49 100644
|
||||
--- a/mariadb/templates/service.yaml
|
||||
+++ b/mariadb/templates/service.yaml
|
||||
@@ -25,4 +25,5 @@ spec:
|
||||
port: {{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
selector:
|
||||
{{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
|
||||
+{{ .Values.network.mariadb | include "helm-toolkit.snippets.service_params" | indent 2 }}
|
||||
{{- end }}
|
||||
diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml
|
||||
index b8d3f193..b35d2d01 100644
|
||||
--- a/mariadb/templates/statefulset.yaml
|
||||
+++ b/mariadb/templates/statefulset.yaml
|
||||
@@ -47,29 +47,6 @@ rules:
|
||||
- configmaps
|
||||
verbs:
|
||||
- create
|
||||
- - apiGroups:
|
||||
- - ""
|
||||
- resources:
|
||||
- - services
|
||||
- verbs:
|
||||
- - create
|
||||
- - apiGroups:
|
||||
- - ""
|
||||
- resourceNames:
|
||||
- - {{ tuple "oslo_db" "primary" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
|
||||
- resources:
|
||||
- - services
|
||||
- verbs:
|
||||
- - get
|
||||
- - patch
|
||||
- - apiGroups:
|
||||
- - ""
|
||||
- resourceNames:
|
||||
- - {{ tuple "oslo_db" "primary" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
|
||||
- resources:
|
||||
- - endpoints
|
||||
- verbs:
|
||||
- - get
|
||||
- apiGroups:
|
||||
- ""
|
||||
resourceNames:
|
||||
@@ -190,12 +167,6 @@ spec:
|
||||
value: {{ tuple "oslo_db" "direct" "wsrep" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
|
||||
- name: STATE_CONFIGMAP
|
||||
value: {{ printf "%s-%s" .deployment_name "mariadb-state" | quote }}
|
||||
- - name: PRIMARY_SERVICE_NAME
|
||||
- value: {{ tuple "oslo_db" "primary" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }}
|
||||
- - name: CLUSTER_LEADER_TTL
|
||||
- value: {{ .Values.conf.galera.cluster_leader_ttl | quote }}
|
||||
- - name: MARIADB_PORT
|
||||
- value: {{ tuple "oslo_db" "direct" "mysql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }}
|
||||
- name: MYSQL_DBADMIN_USERNAME
|
||||
value: {{ .Values.endpoints.oslo_db.auth.admin.username }}
|
||||
- name: MYSQL_DBADMIN_PASSWORD
|
||||
@@ -221,6 +192,8 @@ spec:
|
||||
{{- end }}
|
||||
- name: MYSQL_HISTFILE
|
||||
value: {{ .Values.conf.database.mysql_histfile }}
|
||||
+ - name: CLUSTER_LEADER_TTL
|
||||
+ value: {{ .Values.conf.galera.cluster_leader_ttl | quote }}
|
||||
ports:
|
||||
- name: mysql
|
||||
protocol: TCP
|
||||
@@ -228,6 +201,12 @@ spec:
|
||||
- name: wsrep
|
||||
protocol: TCP
|
||||
containerPort: {{ tuple "oslo_db" "direct" "wsrep" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
+ - name: ist
|
||||
+ protocol: TCP
|
||||
+ containerPort: {{ tuple "oslo_db" "direct" "ist" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
+ - name: sst
|
||||
+ protocol: TCP
|
||||
+ containerPort: {{ tuple "oslo_db" "direct" "sst" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
|
||||
command:
|
||||
- /tmp/start.py
|
||||
lifecycle:
|
||||
diff --git a/mariadb/values.yaml b/mariadb/values.yaml
|
||||
index d348f587..4ec66f25 100644
|
||||
--- a/mariadb/values.yaml
|
||||
+++ b/mariadb/values.yaml
|
||||
@@ -32,6 +32,7 @@ images:
|
||||
ks_user: docker.io/openstackhelm/heat:wallaby-ubuntu_focal
|
||||
scripted_test: docker.io/openstackhelm/mariadb:ubuntu_focal-20210415
|
||||
pre_apply_cleanup: docker.io/starlingx/stx-vault-manager:master-debian-stable-latest
|
||||
+ mariadb_controller: docker.io/openstackhelm/mariadb:latest-ubuntu_focal
|
||||
pull_policy: "IfNotPresent"
|
||||
local_registry:
|
||||
active: false
|
||||
@@ -59,8 +60,16 @@ labels:
|
||||
test:
|
||||
node_selector_key: openstack-control-plane
|
||||
node_selector_value: enabled
|
||||
+ controller:
|
||||
+ node_selector_key: openstack-control-plane
|
||||
+ node_selector_value: enabled
|
||||
|
||||
pod:
|
||||
+ env:
|
||||
+ mariadb_controller:
|
||||
+ MARIADB_CONTROLLER_DEBUG: 0
|
||||
+ MARIADB_CONTROLLER_CHECK_PODS_DELAY: 10
|
||||
+ MARIADB_CONTROLLER_PYKUBE_REQUEST_TIMEOUT: 60
|
||||
probes:
|
||||
server:
|
||||
mariadb:
|
||||
@@ -146,6 +155,13 @@ pod:
|
||||
test:
|
||||
runAsUser: 999
|
||||
readOnlyRootFilesystem: true
|
||||
+ controller:
|
||||
+ pod:
|
||||
+ runAsUser: 65534
|
||||
+ container:
|
||||
+ controller:
|
||||
+ allowPrivilegeEscalation: false
|
||||
+ readOnlyRootFilesystem: true
|
||||
affinity:
|
||||
anti:
|
||||
type:
|
||||
@@ -169,6 +185,7 @@ pod:
|
||||
ingress: 2
|
||||
error_page: 1
|
||||
prometheus_mysql_exporter: 1
|
||||
+ controller: 1
|
||||
lifecycle:
|
||||
upgrades:
|
||||
deployments:
|
||||
@@ -292,7 +309,8 @@ dependencies:
|
||||
services:
|
||||
- endpoint: internal
|
||||
service: oslo_db
|
||||
-
|
||||
+ controller:
|
||||
+ services: null
|
||||
volume:
|
||||
# this value is used for single pod deployments of mariadb to prevent losing all data
|
||||
# if the pod is restarted
|
||||
@@ -621,7 +639,6 @@ endpoints:
|
||||
direct: mariadb-server
|
||||
discovery: mariadb-discovery
|
||||
error_pages: mariadb-ingress-error-pages
|
||||
- primary: mariadb
|
||||
host_fqdn_override:
|
||||
default: null
|
||||
path: null
|
||||
@@ -631,6 +648,10 @@ endpoints:
|
||||
default: 3306
|
||||
wsrep:
|
||||
default: 4567
|
||||
+ ist:
|
||||
+ default: 4568
|
||||
+ sst:
|
||||
+ default: 4444
|
||||
kube_dns:
|
||||
namespace: kube-system
|
||||
name: kubernetes-dns
|
||||
@@ -686,6 +707,13 @@ endpoints:
|
||||
default: 80
|
||||
internal: 5000
|
||||
|
||||
+network:
|
||||
+ mariadb: {}
|
||||
+ mariadb_discovery: {}
|
||||
+ mariadb_ingress: {}
|
||||
+ mariadb_ingress_error_pages: {}
|
||||
+ mariadb_master: {}
|
||||
+
|
||||
network_policy:
|
||||
mariadb:
|
||||
ingress:
|
||||
@@ -739,4 +767,6 @@ manifests:
|
||||
service: true
|
||||
statefulset: true
|
||||
config_ipv6: false
|
||||
+ deployment_controller: true
|
||||
+ service_master: true
|
||||
...
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -18,3 +18,4 @@
|
||||
0018-Add-support-for-multiple-hosts-in-a-daemonset.patch
|
||||
0019-Fix-upversion-breaking-changes.patch
|
||||
0020-removed-section-to-add-default-daemonset-to-global-l.patch
|
||||
0021-Bring-necessary-upstream-commits.patch
|
||||
Reference in new issue
Block a user