Skip to content

Commit 9cbc826

Browse files
committed
be able to add containers to Kiali pod
fixes: kiali/kiali#5028
1 parent b12c2f8 commit 9cbc826

File tree

8 files changed

+27
-1
lines changed

8 files changed

+27
-1
lines changed

crd-docs/cr/kiali.io_v1alpha1_kiali.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ spec:
6262
deployment:
6363
# default: accessible_namespaces is undefined
6464
accessible_namespaces: [ "my-mesh.*" ]
65+
additional_pod_containers_yaml: {}
6566
# default: additional_service_yaml is empty
6667
additional_service_yaml:
6768
externalName: "kiali.example.com"

crd-docs/crd/kiali.io_kialis.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ spec:
236236
type: array
237237
items:
238238
type: string
239+
additional_pod_containers_yaml:
240+
description: "Additional containers to add to the list of pod containers. Use this to add sidecar(s) to the Kiali pod. Use with care since sidecars may cause the Kiali container itself to operate incorrectly. It is up to the user who added the additional containers to ensure it works properly inside the Kiali pod; Kiali makes no guarantee additional containers will work. You can utilize container environment variables to pass data to the containers via mounted custom secrets (see spec.deployment.custom_secrets)."
241+
type: object
242+
x-kubernetes-preserve-unknown-fields: true
239243
additional_service_yaml:
240244
description: "Additional custom yaml to add to the service definition. This is used mainly to customize the service type. For example, if the `deployment.service_type` is set to 'LoadBalancer' and you want to set the loadBalancerIP, you can do so here with: `additional_service_yaml: { 'loadBalancerIP': '78.11.24.19' }`. Another example would be if the `deployment.service_type` is set to 'ExternalName' you will need to configure the name via: `additional_service_yaml: { 'externalName': 'my.kiali.example.com' }`. A final example would be if external IPs need to be set: `additional_service_yaml: { 'externalIPs': ['80.11.12.10'] }`"
241245
type: object

manifests/kiali-ossm/manifests/kiali.clusterserviceversion.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ spec:
226226
value: "false"
227227
- name: ALLOW_AD_HOC_KIALI_IMAGE
228228
value: "false"
229+
- name: ALLOW_AD_HOC_CONTAINERS
230+
value: "false"
229231
- name: ALLOW_SECURITY_CONTEXT_OVERRIDE
230232
value: "false"
231233
- name: ALLOW_ALL_ACCESSIBLE_NAMESPACES

roles/default/kiali-deploy/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ kiali_defaults:
5757

5858
deployment:
5959
accessible_namespaces: ["**"]
60+
additional_pod_containers_yaml: {}
6061
#additional_service_yaml:
6162
affinity:
6263
node: {}

roles/default/kiali-deploy/tasks/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@
156156
# restrict to 40 chars, not 63, because instance_name is a prefix and we need to prepend additional chars for some resource names (like "-service-account")
157157
- kiali_vars.deployment.instance_name is not regex('^(?![0-9]+$)(?!-)[a-z0-9-]{,40}(?<!-)$')
158158

159+
- name: Only allow ad-hoc containers when appropriate
160+
fail:
161+
msg: "The operator is forbidden from installing additional containers into the Kiali pod."
162+
when:
163+
- kiali_vars.deployment.additional_pod_containers_yaml|length > 0
164+
- lookup('env', 'ALLOW_AD_HOC_CONTAINERS') | default('false', True) != "true"
165+
159166
- name: "Determine environment to store in status"
160167
set_fact:
161168
status_environment: "{{ status_environment | default({}) | combine({item.0: item.1}) }}"

roles/default/kiali-deploy/tasks/snake_camel_case.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,9 @@
119119
{% set kiali_vars=kiali_vars | combine({'deployment': {'security_context': current_cr.spec.deployment.security_context}}, recursive=True) %}
120120
{% endif %}
121121
{# #}
122-
{{ kiali_vars }}
122+
{# deployment.additional_pod_containers_yaml #}
123+
{% if kiali_vars.deployment.additional_pod_containers_yaml is defined and kiali_vars.deployment.additional_pod_containers_yaml | length > 0 %}
124+
{% set _=kiali_vars['deployment'].pop('additional_pod_containers_yaml') %}
125+
{% set kiali_vars=kiali_vars | combine({'deployment': {'additional_pod_containers_yaml': current_cr.spec.deployment.additional_pod_containers_yaml }}, recursive=True) %}
126+
{% endif %}
127+
{{ kiali_vars }}

roles/default/kiali-deploy/templates/kubernetes/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ spec:
128128
{{ kiali_vars.deployment.resources | to_nice_yaml(indent=0) | trim | indent(10) }}
129129
{% else %}
130130
resources: null
131+
{% endif %}
132+
{% if kiali_vars.deployment.additional_pod_containers_yaml|length > 0 %}
133+
{{ kiali_vars.deployment.additional_pod_containers_yaml | to_nice_yaml(indent=0) | trim | indent(6) }}
131134
{% endif %}
132135
volumes:
133136
- name: kiali-configuration

roles/default/kiali-deploy/templates/openshift/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ spec:
132132
{{ kiali_vars.deployment.resources | to_nice_yaml(indent=0) | trim | indent(10) }}
133133
{% else %}
134134
resources: null
135+
{% endif %}
136+
{% if kiali_vars.deployment.additional_pod_containers_yaml|length > 0 %}
137+
{{ kiali_vars.deployment.additional_pod_containers_yaml | to_nice_yaml(indent=0) | trim | indent(6) }}
135138
{% endif %}
136139
volumes:
137140
- name: kiali-configuration

0 commit comments

Comments
 (0)