mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-17 21:36:14 +02:00
refactor pooler tls support and set pooler pod security context (#2255)
* bump pooler image * set pooler pod security context * use hard coded RunAsUser 100 and RunAsGroup 101 for pooler pod * unify generation of TLS secret mounts * extend documentation on tls support * add unit test for testing TLS support for pooler * add e2e test for tls support
This commit is contained in:
@@ -156,6 +156,26 @@ class K8s:
|
||||
while not get_services():
|
||||
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||
|
||||
def count_pods_with_volume_mount(self, mount_name, labels, namespace='default'):
|
||||
pod_count = 0
|
||||
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||
for pod in pods:
|
||||
for mount in pod.spec.containers[0].volume_mounts:
|
||||
if mount.name == mount_name:
|
||||
pod_count += 1
|
||||
|
||||
return pod_count
|
||||
|
||||
def count_pods_with_env_variable(self, env_variable_key, labels, namespace='default'):
|
||||
pod_count = 0
|
||||
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||
for pod in pods:
|
||||
for env in pod.spec.containers[0].env:
|
||||
if env.name == env_variable_key:
|
||||
pod_count += 1
|
||||
|
||||
return pod_count
|
||||
|
||||
def count_pods_with_rolling_update_flag(self, labels, namespace='default'):
|
||||
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||
return len(list(filter(lambda x: "zalando-postgres-operator-rolling-update-required" in x.metadata.annotations, pods)))
|
||||
@@ -241,6 +261,18 @@ class K8s:
|
||||
def patch_pod(self, data, pod_name, namespace="default"):
|
||||
self.api.core_v1.patch_namespaced_pod(pod_name, namespace, data)
|
||||
|
||||
def create_tls_secret_with_kubectl(self, secret_name):
|
||||
return subprocess.run(
|
||||
["kubectl", "create", "secret", "tls", secret_name, "--key=tls/tls.key", "--cert=tls/tls.crt"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
|
||||
def create_tls_ca_secret_with_kubectl(self, secret_name):
|
||||
return subprocess.run(
|
||||
["kubectl", "create", "secret", "generic", secret_name, "--from-file=ca.crt=tls/ca.crt"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
|
||||
def create_with_kubectl(self, path):
|
||||
return subprocess.run(
|
||||
["kubectl", "apply", "-f", path],
|
||||
|
||||
Reference in New Issue
Block a user