Skip to content

Commit a658bbe

Browse files
committed
be able to add containers to Kiali pod
fixes: kiali/kiali#5028
1 parent 071020f commit a658bbe

File tree

8 files changed

+30
-0
lines changed

8 files changed

+30
-0
lines changed

crd-docs/cr/kiali.io_v1alpha1_kiali.yaml

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

5858
deployment:
5959
accessible_namespaces: ["^((?!(istio-operator|kube-.*|openshift.*|ibm.*|kiali-operator)).)*$"]
60+
additional_pod_containers_yaml: {}
6061
# default: additional_service_yaml is empty
6162
additional_service_yaml:
6263
externalName: "kiali.example.com"

crd-docs/crd/kiali.io_kialis.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ spec:
217217
type: array
218218
items:
219219
type: string
220+
additional_pod_containers_yaml:
221+
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)."
222+
type: object
223+
x-kubernetes-preserve-unknown-fields: true
220224
additional_service_yaml:
221225
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'] }`"
222226
type: object

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

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ spec:
264264
value: "false"
265265
- name: ALLOW_AD_HOC_KIALI_IMAGE
266266
value: "false"
267+
- name: ALLOW_AD_HOC_CONTAINERS
268+
value: "false"
267269
- name: ALLOW_SECURITY_CONTEXT_OVERRIDE
268270
value: "false"
269271
- name: PROFILE_TASKS_TASK_OUTPUT_LIMIT

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

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ kiali_defaults:
5252

5353
deployment:
5454
accessible_namespaces: ["^((?!(istio-operator|kube-.*|openshift.*|ibm.*|kiali-operator)).)*$"]
55+
additional_pod_containers_yaml: {}
5556
#additional_service_yaml:
5657
affinity:
5758
node: {}

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

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@
143143
# 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")
144144
- kiali_vars.deployment.instance_name is not regex('^(?![0-9]+$)(?!-)[a-z0-9-]{,40}(?<!-)$')
145145

146+
- name: Only allow ad-hoc containers when appropriate
147+
fail:
148+
msg: "The operator is forbidden from installing additional containers into the Kiali pod."
149+
when:
150+
- kiali_vars.deployment.additional_pod_containers_yaml|length > 0
151+
- lookup('env', 'ALLOW_AD_HOC_CONTAINERS') | default('false', True) != "true"
152+
146153
- set_fact:
147154
status_environment: "{{ status_environment | default({}) | combine({item.0: item.1}) }}"
148155
loop: "{{ data[0] | zip(data[1]) | list }}"

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

+9
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,12 @@
176176
when:
177177
- kiali_vars.deployment.security_context is defined
178178
- kiali_vars.deployment.security_context | length > 0
179+
180+
- name: Replace snake_case with camelCase in deployment.additional_pod_containers_yaml
181+
set_fact:
182+
kiali_vars: |
183+
{% set a=kiali_vars['deployment'].pop('additional_pod_containers_yaml') %}
184+
{{ kiali_vars | combine({'deployment': {'additional_pod_containers_yaml': current_cr.spec.deployment.additional_pod_containers_yaml }}, recursive=True) }}
185+
when:
186+
- kiali_vars.deployment.additional_pod_containers_yaml is defined
187+
- kiali_vars.deployment.additional_pod_containers_yaml | length > 0

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

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ spec:
125125
{{ kiali_vars.deployment.resources | to_nice_yaml(indent=0) | trim | indent(10) }}
126126
{% else %}
127127
resources: null
128+
{% endif %}
129+
{% if kiali_vars.deployment.additional_pod_containers_yaml|length > 0 %}
130+
{{ kiali_vars.deployment.additional_pod_containers_yaml | to_nice_yaml(indent=0) | trim | indent(6) }}
128131
{% endif %}
129132
volumes:
130133
- name: kiali-configuration

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

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

0 commit comments

Comments
 (0)